~ salmonella-environment-setup (master) /awful/init-scripts/debian
Trap1#!/bin/sh2# Start/stop/restart/reload the awful web framework.3#4### BEGIN INIT INFO5# Provides: awful6# Required-Start: $remote_fs $syslog $time7# Required-Stop: $remote_fs $syslog $time8# Should-Start:9# Should-Stop:10# Default-Start: 2 3 4 511# Default-Stop:12# Short-Description: Awful web framework13# Description: A CHICKEN web framework on top of the Spiffy web server14### END INIT INFO1516PIDFILE=/var/run/awful.pid17NAME=awful18AWFUL=/home/chicken/local/chicken/bin/$NAME19AWFUL_ARGS=''2021# In some systems the pidfile might be (incorrectly) set to /etc22# if this pidfile is present, use it instead.23[ -e /etc/$NAME.pid ] && PIDFILE=/etc/$NAME.pid24[ -r /etc/default/$NAME ] && . /etc/default/$NAME2526. /lib/lsb/init-functions2728[ -e "/etc/$NAME/$NAME.conf" ] && AWFUL_ARGS="/etc/$NAME/$NAME.conf $AWFUL_ARGS"29[ -e "/etc/$NAME/privileged.conf" ] && AWFUL_ARGS="--privileged-code=/etc/$NAME/privileged.conf $AWFUL_ARGS"3031# Read configuration variable file if it is present32[ -r /etc/default/$NAME ] && . /etc/default/$NAME3334# Load the VERBOSE setting and other rcS variables35. /lib/init/vars.sh363738is_running() {39 if [ -f "$PIDFILE" ]; then40 if pidofproc -p "$PIDFILE" >/dev/null; then41 return 042 else43 return 144 fi45 else46 return 147 fi48}4950do_start() {51 # Return52 # 0 if daemon has been started53 # 1 if daemon was already running54 # 2 if daemon could not be started55 echo "Starting $NAME"56 if is_running; then57 echo "$NAME is already running."58 else59 rm -f $PIDFILE60 $AWFUL $AWFUL_ARGS 2>&1 > /var/log/awful/init.log &61 local pid=$!62 local exit_code=$?63 if [ "$exit_code" = "0" ]; then64 echo $pid > $PIDFILE65 return 066 else67 return 268 fi69 fi70}717273do_stop() {74 echo "Stopping $NAME"75 if [ ! -f "$PIDFILE" ]; then76 echo "Could not determine $NAME pid (no $PIDFILE)."77 return 178 fi79 local pid=`cat $PIDFILE`80 local cmdline=`cat /proc/$pid/cmdline`81 local cmd=`echo $AWFUL$AWFUL_ARGS | sed "s/ //g"`82 local killed=8384 if [ "$cmd" = "$cmdline" ]; then85 kill $pid86 for i in `seq 1 5`; do87 if pidofproc -p "$PIDFILE" >/dev/null; then88 echo -n .89 sleep 190 kill $pid91 else92 killed=193 break94 fi95 done9697 if [ $killed = "1" ]; then98 rm -f $PIDFILE99 return 0100 else101 return 1102 fi103 else104 echo "Error stopping $NAME."105 return 1106 fi107}108109110do_restart() {111 echo "Restarting $NAME"112 do_stop113 do_start114 return $?115}116117118do_reload() {119 # Considering awful defines a /reload page120 echo "Reloading $NAME"121 wget -O /dev/null http://localhost/reload &> /dev/null122}123124125do_status() {126 if is_running; then127 echo "running"128 exit 0129 else130 if [ -e "$PIDFILE" ]; then131 echo "failed to start"132 exit 1133 else134 echo "not running"135 exit 3136 fi137 fi138}139140case "$1" in141 start)142 do_start143 ;;144145 stop)146 do_stop147 ;;148149 restart)150 do_restart151 ;;152153 reload|force-reload)154 do_reload155 ;;156157 status)158 do_status159 ;;160 *)161 echo "Usage: /etc/init.d/$NAME {start|stop|status|restart|reload|force-reload}"162 exit 2163 ;;164esac165exit 0