We have a new Jail but now we need to install and configure Serviio which is what I use for my DLNA service. Go to the NAS4Free web GUI, click the ‘Extensions’ menu and ‘TheBrig’ sub-menu. Now from here let’s start the Jail by clicking the icon below, its red in this screenshot to turn it off but it’ll be green when we first click it as the Jail instance is off after it has been created.
Now SSH to the NAS4Free instance and check your jail status by running the command
This will list your jails of which we need to select the one we just created. Run the command below to access the jail’s root (where the number is the jail number)
jexec 1 csh
The first change I normally make is to create some new folders where we can point the folders we want to share from the NAS4free NAS file store to within the Jail. For example, lets make a TV and Film folder.
mkdir /mnt/TV mkdir /mnt/Films
Lets add a new user (give it whatever name you want) by typing
Follow the prompts selecting defaults with the exception of the secondary groups, here we need to add the user to the additional group called ‘wheel’ without the apostrophes. This will give the new user SU access.
Ok, finally lets make life a little easier and enable SSH access so that we can make the rest of the changes without needing to log in to the NAS4Free system. Execute this command
echo 'sshd_enable="YES"' >> /etc/rc.conf
exit out of the Jail session and then go back to TheBrig dashboard and stop the Jail by hitting the red button shown in the first screenshot.
If you’ve been following these posts you’ll probably remember the Fstab section in the Jail edit from the ‘Setting the Jail Rules, NAS4Free’ post. Lets get back to this section, once there we can now add in the folders we want to share from the NAS4Free store to the Jail we created.
The command we need to type is the NAS4Free store folder followed by the Jail folder we want to point to and then some system commands including whether we have read-write or read-only access to the NAS4Free NAS store folder. It’ll look like this:
/path/to/your/tvfolder/TV /mnt/TV nullfs ro 0 0 /path/to/your/filmsfolder/Films /mnt/Films nullfs ro 0 0
Save the settings and press the green button mentioned at the start of this post to restart the jail. Now we need to enable ports access to our Jail so that we can build the Serviio application, we can do this from the NAS4Free GUI within TheBrig dashboard. Click the ‘Updates’ tab and then the ‘Central Ports’ under this. We then select the ‘Fetch and Update’ button, once this is finish we click the ‘Port Tree Enabling’ button beside the Jail name and click save at the bottom of the screen.
Now we need to SSH to the IP address of the Jail and log in with the new user we created so we that install and configure Serviio.
Once logged in, type ‘su’ for root access.
Lets configure the domain name of the machine which serviio needs, edit the hosts file
and make sure there is an entry with the IP of your Jail and the Fully Qualified Domain Name (FQDN) of your machine for example ‘serviio.local’ without the apostrophes. Now save the changes.
All of this is really mechanical but we can build the Serviio application now. SSH and login back to your Jail. Type ‘su’ for root access and change directory by typing
now its time to build, type
make clean install
You can accept the default for most options except FFMPEG, while it is building we need to select the following options (note some of these will already be selected)
AMR_NB AMR_WB ASS FAAC FFSERVER FREI0R ICONV LAME RTMP THEORA VORBIS VPX X264 XVID
This will take time, for me it took a few hours so make sure you’ve something to watch or a good book to read.
The port build script for this release installs the wrong version of Java so we need to uninstall it and install version 8. Let’s uninstall the wrong one and install version 8.
Install the right verion
cd /usr/ports/java/openjdk7 make deinstall
cd /usr/ports/java/openjdk8 make -DBATCH clean install
Again this will take some time but at least we won’t get any prompts so we can leave the install to work its magic.
Serviio uses the dlna user for its runtime and we need to make some changes to accommodate this. We create a new home directory and change the owner to the dlna user
Now we change the home path for the dlna user
mkdir /home/dlna chown -R dlna:dlna /home/dlna
we also need to change permissions for other serviio related files and folders
chown -R dlna:dlna /usr/local/etc/serviio chown -R dlna:dlna /usr/local/share/java/classes/serviio/
We need to ensure Serviio will start at boot by typing
echo 'serviio_enable="YES"' >> /etc/rc.conf
We also need to setup Serviio with a few parameters, note change ‘IP’ to the IP of your Jail
echo serviio_args=\'-Dserviio.advertisementDuration=\"15\" -Dserviio.remoteHost=\"IP\"\' >> /etc/rc.conf
That’s the majority of what we need but there are a few other things we need to do.
I normally enable the web GUI which we developed by a third-party. This allows us to control Serviio without the need for a console client. To configure this we first install Apache by typing
cd /usr/ports/www/apache24 make -DBATCH clean install
Once done make sure Apache will survive a reboot
echo 'apache24_enable="YES"' >> /etc/rc.conf
Now we need to follow the same steps for PHP
cd /usr/ports/www/mod_php55 make -DBATCH clean install
Copy the base PHP config file to the active file
cp /usr/local/etc/php.ini-development /usr/local/etc/php.ini
We need to enable PHP within Apache by changing it’s config, edit the config file by typing
Make sure ‘index.php’ is part of your ‘DirectoryIndex’.
and at the bottom of the config file add
AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
Save and create a test PHP file
echo "<?php phpinfo(); ?>" >> /usr/local/www/apache24/data/test.php
There are also a bunch of PHP dependencies that we need to install
pkg install php55-curl php55-xml php55-mbstring php55-simplexml php55-json php55-dom dcraw
Now we’re ready to start Apache
Open a browser and browse to your test file http://IP/test.php were the ‘IP’ is the IP of your Jail.
We now need to install the web GUI, first install wget
pkg install wget
and go to the tmp directory
download the web GUI files from here:
unzip the zip file by typing
where X.X is the version of the release we’ve downloaded.Now change the directory the the newly extracted folder
and copy the contents to the HTTP web root
cp -r * /usr/local/www/apache24/data/
Ok if you’ve kept up at this point we can now start Serviio by typing
service serviio start
And stop it again
service serviio stop
It might seem a little odd that we’ve just done that but we need to change file permissions
chown -R dlna:dlna /var/db/serviio chown -R dlna:dlna /var/log/serviio
Now start Serviio again
service serviio start
That’s it, we’re done! We can now add in your directory shares… YAY! Just one small note, I noticed with the release of Serviio I’m using 1.5.2, the web GUI add/remove folder isn’t working very well. I’d recommend using the Serviio console or app for the time being. Ping me if you have any issues.