Installing mediabrowser in a jail root
Installing mediabrowser in the jail
Let’s start the jail by executing the following command:
sudo schroot -c mediabrowser
You will probably get a warning that the directory does not exist, you can ignore that one. You will also get a warning that the locale cannot be changed, we will fix that now. For commands executed in the jail I will start every line with (mediabrowser), I will assume you are the root user in the jail, so I will not use sudo.
(mediabrowser) apt-get update
(mediabrowser) apt-get install locales ca-certificates
(mediabrowser) dpkg-reconfigure locales
Pick your locale from the list (if in doubt select en_US.UTF-8 UTF8), select it with space and use tab and enter to press “OK”. Select your local as the default one (press arrow down) and hit tab and enter again to select “OK”. I also installed an editor, you can do the same, but you don’t have to:
(mediabrowser) apt-get install vim
Create the user for mediabrowser with the ID you have remembered on the previous page (replace YOUR_UID with the actual number and make sure the next command is all on one line):
(mediabrowser) adduser --UID YOUR_UID --system --shell /bin/false
--disabled-password --no-create-home mediabrowser
Download the mediabrowser debian (.deb) package from this site: https://github.com/MediaBrowser/MediaBrowser.Releases/tree/master/Server. Find the latest package there and download it to your jail, make sure you get the link to the “raw download”:
(mediabrowser) wget https://github.com/MediaBrowser/MediaBrowser.Releases/raw/master/Server/mediabrowser_3.0.5424.2_all.deb
Install the file and ignore the errors:
(mediabrowser) dpkg-i mediabrowser_3.0.5424.2_all.deb
Fix the dependencies (this will install around 115MB of packages):
(mediabrowser) apt-get -f install
Start the service:
(mediabrowser) service mediabrowser start
And check if you can reach it by connecting a browser to http://ip_of_your_host:8096/mediabrowser. You should be presented with the mediabrowser setup wizard. If you get an error make sure your firewall is allowing access to that port!
If you have your content on the same machine, you also need to synchronize some groups. Have a look at your content files and see what groups have access to it. Look for those groups in your /etc/group file on your host and copy the line to the /etc/group file in your mediabrowser jail. Make sure your mediabrowser user is added to that line. For a group called “music” the line would look like this (note that the id of the group, 1002 in this example, must be the same on the host and in the jail):
music:x:1002:mediabrowser
Making the jail start automatically
You might have noticed that your media browser session dies as soon as you leave the jail. Since nobody wants to have a console session open to keep a service alive, you will have to create a script that will start the jail as a service directly from the host. To achieve this create the file: /etc/init.d/mediabrowser-chroot (as root) with the following content
#!/bin/sh ### BEGIN INIT INFO # Provides: mediabrowser # Required-Start: smbd nfs-kernel-server # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Description: Mediabrowser ### END INIT INFO ###### Start Mediaserver in the schroot environment ###### case "$1" in start) schroot -c mediabrowser -d /etc/init.d -b -n mediabrowser-daemon # By default all your "local" mounts will be mounted read-write # If you want to have the host mount points mounted read only # you can add a line like the following for each mount point # mount -o remount,ro,bind /var/lib/schroot/mount/mediabrowser-daemon/media/your/mount/point # Now start the service schroot -c mediabrowser-daemon -d /etc/init.d -r /etc/init.d/mediabrowser start ;; stop) schroot -c mediabrowser-daemon -d /etc/init.d -r /etc/init.d/mediabrowser stop schroot -c mediabrowser-daemon -d /etc/init.d -e ;; restart) schroot -c mediabrowser-daemon -d /etc/init.d -r /etc/init.d/mediabrowser stop schroot -c mediabrowser-daemon -d /etc/init.d -e schroot -c mediabrowser -b -n mediabrowser-daemon # By default all your "local" mounts will be mounted read-write # If you want to have the host mount points mounted read only # you can add a line like the following for each mount point # mount -o remount,ro,bind /var/lib/schroot/mount/mediabrowser-daemon/media/your/mount/point # Now start the service schroot -c mediabrowser-daemon -d /etc/init.d -r /etc/init.d/mediabrowser start ;; *) echo "Usage: {start|stop|restart}" >&2 exit 1 ;; esac exit 0
Make the script executable and known with systemd:
sudo chmod +x /etc/init.d/mediabrowser-chroot
sudo systemctl daemon-reload
Now you can stop / start / restart your service with:
sudo service mediabrowser-chroot stop
sudo service mediabrowser-chroot start
sudo service mediabrowser-chroot restart
Setup a proxy in apache
If you want to access your environment from the outside over https, you can easily setup a proxy on your apache. I will not describe how to setup apache with ssl, since there are already numerous sources on the next doing just that. For a working proxy you will need to change your main configuration (have a look in /etc/apache2/sites-enabled) and add the following lines to the end of the file, before the </VirtualHost> line:
ProxyRequests On ProxyVia On ProxyPass /mediabrowser http://127.0.0.1:8096/mediabrowser ProxyPassReverse /mediabrowser http://127.0.0.1:8096/mediabrowser
This assumes you have your apache running on the host (or another jail) of your mediabrowser machine. If your mediabrowser is running somewhere else, update the 127.0.0.1 to match the IP of your mediabrowser.