renatofilho@816
|
1 |
#!/bin/sh
|
renatofilho@816
|
2 |
|
renatofilho@816
|
3 |
|
renatofilho@816
|
4 |
set -e
|
renatofilho@816
|
5 |
|
renatofilho@914
|
6 |
DAEMON=/usr/bin/gms.py
|
renatofilho@914
|
7 |
PIDDIR=/var/run/gms
|
renatofilho@914
|
8 |
PIDFILE=$PIDDIR.pid
|
renatofilho@914
|
9 |
LOGFILE=/var/log/gms.log
|
renatofilho@914
|
10 |
DAEMONUSER=root
|
renatofilho@914
|
11 |
NAME=gms
|
renatofilho@914
|
12 |
DESC="GMyth transcode server"
|
renatofilho@914
|
13 |
|
renatofilho@914
|
14 |
test -x $DAEMON || exit 0
|
renatofilho@816
|
15 |
. /lib/lsb/init-functions
|
renatofilho@816
|
16 |
. /etc/default/rcS
|
renatofilho@816
|
17 |
|
renatofilho@914
|
18 |
# Source defaults file; edit that file to configure this script.
|
renatofilho@914
|
19 |
ENABLED=1
|
renatofilho@914
|
20 |
PARAMS="-d"
|
renatofilho@914
|
21 |
|
renatofilho@914
|
22 |
start_it_up()
|
renatofilho@914
|
23 |
{
|
renatofilho@914
|
24 |
if [ ! -d $PIDDIR ]; then
|
renatofilho@914
|
25 |
mkdir -p $PIDDIR
|
renatofilho@914
|
26 |
chown $DAEMONUSER $PIDDIR
|
renatofilho@914
|
27 |
chgrp $DAEMONUSER $PIDDIR
|
renatofilho@914
|
28 |
fi
|
renatofilho@914
|
29 |
if [ -e $PIDFILE ]; then
|
renatofilho@914
|
30 |
PIDDIR=/proc/$(cat $PIDFILE)
|
renatofilho@914
|
31 |
if [ -d ${PIDDIR} -a "$(readlink -f ${PIDDIR}/exe)" = "${DAEMON}" ]; then
|
renatofilho@914
|
32 |
log_success_msg "$DESC already started; not starting."
|
renatofilho@914
|
33 |
return
|
renatofilho@914
|
34 |
else
|
renatofilho@914
|
35 |
log_success_msg "Removing stale PID file $PIDFILE."
|
renatofilho@914
|
36 |
rm -f $PIDFILE
|
renatofilho@914
|
37 |
fi
|
renatofilho@914
|
38 |
fi
|
renatofilho@914
|
39 |
|
renatofilho@914
|
40 |
log_daemon_msg "Starting $DESC" "$NAME"
|
renatofilho@914
|
41 |
start-stop-daemon --start --quiet --pidfile $PIDFILE \
|
renatofilho@914
|
42 |
--user $DAEMONUSER --exec $DAEMON -- $PARAMS
|
renatofilho@914
|
43 |
log_end_msg $?
|
renatofilho@914
|
44 |
}
|
renatofilho@914
|
45 |
|
renatofilho@914
|
46 |
shut_it_down()
|
renatofilho@914
|
47 |
{
|
renatofilho@914
|
48 |
log_daemon_msg "Stopping $DESC" "$NAME"
|
renatofilho@914
|
49 |
start-stop-daemon --stop --retry 60 --quiet --oknodo --pidfile $PIDFILE \
|
renatofilho@914
|
50 |
--user $DAEMONUSER
|
renatofilho@914
|
51 |
log_end_msg $?
|
renatofilho@914
|
52 |
rm -f $PIDFILE
|
renatofilho@914
|
53 |
}
|
renatofilho@914
|
54 |
|
renatofilho@816
|
55 |
case $1 in
|
renatofilho@816
|
56 |
start)
|
renatofilho@914
|
57 |
start_it_up
|
renatofilho@816
|
58 |
;;
|
renatofilho@816
|
59 |
|
renatofilho@816
|
60 |
stop)
|
renatofilho@914
|
61 |
shut_it_down
|
renatofilho@816
|
62 |
;;
|
renatofilho@816
|
63 |
|
renatofilho@816
|
64 |
restart)
|
renatofilho@914
|
65 |
shut_it_down
|
renatofilho@914
|
66 |
start_it_up
|
renatofilho@816
|
67 |
;;
|
renatofilho@816
|
68 |
|
renatofilho@816
|
69 |
*)
|
renatofilho@914
|
70 |
echo "Usage: /etc/init.d/$NAME {start|stop|restart}" >&2
|
renatofilho@914
|
71 |
exit 2
|
renatofilho@816
|
72 |
;;
|
renatofilho@816
|
73 |
esac
|