How to install Subsonic on MacOS using LaunchDaemon

Tutorials, tips and tricks.

Moderator: moderators

How to install Subsonic on MacOS using LaunchDaemon

Postby dandjo » Fri Jul 08, 2011 9:04 am

Hi folks,

I struggled with running my Subsonic installation with Apple's LaunchDaemon. LaunchDaemon starts Subsonic as root at system startup. Here's how i did.

Step 1: Download Subsonic standalone version and put contents in "/opt/local/subonic" (be careful with rights: folder and files should have "755 root admin").

Step 2: Edit "/opt/local/subsonic/subsonic.sh" to set the startup variables.
Code: Select all
SUBSONIC_HOME=/opt/local/var/subsonic
SUBSONIC_HOST=0.0.0.0
SUBSONIC_PORT=4040
SUBSONIC_HTTPS_PORT=0
SUBSONIC_CONTEXT_PATH=/
SUBSONIC_MAX_MEMORY=200
SUBSONIC_PIDFILE=
SUBSONIC_DEFAULT_MUSIC_FOLDER=/path/to/music
SUBSONIC_DEFAULT_PODCAST_FOLDER=/path/to/podcasts
SUBSONIC_DEFAULT_PLAYLIST_FOLDER=/path/to/playlists


Step 3: Start Subsonic once with the startup script to ensure that all folders exist: "sh /opt/local/subsonic/subsonic.sh".

Step 4: Create LaunchDaemon ParameterList in "/Library/LaunchDaemons/org.subsonic.plist" with rights "755 root wheel".
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key><string>org.subsonic</string>
        <key>ProgramArguments</key>
                <array>
                        <string>java</string>
                        <string>-Xmx200m</string>
                        <string>-Dsubsonic.home=/opt/local/var/subsonic</string>
                        <string>-Dsubsonic.host=0.0.0.0</string>
                        <string>-Dsubsonic.port=4040</string>
                        <string>-Dsubsonic.httpsPort=0</string>
                        <string>-Dsubsonic.contextPath=/</string>
                        <string>-Dsubsonic.defaultMusicFolder=/path/to/music</string>
                        <string>-Dsubsonic.defaultPodcastFolder=/path/to/podcasts</string>
                        <string>-Dsubsonic.defaultPlaylistFolder=/path/to/playlists</string>
                        <string>-Djava.awt.headless=true</string>
                        <string>-jar</string>
                        <string>subsonic-booter-jar-with-dependencies.jar</string>
                </array>
        <key>WorkingDirectory</key><string>/opt/local/subsonic</string>
        <key>StandardErrorPath</key><string>/opt/local/var/subsonic/subsonic.log</string>
        <key>StandardOutPath</key><string>/opt/local/var/subsonic/subsonic.log</string>
        <key>Debug</key><false/>
        <key>Disabled</key><false/>
        <key>OnDemand</key><false/>
        <key>RunAtLoad</key><true/>
</dict>
</plist>


Step 5: Reboot and check if subsonic started without problems (have a look at "/opt/local/var/subsonic/subsonic.log").

Improvement suggestions are welcome.

Good luck!
dandjo
dandjo
 
Posts: 9
Joined: Mon Jan 17, 2011 3:11 pm

Re: How to install Subsonic on MacOS using LaunchDaemon

Postby colin » Thu Mar 01, 2012 4:49 pm

Thanks for this. Works great.
colin
 
Posts: 12
Joined: Thu Mar 01, 2012 10:47 am

Why?

Postby spookybathtub » Fri Apr 27, 2012 7:08 am

Why would you want to run Subsonic as root? Sounds like an security risk with no benefit.
spookybathtub
 
Posts: 110
Joined: Thu Oct 07, 2010 7:13 am

Re: How to install Subsonic on MacOS using LaunchDaemon

Postby dandjo » Fri Apr 27, 2012 7:33 am

Because LaunchDaemon needs root afaik.
dandjo
 
Posts: 9
Joined: Mon Jan 17, 2011 3:11 pm

Re: How to install Subsonic on MacOS using LaunchDaemon

Postby spookybathtub » Fri Apr 27, 2012 3:11 pm

Yes, but you could instead make it a LaunchAgent with a normal user. Or simply add Subsonic.app to Login Items in the GUI. I just don't see the benefit of using a LaunchDaemon.
spookybathtub
 
Posts: 110
Joined: Thu Oct 07, 2010 7:13 am

Re: How to install Subsonic on MacOS using LaunchDaemon

Postby dandjo » Fri Apr 27, 2012 5:01 pm

Placing the App in login items needs a logged in user. With LaunchDeamon Subsonic will start, even if my server crashes and reboots (I disable automatic login by default > security). It is safer to run Subsonic as root than to configure a server to automatically log in on start.
dandjo
 
Posts: 9
Joined: Mon Jan 17, 2011 3:11 pm

Re: How to install Subsonic on MacOS using LaunchDaemon

Postby bushman4 » Fri Apr 27, 2012 5:42 pm

I'm surprised you can't do both... I'm a windows users, and I can create a service that runs under a non-administrative account for subsonic. Is that not possible on a mac?

Glenn
Glenn Sullivan
Subsonic 6.1.6 (Unraid Docker)
90 regular Subsonic Users

Library as of 2024-10-28:
4,527 artists
19,996 albums
282,151 songs
10201.40 GB
41,583 hours
User avatar
bushman4
 
Posts: 874
Joined: Thu Dec 02, 2010 1:47 pm
Location: Massachusetts, USA

Re: How to install Subsonic on MacOS using LaunchDaemon

Postby Munger » Mon Jan 14, 2013 6:47 pm

dandjo wrote:Because LaunchDaemon needs root afaik.


Yes, but you can specify which user you want the daemon to run as:-


UserName <string>
This optional key specifies the user to run the job as. This key is only applicable when launchd is
running as root.

GroupName <string>
This optional key specifies the group to run the job as. This key is only applicable when launchd is
running as root. If UserName is set and GroupName is not, the the group will be set to the default
group of the user.
Munger
 
Posts: 22
Joined: Sat Mar 26, 2011 5:26 pm


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 13 guests