Guest User

Untitled

a guest
Apr 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.09 KB | None | 0 0
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          skeleton
  4. # Required-Start:    $remote_fs $syslog
  5. # Required-Stop:     $remote_fs $syslog
  6. # Default-Start:     2 3 4 5
  7. # Default-Stop:      0 1 6
  8. # Short-Description: Example initscript
  9. # Description:       This file should be used to construct scripts to be
  10. #                    placed in /etc/init.d.
  11. ### END INIT INFO
  12.  
  13. PATH=/sbin:/bin:/usr/sbin:/usr/bin:/opt/cherokee/sbin:/opt/cherokee/bin
  14.  
  15. DAEMON=/opt/cherokee/sbin/cherokee
  16. NAME=cherokee
  17. PIDFILE=/opt/cherokee/var/run/cherokee.pid
  18.  
  19. set -e
  20. test -x $DAEMON || exit 0
  21.  
  22. case "$1" in
  23. start)
  24.    /opt/cherokee/sbin/cherokee -d
  25.    ;;
  26.  
  27. stop)
  28.    if [ -f $PIDFILE ]; then
  29.         PID=$(cat $PIDFILE)
  30.         kill $PID
  31.    fi
  32.    ;;
  33.  
  34. restart)
  35.    $0 stop
  36.    sleep 1
  37.    $0 start
  38.    ;;
  39.  
  40. reload|force-reload)
  41.    printf "Reloading web server: %s " "$NAME"
  42.    if [ -f $PIDFILE ]; then
  43.         PID=$(cat $PIDFILE)
  44.         if ps p $PID | grep $NAME >/dev/null 2>&1; then
  45.            kill -HUP $PID
  46.         else
  47.            echo "PID present, but $NAME not found at PID $PID - Cannot reload"
  48.            exit 1
  49.         fi
  50.    else
  51.         echo "No PID file present for $NAME - Cannot reload"
  52.         exit 1
  53.    fi
  54.    ;;
  55.  
  56. status)
  57.    printf "%s web server status:    " "$NAME"
  58.    if [ -e $PIDFILE ] ; then
  59.        PROCNAME=$(ps -p $(cat $PIDFILE) -o comm=)
  60.        if [ "x$PROCNAME" = "x" ]; then
  61.             printf "Not running, but PID file present   "
  62.        else
  63.             if [ "$PROCNAME" = "$NAME" ]; then
  64.                  printf "Running    "
  65.             else
  66.                  printf "PID file points to process '%s', not '%s'  " "$PROCNAME" "$NAME"
  67.             fi
  68.        fi
  69.    else
  70.        if PID=$(pidofproc cherokee); then
  71.             printf "Running (PID %s), but PIDFILE not present   " "$PID"
  72.        else
  73.             printf "Not running "
  74.        fi
  75.    fi
  76.    ;;
  77.  
  78. *)
  79.    N=/etc/init.d/$NAME
  80.    echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2
  81.    exit 1
  82.    ;;
  83. esac
  84.  
  85. if [ $? = 0 ]; then
  86.     echo .
  87.     exit 0
  88. else
  89.     echo failed
  90.     exit 1
  91. fi
  92. exit 0
Add Comment
Please, Sign In to add comment