#!/bin/sh set -e DAEMON=/usr/bin/gms.py PIDDIR=/var/run/gms PIDFILE=$PIDDIR.pid LOGFILE=/var/log/gms.log DAEMONUSER=root NAME=gms DESC="GMyth transcode server" test -x $DAEMON || exit 0 . /lib/lsb/init-functions . /etc/default/rcS # Source defaults file; edit that file to configure this script. ENABLED=1 PARAMS="-d" start_it_up() { if [ ! -d $PIDDIR ]; then mkdir -p $PIDDIR chown $DAEMONUSER $PIDDIR chgrp $DAEMONUSER $PIDDIR fi if [ -e $PIDFILE ]; then PIDDIR=/proc/$(cat $PIDFILE) if [ -d ${PIDDIR} -a "$(readlink -f ${PIDDIR}/exe)" = "${DAEMON}" ]; then log_success_msg "$DESC already started; not starting." return else log_success_msg "Removing stale PID file $PIDFILE." rm -f $PIDFILE fi fi log_daemon_msg "Starting $DESC" "$NAME" start-stop-daemon --start --quiet --pidfile $PIDFILE \ --user $DAEMONUSER --exec $DAEMON -- $PARAMS log_end_msg $? } shut_it_down() { log_daemon_msg "Stopping $DESC" "$NAME" start-stop-daemon --stop --retry 60 --quiet --oknodo --pidfile $PIDFILE \ --user $DAEMONUSER log_end_msg $? rm -f $PIDFILE } case $1 in start) start_it_up ;; stop) shut_it_down ;; restart) shut_it_down start_it_up ;; *) echo "Usage: /etc/init.d/$NAME {start|stop|restart}" >&2 exit 2 ;; esac