Skip to content

Turris LXC setup

tkapin edited this page Feb 2, 2020 · 12 revisions

Turris LXC setup

This page describes the setup of my Turris containers. It just describes the necessary steps to get the container with the desired services (Samba, DLNA server, git backup engine) up and running.

New container creation

Initial setup

Set root password

passwd

Hostname

echo CONTAINER-NAME > /etc/hostname

where CONTAINER-NAME is the name of the container.

Note: setting the hostname only by running hostname CONTAINER-NAME is not enough as it's effective only to the next reboot.

Timezone

dpkg-reconfigure tzdata

Select Europe -> Prague. The current timezone is set by the /etc/localtime symlink.

cat $(readlink -f /etc/localtime)

Install packages

apt-get install man mc screen openssh-server

SSH authentication

Scp your public key to the container's /root and add it to authorized_keys. The .ssh directory doesn't exist yet, the simplest way to create it (with the right permissions) is to create keys for root:

ssh-keygen -C "root@CONTAINER-NAME (on Turris)"
cat id_rsa.pub >> .ssh/authorized_keys

Disable container's root authentication by password. Edit /etc/ssh/sshd_config and change the PermitRootLogin option to without-password and restart the service.

/etc/init.d/sshd restart

Services

Samba

Samba will be set up so that it requires authentication, but the main share is storing files as nobody:nogroup.

apt-get install samba

Config file - smb.conf

The config file contains only items that are not default per smb.conf man page.

man smb.conf

The main config is at /etc/samba/smb.conf.

Backup this config first:

cp /etc/samba/smb.conf /etc/samba/smb.conf.orig

Then replace the config with the content below. Only options with non-default values are set.

[global]
    netbios name = servicebox
    workgroup = WORKGROUP
    server string = Turris Omnia
    log file = /var/log/samba/%m.log
    log level = 3

[share]
    path = /srv/samba/share
    read only = no
    create mask = 644
    directory mask = 775
    force user = nobody
    force group = nogroup

Restart the samba server to apply tyhe changes:

/etc/init.d/samba restart

Create the share on the filesystem

Create the share corresponding to the path option in the [share] section above and set its ownership to nobody:nogroup. In case an attempt to write a file from the mounted Samba share on Windows fails, the problem is usually with the share permissions on the filesystem.

mkdir -p /srv/samba/share
chown nobody:nogroup /srv/samba/share

Create and add users

Every Samba user has to have a corresponding system user account. These accounts don't have to have homes or shells set though.

useradd -M -s /bin/false USER
smbpasswd -a USER

This will create user USER without home directory (-M option) and with /bin/false used as shell. The users don't have password set by default (see the exclamation mark in the password filed of /etc/shadow).

The smbpasswd then creates the corresponding Samba user in the default database, which is stored at /var/lib/samba/private/passdb.tdb.

To list users, use

pdbedit -L -v

DLNA server

The setup of minidlna is pretty simple. Just install it and configure the location of the data. Unfortunately, it's not possible (as of Feb 2019) to update the icon of the DLNA server without recompiling it from sources.

apt-get install minidlna

The config is located at /etc/minidlna.conf.

The parameter that needs to be updated is the notify interval that determines how often the DLNA server advertises itself over the network.

# SSDP notify interval, in seconds.
notify_interval=60

To set up log levels for various subsystems, set

log_level=general=debug,artwork=warn,database=debug,inotify=debug,scanner=debug,metadata=debug,http=warn,ssdp=warn,tivo=warn

If systemd service definition is missing at /etc/systemd/system/minidlna.service, it can be defined (to prevent redirection to /etc/init.d scripts as

[Unit]
Description=MiniDLNA is a DLNA/UPnP-AV server software
After=syslog.target local-fs.target network.target

[Service]
User=minidlna
Group=minidlna
Type=forking
ExecStart=/usr/sbin/minidlnad -f /etc/minidlna.conf

[Install]
WantedBy=multi-user.target

Troubleshooting

In case the minidlna service doesn't start and there is no etry in the log file, verify that the directory where the case is located (usually /var/cache/minidlna) exists and is owned by minidlna:minidlna.

Git backup

Clone this wiki locally