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