This article will show you how to install Madsonic. Madsonic is a web-based media library and media streamer with jukebox functionality.
You'll need to execute some commands via SSH to use this software. There is a separate guide on how to connect to your slot via SSH. Commands are kept as simple as possible and in most cases will simply need to be copied and pasted into the terminal window (then executed by pressing the Enter key).
Table of contents
Madsonic requires an updated version of Java to run. Please install a later version of Java first, then return to this section.
You should also install FFMpeg to allow Madsonic to transcode to your device if needed.
Install Madsonic by logging in via SSH, then copying and pasting the following:
mkdir -p ~/private/madsonic wget -qO ~/madsonic.zip https://download.madsonic.org/6.2/20190425_madsonic-6.2.9084-standalone.zip unzip -qo ~/madsonic.zip -d ~/private/madsonic rm ~/madsonic.zip
By default, you will access the software in your browser by using the URL with a port number. If you consider the URL without a port number to be neater, you will need to configure a proxypass.
If you want to proxypass, please run the following command first:
sed -i 's|MADSONIC_CONTEXT_PATH=/|MADSONIC_CONTEXT_PATH=/'$(whoami)'/madsonic|g' ~/private/madsonic/madsonic.sh
The context path option will add /username/madsonic to the URL (so the start command below will return an incorrect URL).
Configuring before starting Madsonic
You'll need to make some configuration changes to Madsonic before you can run it. To make those changes, simply copy and paste the following:
sed -i 's|MADSONIC_HOME=/var/madsonic|MADSONIC_HOME=~/private/madsonic|g' ~/private/madsonic/madsonic.sh sed -i 's|MADSONIC_PORT=4040|MADSONIC_PORT='"$(shuf -i 10001-32001 -n 1)"'|g' ~/private/madsonic/madsonic.sh sed -i 's|MADSONIC_INIT_MEMORY=256|MADSONIC_INIT_MEMORY=2048|g' ~/private/madsonic/madsonic.sh sed -i 's|MADSONIC_MAX_MEMORY=512|MADSONIC_MAX_MEMORY=2048|g' ~/private/madsonic/madsonic.sh sed -i 's|MADSONIC_PIDFILE=|MADSONIC_PIDFILE=~/private/madsonic/madsonic.sh.PID|g' ~/private/madsonic/madsonic.sh sed -i 's|quiet=0|quiet=1|g' ~/private/madsonic/madsonic.sh sed -i '23 i export LANG=en_GB.UTF-8' ~/private/madsonic/madsonic.sh sed -i "23 i export LC_ALL=en_GB.UTF-8\n" ~/private/madsonic/madsonic.sh sed -i '23 i export LANGUAGE=en_GB.UTF-8' ~/private/madsonic/madsonic.sh
Starting, stopping and restarting
This section covers the Madsonic process - starting it, stopping it and restarting it. It also covers checking if the process is running, in case that becomes necessary.
You can start Madsonic and print its URL with the following:
~/private/madsonic/madsonic.sh && echo "http://$(hostname -f):$(sed -rn 's|(.*)MADSONIC_PORT=(.*)|\2|p;q' ~/private/madsonic/madsonic.sh)/$(whoami)/madsonic" | grep http
If you need to check that it's running, you can run the command below. If the process is running a list of relevant process ID numbers will be listed. If nothing is listed, the process is not running.
pgrep -fu "$(whoami)" "madsonic"
The Madsonic process is stopped by executing:
kill "$(pgrep -fu "$(whoami)" "madsonic")"
If Madsonic needs to be restarted, copy and paste this command:
kill "$(pgrep -fu "$(whoami)" "madsonic")" && sleep 5 && ~/private/madsonic/madsonic.sh && echo "http://$(hostname -f):$(sed -rn 's|(.*)MADSONIC_PORT=(.*)|\2|p;q' ~/private/madsonic/madsonic.sh)/$(whoami)/madsonic" | grep http
Please note that if you want to stop the process for Madsonic, it's best to check it afterwards to make sure it has stopped. If the process has crashed and will not stop when requested, you can kill it with:
kill -9 "$(pgrep -fu "$(whoami)" "madsonic")"
Automatically restarting Madsonic if it is not running
Cron jobs can be used to check if Madsonic is running and start it up if it is not. There is a separate page on configuring cron jobs.
When you first access Madsonic you'll get a warning that your instance is not secured. Log in with username admin and password admin. You should see a Getting Started section, the first item of which is to change the administrator password. Click its link, scroll down and tick/check the box Change password. Two fields will open up - to set and confirm your chosen password. Once entered, click on Save.
kill -9 "$(pgrep -fu "$(whoami)" "madsonic")" rm -rf ~/private/madsonic/