Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/sh
- ### BEGIN INIT INFO
- # Provides: skeleton
- # Required-Start: $remote_fs $syslog
- # Required-Stop: $remote_fs $syslog
- # Default-Start: 2 3 4 5
- # Default-Stop: 0 1 6
- # Short-Description: Example initscript
- # Description: This file should be used to construct scripts to be
- # placed in /etc/init.d.
- ### END INIT INFO
- PATH=/sbin:/bin:/usr/sbin:/usr/bin:/opt/cherokee/sbin:/opt/cherokee/bin
- DAEMON=/opt/cherokee/sbin/cherokee
- NAME=cherokee
- PIDFILE=/opt/cherokee/var/run/cherokee.pid
- set -e
- test -x $DAEMON || exit 0
- case "$1" in
- start)
- /opt/cherokee/sbin/cherokee -d
- ;;
- stop)
- if [ -f $PIDFILE ]; then
- PID=$(cat $PIDFILE)
- kill $PID
- fi
- ;;
- restart)
- $0 stop
- sleep 1
- $0 start
- ;;
- reload|force-reload)
- printf "Reloading web server: %s " "$NAME"
- if [ -f $PIDFILE ]; then
- PID=$(cat $PIDFILE)
- if ps p $PID | grep $NAME >/dev/null 2>&1; then
- kill -HUP $PID
- else
- echo "PID present, but $NAME not found at PID $PID - Cannot reload"
- exit 1
- fi
- else
- echo "No PID file present for $NAME - Cannot reload"
- exit 1
- fi
- ;;
- status)
- printf "%s web server status: " "$NAME"
- if [ -e $PIDFILE ] ; then
- PROCNAME=$(ps -p $(cat $PIDFILE) -o comm=)
- if [ "x$PROCNAME" = "x" ]; then
- printf "Not running, but PID file present "
- else
- if [ "$PROCNAME" = "$NAME" ]; then
- printf "Running "
- else
- printf "PID file points to process '%s', not '%s' " "$PROCNAME" "$NAME"
- fi
- fi
- else
- if PID=$(pidofproc cherokee); then
- printf "Running (PID %s), but PIDFILE not present " "$PID"
- else
- printf "Not running "
- fi
- fi
- ;;
- *)
- N=/etc/init.d/$NAME
- echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2
- exit 1
- ;;
- esac
- if [ $? = 0 ]; then
- echo .
- exit 0
- else
- echo failed
- exit 1
- fi
- exit 0
Add Comment
Please, Sign In to add comment