File indexing completed on 2024-05-12 05:39:33
0001 #! /bin/sh 0002 # 0003 # skeleton example file to build /etc/init.d/ scripts. 0004 # This file should be used to construct scripts for /etc/init.d. 0005 # 0006 # Written by Miquel van Smoorenburg <miquels@cistron.nl>. 0007 # Modified for Debian 0008 # by Ian Murdock <imurdock@gnu.ai.mit.edu>. 0009 # Further changes by Javier Fernandez-Sanguino <jfs@debian.org> 0010 # 0011 # Version: @(#)skeleton 1.9 26-Feb-2001 miquels@cistron.nl 0012 # 0013 0014 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 0015 DAEMON=/usr/sbin/rcse 0016 NAME=rcse 0017 DESC=rcse 0018 0019 test -x $DAEMON || exit 0 0020 0021 LOGDIR=/var/log/rcse 0022 PIDFILE=/var/run/$NAME.pid 0023 DODTIME=1 # Time to wait for the server to die, in seconds 0024 # If this value is set too low you might not 0025 # let some servers to die gracefully and 0026 # 'restart' will not work 0027 0028 # Include rolisteam defaults if available 0029 if [ -f /etc/default/rcse ] ; then 0030 . /etc/default/rcse 0031 fi 0032 0033 set -e 0034 0035 running_pid() 0036 { 0037 # Check if a given process pid's cmdline matches a given name 0038 pid=$1 0039 name=$2 0040 [ -z "$pid" ] && return 1 0041 [ ! -d /proc/$pid ] && return 1 0042 cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1` 0043 # Is this the expected child? 0044 [ "$cmd" != "$name" ] && return 1 0045 return 0 0046 } 0047 0048 running() 0049 { 0050 # Check if the process is running looking at /proc 0051 # (works for all users) 0052 0053 # No pidfile, probably no daemon present 0054 [ ! -f "$PIDFILE" ] && return 1 0055 # Obtain the pid and check it against the binary name 0056 pid=`cat $PIDFILE` 0057 running_pid $pid $DAEMON || return 1 0058 return 0 0059 } 0060 0061 force_stop() { 0062 # Forcefully kill the process 0063 [ ! -f "$PIDFILE" ] && return 0064 if running ; then 0065 kill -15 $pid 0066 # Is it really dead? 0067 [ -n "$DODTIME" ] && sleep "$DODTIME"s 0068 if running ; then 0069 kill -9 $pid 0070 [ -n "$DODTIME" ] && sleep "$DODTIME"s 0071 if running ; then 0072 echo "Cannot kill $LABEL (pid=$pid)!" 0073 exit 1 0074 fi 0075 fi 0076 fi 0077 rm -f $PIDFILE 0078 return 0 0079 } 0080 0081 case "$1" in 0082 start) 0083 echo -n "Starting $DESC: " 0084 start-stop-daemon --start --quiet --pidfile $PIDFILE \ 0085 --exec $DAEMON -- $DAEMON_OPTS 0086 if running ; then 0087 echo "$NAME." 0088 else 0089 echo " ERROR." 0090 fi 0091 ;; 0092 stop) 0093 echo -n "Stopping $DESC: " 0094 start-stop-daemon --stop --quiet --pidfile $PIDFILE \ 0095 --exec $DAEMON 0096 echo "$NAME." 0097 ;; 0098 force-stop) 0099 echo -n "Forcefully stopping $DESC: " 0100 force_stop 0101 if ! running ; then 0102 echo "$NAME." 0103 else 0104 echo " ERROR." 0105 fi 0106 ;; 0107 #reload) 0108 # 0109 # If the daemon can reload its config files on the fly 0110 # for example by sending it SIGHUP, do it here. 0111 # 0112 # If the daemon responds to changes in its config file 0113 # directly anyway, make this a do-nothing entry. 0114 # 0115 # echo "Reloading $DESC configuration files." 0116 # start-stop-daemon --stop --signal 1 --quiet --pidfile \ 0117 # /var/run/$NAME.pid --exec $DAEMON 0118 #;; 0119 force-reload) 0120 # 0121 # If the "reload" option is implemented, move the "force-reload" 0122 # option to the "reload" entry above. If not, "force-reload" is 0123 # just the same as "restart" except that it does nothing if the 0124 # daemon isn't already running. 0125 # check wether $DAEMON is running. If so, restart 0126 start-stop-daemon --stop --test --quiet --pidfile \ 0127 /var/run/$NAME.pid --exec $DAEMON \ 0128 && $0 restart \ 0129 || exit 0 0130 ;; 0131 restart) 0132 echo -n "Restarting $DESC: " 0133 start-stop-daemon --stop --quiet --pidfile \ 0134 /var/run/$NAME.pid --exec $DAEMON 0135 [ -n "$DODTIME" ] && sleep $DODTIME 0136 start-stop-daemon --start --quiet --pidfile \ 0137 /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS 0138 echo "$NAME." 0139 ;; 0140 status) 0141 echo -n "$LABEL is " 0142 if running ; then 0143 echo "running" 0144 else 0145 echo " not running." 0146 exit 1 0147 fi 0148 ;; 0149 *) 0150 N=/etc/init.d/$NAME 0151 # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 0152 echo "Usage: $N {start|stop|restart|force-reload|status|force-stop}" >&2 0153 exit 1 0154 ;; 0155 esac 0156 0157 exit 0