Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
591
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.41 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # httpd        Startup script for the Apache HTTP Server
  4. #
  5. # chkconfig: - 85 15
  6. # description: The Apache HTTP Server is an efficient and extensible  \
  7. #          server implementing the current HTTP standards.
  8. # processname: httpd
  9. # config: /etc/httpd/conf/httpd.conf
  10. # config: /etc/sysconfig/httpd
  11. # pidfile: /var/run/httpd/httpd.pid
  12. #
  13. ### BEGIN INIT INFO
  14. # Provides: httpd
  15. # Required-Start: $local_fs $remote_fs $network $named
  16. # Required-Stop: $local_fs $remote_fs $network
  17. # Should-Start: distcache
  18. # Short-Description: start and stop Apache HTTP Server
  19. # Description: The Apache HTTP Server is an extensible server
  20. #  implementing the current HTTP standards.
  21. ### END INIT INFO
  22.  
  23. # Source function library.
  24. . /etc/rc.d/init.d/functions
  25.  
  26. if [ -f /etc/sysconfig/httpd ]; then
  27.         . /etc/sysconfig/httpd
  28. fi
  29.  
  30. # Start httpd in the C locale by default.
  31. HTTPD_LANG=${HTTPD_LANG-"C"}
  32.  
  33. # This will prevent initlog from swallowing up a pass-phrase prompt if
  34. # mod_ssl needs a pass-phrase from the user.
  35. INITLOG_ARGS=""
  36.  
  37. # Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
  38. # with the thread-based "worker" MPM; BE WARNED that some modules may not
  39. # work correctly with a thread-based MPM; notably PHP will refuse to start.
  40.  
  41. # Path to the apachectl script, server binary, and short-form for messages.
  42. apachectl=/usr/sbin/apachectl
  43. httpd=${HTTPD-/usr/sbin/httpd}
  44. prog=httpd
  45. pidfile=${PIDFILE-/var/run/httpd/httpd.pid}
  46. lockfile=${LOCKFILE-/var/lock/subsys/httpd}
  47. RETVAL=0
  48. STOP_TIMEOUT=${STOP_TIMEOUT-10}
  49.  
  50. # The semantics of these two functions differ from the way apachectl does
  51. # things -- attempting to start while running is a failure, and shutdown
  52. # when not running is also a failure.  So we just do it the way init scripts
  53. # are expected to behave here.
  54. start() {
  55.         echo -n $"Starting $prog: "
  56.         LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
  57.         RETVAL=$?
  58.         echo
  59.         [ $RETVAL = 0 ] && touch ${lockfile}
  60.         return $RETVAL
  61. }
  62.  
  63. # When stopping httpd, a delay (of default 10 second) is required
  64. # before SIGKILLing the httpd parent; this gives enough time for the
  65. # httpd parent to SIGKILL any errant children.
  66. stop() {
  67.     echo -n $"Stopping $prog: "
  68.     killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd
  69.     RETVAL=$?
  70.     echo
  71.     [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
  72. }
  73. reload() {
  74.     echo -n $"Reloading $prog: "
  75.     if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
  76.         RETVAL=6
  77.         echo $"not reloading due to configuration syntax error"
  78.         failure $"not reloading $httpd due to configuration syntax error"
  79.     else
  80.         # Force LSB behaviour from killproc
  81.         LSB=1 killproc -p ${pidfile} $httpd -HUP
  82.         RETVAL=$?
  83.         if [ $RETVAL -eq 7 ]; then
  84.             failure $"httpd shutdown"
  85.         fi
  86.     fi
  87.     echo
  88. }
  89.  
  90. # See how we were called.
  91. case "$1" in
  92.   start)
  93.     start
  94.     ;;
  95.   stop)
  96.     stop
  97.     ;;
  98.   status)
  99.         status -p ${pidfile} $httpd
  100.     RETVAL=$?
  101.     ;;
  102.   restart)
  103.     stop
  104.     start
  105.     ;;
  106.   condrestart|try-restart)
  107.     if status -p ${pidfile} $httpd >&/dev/null; then
  108.         stop
  109.         start
  110.     fi
  111.     ;;
  112.   force-reload|reload)
  113.         reload
  114.     ;;
  115.   graceful|help|configtest|fullstatus)
  116.     $apachectl $@
  117.     RETVAL=$?
  118.     ;;
  119.   *)
  120.     echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}"
  121.     RETVAL=2
  122. esac
  123.  
  124. exit $RETVAL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement