Page 1 of 1

[OS X Version] Add SABnzbd+ menu option to add launchd .plist

Posted: February 23rd, 2010, 10:12 pm
by hanzo
I would like SABnzbd+ to launch when my OS X system boots (independent of a user logging in, as a daemon).

The only way I am aware of to do this is by creating a launch .plist , which I haven't had great success with.
It would be quite nice if I could launch the SABnzbd.app and from the finder bar choose an option to run at boot, which would handle installing the .plist for me with correct settings.

FWIW, I haven't had a chance to test this yet, but I think I've finally got this sorted out:

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>GroupName</key>
        <string>admin</string>
        <key>Label</key>
        <string>com.sabnzbd.daemon</string>
        <key>ProgramArguments</key>
        <array>
                <string>/Applications/SABnzbd.app/Contents/MacOS/SABnzbd</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>StandardErrorPath</key>
        <string>/Library/Logs/sabnzbd/error.log</string>
        <key>StandardOutPath</key>
        <string>/Library/Logs/sabnzbd/sabnzbd.log</string>
        <key>UserName</key>
        <string>hanzo</string>
        <key>WorkingDirectory</key>
        <string>/Users/hanzo</string>
</dict>
</plist>
This is stored in /Library/LaunchDaemons/com.sabnzbd.daemon.plist

Re: [OS X Version] Add SABnzbd+ menu option to add launchd .plist

Posted: February 24th, 2010, 4:52 am
by rAf
Never tried this, I'll try to find a way.

Re: [OS X Version] Add SABnzbd+ menu option to add launchd .plist

Posted: February 24th, 2010, 3:50 pm
by rAf
I've managed to get it work.

This is the plist I've used :

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>com.sabnzbd.daemon</string>
	<key>ProgramArguments</key>
	<array>
		<string>/Applications/SABnzbd.app/Contents/MacOS/SABnzbd</string>
		<string>-f</string>
		<string>/Users/#YOURUSERNAME#/Library/Application Support/SABnzbd/sabnzbd.ini</string>
	</array>
	<key>UserName</key>
	<string>#YOURUSERNAME</string>
	<key>WorkingDirectory</key>
	<string>/Users/#YOURUSERNAME</string>
	<key>RunAtLoad</key>
	<true/>
</dict>
</plist>
This is stored in /Library/LaunchDaemons/com.sabnzbd.daemon.plist

The root user should be owner of the plist :

Code: Select all

sudo chown root:wheel /Library/LaunchDaemons/com.sabnzbd.daemon.plist
The service need to be registered :

Code: Select all

sudo launchctl load /Library/LaunchDaemons/com.sabnzbd.daemon.plist
If you want to unregister replace load by unload.

I hope this will work for you.

Daemons are not usually used for GUI apps, it's working but you don't have access to the menuicon anymore...
For most users, launching SABnzbd at user logging is more appropriate.

Re: [OS X Version] Add SABnzbd+ menu option to add launchd .plist

Posted: February 25th, 2010, 9:40 pm
by hanzo
Fantastic.

I realize that for most users, this is a non-issue.

But I'm running a headless box and I don't want to enable auto-login :)

Thanks rAF!