PKGBUILDs/aur/couchpotato-git/couchpotato.init
2012-10-13 22:26:49 +00:00

43 lines
1,020 B
Bash

#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
. /etc/conf.d/couchpotato
PID=`ps -A -F | grep "python2 /opt/couchpotato/CouchPotato.py" | grep -v grep | awk '{print $2}'`
case "$1" in
start)
stat_busy "Starting CouchPotato"
if [ -z "$CP_USER" ]; then
stat_busy "No CP_USER, please edit /etc/conf.d/couchpotato"
stat_fail
else
[ -z "$PID" ] && su -l -s /bin/sh -c "python2 /opt/couchpotato/CouchPotato.py ${CP_OPTS} --config_file ${CP_CONFIG} --data_dir ${CP_DATA} &> /dev/null &" "$CP_USER"
if [ $? -gt 0 ]; then
stat_fail
else
add_daemon couchpotato
stat_done
fi
fi
;;
stop)
stat_busy "Stopping CouchPotato"
[ ! -z "$PID" ] && kill $PID &> /dev/null
if [ $? -ne 0 ]; then
stat_fail
else
rm_daemon couchpotato
stat_done
fi
;;
restart)
$0 stop
while [ ! -z "$PID" -a -d "/proc/$PID" ]; do sleep 1; done
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
exit 0