Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Hi i have a problem autostarting couchpotato 2 in ubuntu i did this:

sudo cp /home/max/.couchpotato/init/ubuntu /etc/init.d/couchpotato
sudo nano /etc/init.d/couchpotato

My file looks like this:

#! /bin/sh

### BEGIN INIT INFO
# Provides:          couchpotato
# Required-Start:    $local_fs $network $remote_fs
# Required-Stop:     $local_fs $network $remote_fs
# Should-Start:      $NetworkManager
# Should-Stop:       $NetworkManager
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts instance of CouchPotato
# Description:       starts instance of CouchPotato using start-stop-daemon
### END INIT INFO

# Check for existance of defaults file
# and utilze if available
if [ -f /etc/default/couchpotato ]; then
    . /etc/default/couchpotato
else
    echo "/etc/default/couchpotato not found using default settings.";
fi

# Script name
NAME=couchpotato

# App name
DESC=CouchPotato

## Don't edit this file
## Edit user configuation in /etc/default/couchpotato to change
##
## CP_USER= #$RUN_AS, username to run couchpotato under, the default is couchpotato
## CP_HOME= #$APP_PATH, the location of couchpotato.py, the default is /opt/couchpotato
## CP_DATA= #$DATA_DIR, the location of couchpotato.db, cache, logs, the default is /var/couchpotato
## CP_PIDFILE= #$PID_FILE, the location of couchpotato.pid, the default is /var/run/couchpotato.pid
## PYTHON_BIN= #$DAEMON, the location of the python binary, the default is /usr/bin/python
## CP_OPTS= #$EXTRA_DAEMON_OPTS, extra cli option for couchpotato, i.e. " --config_file=/home/couchpotato/couchpotato.ini"
## SSD_OPTS= #$EXTRA_SSD_OPTS, extra start-stop-daemon option like " --group=users"
##
## EXAMPLE if want to run as different user
## add CP_USER=username to /etc/default/couchpotato
## otherwise default couchpotato is used

# Run CP as username
RUN_AS=max

# Path to app 
# CP_HOME=path_to_app_CouchPotato.py
APP_PATH=/home/max/.couchpotato/

# Data directory where couchpotato.db, cache and logs are stored
DATA_DIR=${CP_DATA-/var/couchpotato}

# Path to store PID file
PID_FILE=${CP_PIDFILE-/var/run/couchpotato.pid}

# path to python bin
DAEMON=/usr/bin/python

# Extra daemon option like: CP_OPTS=" --config=/home/couchpotato/couchpotato.ini"
EXTRA_DAEMON_OPTS=${CP_OPTS-}

# Extra start-stop-daemon option like START_OPTS=" --group=users"
EXTRA_SSD_OPTS=${SSD_OPTS-}


PID_PATH=/var/run/couchpotato/server.pid
DAEMON_OPTS=" CouchPotato.py --daemon --pid_file=${PID_FILE} --data_dir=/home/max/.couchpotato"


test -x $DAEMON || exit 0

set -e

# Create PID directory if not exist and ensure the CouchPotato user can write to it
if [ ! -d $PID_PATH ]; then
    mkdir -p $PID_PATH
    chown $RUN_AS $PID_PATH
fi

if [ ! -d $DATA_DIR ]; then
    mkdir -p $DATA_DIR
    chown $RUN_AS $DATA_DIR
fi

if [ -e $PID_FILE ]; then
    PID=`cat $PID_FILE`
    if ! kill -0 $PID > /dev/null 2>&1; then
        echo "Removing stale $PID_FILE"
        rm $PID_FILE
    fi
fi

case "$1" in
  start)
        echo "Starting $DESC"
        start-stop-daemon -d $APP_PATH -c $RUN_AS $EXTRA_SSD_OPTS --start --pidfile $PID_FILE --exec $DAEMON -- $DAEMON_OPTS
        ;;
stop)
        echo "Stopping $DESC"
        start-stop-daemon --stop --pidfile $PID_FILE --retry 15
        ;;

  restart|force-reload)
        echo "Restarting $DESC"
        start-stop-daemon --stop --pidfile $PID_FILE --retry 15
        start-stop-daemon -d $APP_PATH -c $RUN_AS $EXTRA_SSD_OPTS --start --pidfile $PID_FILE --exec $DAEMON -- $DAEMON_OPTS
        ;;

  status)
       status_of_proc -p $PID_FILE "$DAEMON" "$NAME"
        ;;
  *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
        exit 1
        ;;
esac

exit 0

i saved and did this:

sudo chmod +x /etc/init.d/couchpotato
sudo update-rc.d couchpotato defaults

but when i now reboot couchpotato doesnt start :(

share|improve this question
    
Have you already tested the script? You could use crontab to get it to start at reboot –  troylatroy Oct 4 '13 at 20:50

protected by Community Mar 13 at 19:37

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Browse other questions tagged or ask your own question.