PKGBUILDs/aur/couchpotato-git/couchpotato.init

44 lines
1,020 B
Plaintext
Raw Normal View History

2011-02-28 03:00:10 +00:00
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
2012-10-13 22:26:49 +00:00
. /etc/conf.d/couchpotato
PID=`ps -A -F | grep "python2 /opt/couchpotato/CouchPotato.py" | grep -v grep | awk '{print $2}'`
2011-02-28 03:00:10 +00:00
case "$1" in
start)
stat_busy "Starting CouchPotato"
2012-10-13 22:26:49 +00:00
if [ -z "$CP_USER" ]; then
stat_busy "No CP_USER, please edit /etc/conf.d/couchpotato"
stat_fail
2011-02-28 03:00:10 +00:00
else
2012-10-13 22:26:49 +00:00
[ -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
2011-02-28 03:00:10 +00:00
fi
;;
stop)
stat_busy "Stopping CouchPotato"
2012-10-13 22:26:49 +00:00
[ ! -z "$PID" ] && kill $PID &> /dev/null
if [ $? -ne 0 ]; then
stat_fail
2011-02-28 03:00:10 +00:00
else
2012-10-13 22:26:49 +00:00
rm_daemon couchpotato
stat_done
2011-02-28 03:00:10 +00:00
fi
;;
restart)
$0 stop
2012-10-13 22:26:49 +00:00
while [ ! -z "$PID" -a -d "/proc/$PID" ]; do sleep 1; done
2011-02-28 03:00:10 +00:00
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
exit 0