2011-04-03

Non-root subsonic installation

I choose already for some time subsonic as music streaming and jukebox system. This was working well with the basic installation information provided from the website:

sudo apt-get install openjdk-6-jre
sudo dpkg -i subsonic-x.x.deb
sudo apt-get install lame flac faad vorbis-tools ffmpeg

First problem: no sound in jukebox mode. The solution is to install the java from sun, and use this one instead of the openjdk provided by default.

sudo apt-get install sun-java6-jre sun-java6-plugin

Installing is only half of the job. Selecting what java to use is done with following command:

update-java-alternatives -s java-6-sun

Second problem: subsonic is now running as root. This is not a big deal when the server is intended to be use behind your firewall, but becomes a bit scary when allowing access from internet. The solution is described in the official subsonic forum. I preferred the second post of the thread explaining how to do the changes to run as a specific user still using the simple package based installation. The first post requires to configure your own web-server, a bit more complex for similar result.

I used slightly different commands:
sudo su
service subsonic stop
adduser --system --no-create-home subsonic
adduser subsonic audio
chown -R subsonic:nogroup /tmp/subsonic 
chown -R subsonic:nogroup /var/subsonic 
chown -R root:root /var/subsonic/transcode 
chown -R root:root /var/subsonic/jetty/*/webapp

Now we need to edit /usr/share/subsonic/subsonic.sh to use sudo -u subsonic before the call to java. The line looks like that with the change applied:

sudo -u subsonic ${JAVA} -Xmx${SUBSONIC_MAX_MEMORY}m \

Now subsonic can be started, and we can verify it uses the correct assigned user instead of root. Start subsonic: service subsonic start.

ps -Af | grep subsonic shows what user runs subsonic.

To finish, enjoy some music :)

9 comments:

  1. Worked like a charm. Thanks!

    ReplyDelete
  2. It's 2014 now and quite a few things have changed :)

    Try the webupd8team java ppa for starters:

    http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html

    I found it useful to install the oracle-java7-set-default package, too, because I'm lazy.

    Finally, /etc/default/subsonic lets you change the user:

    SUBSONIC_ARGS="--max-memory=512 --port=4041"
    SUBSONIC_USER=subsonic

    ReplyDelete
  3. Thanks for this! Totally was able to fix the same issue on my install.

    ReplyDelete
  4. For me, process is still running as root after stopping the service and making the modification to /etc/default/subsonic (SUBSONIC_USER=user). Also rebooted the server.
    Any ideas please?

    ReplyDelete
  5. For me, process is still running as root after stopping the service and making the modification to /etc/default/subsonic (SUBSONIC_USER=user). Also rebooted the server.
    Any ideas please?

    ReplyDelete
    Replies
    1. Did you ever get this fixed Phil? I'm having the same issue.

      Delete
  6. Madsonic ... @#%$ this noise ....

    ReplyDelete
  7. edit: /usr/share/subsonic/subsonic.sh

    add: sudo -u subsonic

    to the line that looks like this: ${JAVA} -Xmx${SUBSONIC_MAX_MEMORY}m

    Line 127 in mine.

    ReplyDelete
  8. resulting line should look like this:

    sudo -u subsonic ${JAVA} -Xmx${SUBSONIC_MAX_MEMORY}m

    ReplyDelete