How to install and configure CherryMusic on a Debian

Installation

CherryMusic depends on Python. To install Python 3, issue:

apt-get install python3

now install dependencies:

apt-get install ffmpeg imagemagick python3-unidecode lame flack vorbis-tools

Config

Create user dedicated account:

adduser cherrymusic

The easiest way to get the latest CherryMusic code and to update CherryMusic regularly is to use Git. Install Git with:

apt-get install git

Now, switch to the newly created user:

su cherrymusic

and get CherryMusic:

git clone --branch devel git://github.com/devsnd/cherrymusic.git /home/cherrymusic/cherrymusic-devel
cd /home/cherrymusic/cherrymusic-devel
python3 ./cherrymusic --help

cherry1

cherry2

Now, do the initial startup to generate the configuration and data files in your home directory:

python3 ./cherrymusic

This creates the configuration file “~/.config/cherrymusic/cherrymusic.conf”

now we need to edit the config file:

nano~/.config/cherrymusic/cherrymusic.conf

under “basedir” enter the path to your music collection – to make it easier to add further libraries I set the “basedir” to a folder /home/cherrymusic/music_dir and created symlinks in that directory pointing to the location of my music

mkdir /home/cherrymusic/music_dir
ln -s Path_to_your_music /home/cherrymusic/music_dir

now we need to update the cherrymusic database:

python3./cherrymusic--update

and then start the server to test it:

python3./cherrymusic

 

Finalization

By default cherrymusic will run on http – for security we will set it to run on https:

I already have certificate created and openssl installed so I go ahead and change the CherryMusic config:

cd /home/cherrymusic/cherrymusic-devel
 nano ~/.config/cherrymusic/cherrymusic.conf

and change the following lines accordingly:

[...]
 ssl_enabled = True
 [...]
 ssl_certificate = /etc/ssl/certs/server.crt
 [...]
 ssl_private_key = /etc/ssl/private/server.key
 [...]

Now, when you connect to CherryMusic, you should automatically be redirected to the SSL port and therefore have a secure connection.

sysvinit startup script

One final thing is to set it up as a service – instructions are provided on Lord-Simon’s github:
https://github.com/Lord-Simon/Scripts/tree/master/cherrymusic

wget --no-check-certificate https://github.com/Lord-Simon/Scripts/raw/master/cherrymusic/cherrymusic -O /etc/init.d/cherrymusic

then make the file executable:

chmod +x /etc/init.d/cherrymusic

open it for editing:

nano /etc/init.d/cherrymusic

and:
1. Add the path of your cherrymusic folder to DIR (/home/cherrymusic/cherrymusic-devel)
2. Add the python executable path to the PYTHON (/usr/bin/python3)
3. Set the USER and GROUP under which the service will run

Test the the init script by running:

service cherrymusic start

 

Once all is working OK do this:

update-rc.d /etc/init.d/cherrymusic defaults

 

Systemd startup script

I recently moved my cherrymusic service to brand new debian 8 box running systemd and so here is the systemd service script:

[Unit]
Description=CherryMusic Service
After=network.target

[Service]
User=cherrymusic
ExecStart=/usr/bin/python3 /home/cherrymusic/folder/cherrymusic #use your path to cm

[Install]
WantedBy=multi-user.target

saved that file to /etc/systemd/system as a cherrymusic.service
then to start it up just run:

systemctl start cherrymusic

to ensure it starts automatically enable the service:

systemctl enable cherrymusic

cherry3

Leave a Reply

Your email address will not be published. Required fields are marked *

2 × 4 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.