Advertisement
MrSlayers

Cherokee init.d for Fedora

Jun 24th, 2011
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.12 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # cherokee       Startup script for the Cherokee web server.
  4. #
  5. # chkconfig:     - 95 05
  6. # description:   Cherokee is lightweight web server.
  7. #
  8.  
  9. ### BEGIN INIT INFO
  10. # Provides:
  11. # Required-Start:
  12. # Required-Stop:
  13. # Should-Start:
  14. # Should-Stop:
  15. # Default-Start: 3 4 5
  16. # Default-Stop:
  17. # Short-Description:
  18. # Description:
  19. ### END INIT INFO
  20.  
  21. # Source function library.
  22. . /etc/rc.d/init.d/functions
  23.  
  24. exec="/usr/sbin/cherokee"
  25. prog="cherokee"
  26. config="/etc/cherokee/cherokee.conf"
  27. pidfile="/var/run/cherokee.pid"
  28.  
  29. # [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
  30.  
  31. # No network? No cherokee.
  32. . /etc/sysconfig/network
  33. [ ${NETWORKING} = "no" ] && exit 0
  34.  
  35. lockfile=/var/lock/subsys/$prog
  36.  
  37. start() {
  38.     [ -x $exec ] || exit 5
  39.     [ -f $config ] || exit 6
  40.     echo -n $"Starting $prog: "
  41.     daemon --pidfile $pidfile $exec -d -C $config >&/dev/null && success || failure
  42.     retval=$?
  43.     echo
  44.     [ $retval -eq 0 ] && touch $lockfile
  45.     return $retval
  46. }
  47.  
  48. stop() {
  49.     echo -n $"Stopping $prog: "
  50.     killproc -p $pidfile $prog 2>/dev/null && success || failure
  51.     retval=$?
  52.     echo
  53.     [ $retval -eq 0 ] && rm -f $lockfile
  54.     return $retval
  55. }
  56.  
  57. restart() {
  58.     stop
  59.     start
  60. }
  61.  
  62. reload() {
  63.     echo -n $"Reloading $prog: "
  64.     killproc -p $pidfile $prog -HUP
  65.     retval=$?
  66.     echo
  67.     return $retval
  68. }
  69.  
  70. force_reload() {
  71.     restart
  72. }
  73.  
  74. rh_status() {
  75.     # run checks to determine if the service is running or use generic status
  76.     status $prog
  77. }
  78.  
  79. rh_status_q() {
  80.     rh_status >/dev/null 2>&1
  81. }
  82.  
  83.  
  84. case "$1" in
  85.     start)
  86.         rh_status_q && exit 0
  87.         $1
  88.         ;;
  89.     stop)
  90.         rh_status_q || exit 0
  91.         $1
  92.         ;;
  93.     restart)
  94.         $1
  95.         ;;
  96.     reload)
  97.         rh_status_q || exit 7
  98.         $1
  99.         ;;
  100.     force-reload)
  101.         force_reload
  102.         ;;
  103.     status)
  104.         rh_status
  105.         ;;
  106.     condrestart|try-restart)
  107.         rh_status_q || exit 0
  108.         restart
  109.         ;;
  110.     *)
  111.         echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
  112.         exit 2
  113. esac
  114. exit $?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement