How to AutoStart SABNzb+ (Or any application)
#1
Hey All,

New to the forums, new to linux in general.

I have had my Xbmc Live machine up for a few weeks and all is well, just trying to streamline adding media to it.

Somehow I successfully got SABNzb+ installed and am able to run it when i SSH into my xbmc machine from OS X. But this isn't the optimal solution as when I terminate my SSH session, it closes SABNzb.

So my question is how do I set it up so that the program will launch automatically during startup and all I have to do is drop .Nzbs in my watch folder?

Thanks for any help, greatly appreciated.

H
Reply
#2
Either create a proper startup script and place it in /etc/init.d or the quick and easy way is to add the command you run to the file /etc/rc.local and it will be started at boot time.
Reply
#3
This is the one I use that came with the install...may have to adjust the location of the files if you installed it in a different location:

/init.d/sabnzbdplus:

Code:
#!/bin/sh
#
# Copyright (C) 2008-2009 by JCF Ploemen <[email protected]>
# released under GPL, version 2 or later

### BEGIN INIT INFO
# Provides:          sabnzbdplus
# Required-Start:    $local_fs $network $remote_fs
# Required-Stop:     $local_fs $network $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: SABnzbd+ binary newsgrabber
### END INIT INFO

DAEMON=/usr/bin/sabnzbdplus

[ -x $DAEMON ] || exit 0

NAME=$(basename $DAEMON)
DESC="SABnzbd+ binary newsgrabber"
SETTINGS=/etc/default/sabnzbdplus
OPTIONS="--daemon"
PYTHONEXEC="$(readlink -f $(sed -n '1s/^#\!\([a-z0-9\.\/]\+\).*/\1/p' $DAEMON))"
PIDFILE=/var/run/sabnzbdplus.pid

. /lib/lsb/init-functions

check_retval() {
        if [ $? -eq 0 ]; then
                log_end_msg 0
                return 0
        else
                log_end_msg 1
                exit 1
        fi
}

is_running() {
        # returns 0 when running, 1 otherwise
        start-stop-daemon --quiet --stop --test --user $USER --exec $PYTHONEXEC --name $NAME || return 1
}

load_settings() {
        [ -r $SETTINGS ] || exit 0
        . $SETTINGS

        [ -z "$USER" ] && {
                log_warning_msg "$DESC: not configured, aborting. See $SETTINGS";
                exit 0; }

        [ -n "$CONFIG" ] && OPTIONS="$OPTIONS --config-file $CONFIG"
        [ -n "$HOST" -a -n "$PORT" ] && OPTIONS="$OPTIONS --server $HOST:$PORT"
        [ -n "$EXTRAOPTS" ] && OPTIONS="$OPTIONS $EXTRAOPTS"
}

case "$1" in
        start)
                load_settings
                if ! is_running; then
                        log_daemon_msg "Starting $DESC"
                        start-stop-daemon --quiet --chuid $USER --start --exec $DAEMON -- $OPTIONS
                        check_retval
                        # create a pidfile; we don't use it but some monitoring app likes to have one
                        [ -w $(dirname $PIDFILE) ] && \
                                pgrep -f -x -n -u $USER "$(sed -n '1s/^#\!//p' $DAEMON) $DAEMON $OPTIONS" > $PIDFILE
                else
                        log_success_msg "$DESC: already running"
                fi
        ;;
        stop)
                load_settings
                if is_running; then
                        log_daemon_msg "Stopping $DESC"
                        start-stop-daemon --quiet --stop --signal 15 --retry 30 --exec $PYTHONEXEC --name $NAME --user $USER
                        check_retval
                else
                        log_success_msg "$DESC: not running"
                fi
                [ -f $PIDFILE ] && rm -f $PIDFILE
        ;;
        force-reload|restart)
                $0 stop
                $0 start
        ;;
        *)
                log_failure_msg "Usage: $0 {start|stop|restart|force-reload}"
        ;;
esac

exit 0

I made a link in /etc/rc2.d/ (and other runlevels) pointing to that script (update-rc.d sabnzbdplus start 20)
Reply
#4
Thanks for the help.

I used the script you posted and just made that the /etc/init.d/sabnzbdplus file.... But I am not quite sure how to do what you posted after the script... making a link? Forgive me as I am new to all this.

Also tried doing the rc.local file, but that didn't work.

hate to be a nuisance, but would greatly appreciate some more help.
Reply
#5
run this command:

update-rc.d sabnzbdplus start 20

it will create auto-start links to the sabnzbdplus script you created, with priority 20...you can change that priority if you want. that checks all the scripts in init.d and makes them auto start on all runlevels by putting a sym link in /etc/rc#.d/ (you can assign specific runlevels, 2 is the one you boot into...but I just make it for all).
Reply

Logout Mark Read Team Forum Stats Members Help
How to AutoStart SABNzb+ (Or any application)0