rc.lighttpd 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #! /bin/sh
  2. # Copyright (c) 1995-2002 SuSE Linux AG, Nuernberg, Germany.
  3. # All rights reserved.
  4. #
  5. # Author: Kurt Garloff <feedback@suse.de>
  6. #
  7. # /etc/init.d/FOO
  8. #
  9. # and symbolic its link
  10. #
  11. # /(usr/)sbin/rcFOO
  12. #
  13. # LSB compliant service control script; see http://www.linuxbase.org/spec/
  14. #
  15. # System startup script for some example service or daemon FOO (template)
  16. #
  17. ### BEGIN INIT INFO
  18. # Provides: FOO
  19. # Required-Start: $remote_fs $syslog
  20. # Required-Stop: $remote_fs $syslog
  21. # Default-Start: 3 5
  22. # Default-Stop: 0 1 2 6
  23. # Description: Start FOO to allow XY and provide YZ
  24. # continued on second line by '#<TAB>'
  25. ### END INIT INFO
  26. #
  27. # Note on Required-Start: It does specify the init script ordering,
  28. # not real dependencies. Depencies have to be handled by admin
  29. # resp. the configuration tools (s)he uses.
  30. # Source SuSE config (if still necessary, most info has been moved)
  31. test -r /etc/rc.config && . /etc/rc.config
  32. # Check for missing binaries (stale symlinks should not happen)
  33. LIGHTTPD_BIN=/usr/sbin/lighttpd
  34. test -x $LIGHTTPD_BIN || exit 5
  35. # Check for existence of needed config file and read it
  36. LIGHTTPD_CONFIG=/etc/sysconfig/lighttpd
  37. test -r $LIGHTTPD_CONFIG || exit 6
  38. . $LIGHTTPD_CONFIG
  39. # Shell functions sourced from /etc/rc.status:
  40. # rc_check check and set local and overall rc status
  41. # rc_status check and set local and overall rc status
  42. # rc_status -v ditto but be verbose in local rc status
  43. # rc_status -v -r ditto and clear the local rc status
  44. # rc_failed set local and overall rc status to failed
  45. # rc_failed <num> set local and overall rc status to <num><num>
  46. # rc_reset clear local rc status (overall remains)
  47. # rc_exit exit appropriate to overall rc status
  48. # rc_active checks whether a service is activated by symlinks
  49. . /etc/rc.status
  50. # First reset status of this service
  51. rc_reset
  52. # Return values acc. to LSB for all commands but status:
  53. # 0 - success
  54. # 1 - generic or unspecified error
  55. # 2 - invalid or excess argument(s)
  56. # 3 - unimplemented feature (e.g. "reload")
  57. # 4 - insufficient privilege
  58. # 5 - program is not installed
  59. # 6 - program is not configured
  60. # 7 - program is not running
  61. #
  62. # Note that starting an already running service, stopping
  63. # or restarting a not-running service as well as the restart
  64. # with force-reload (in case signalling is not supported) are
  65. # considered a success.
  66. case "$1" in
  67. start)
  68. echo -n "Starting lighttpd"
  69. ## Start daemon with startproc(8). If this fails
  70. ## the echo return value is set appropriate.
  71. # NOTE: startproc returns 0, even if service is
  72. # already running to match LSB spec.
  73. startproc $LIGHTTPD_BIN -f $LIGHTTPD_CONF_PATH
  74. # Remember status and be verbose
  75. rc_status -v
  76. ;;
  77. stop)
  78. echo -n "Shutting down lighttpd"
  79. ## Stop daemon with killproc(8) and if this fails
  80. ## set echo the echo return value.
  81. killproc -TERM $LIGHTTPD_BIN
  82. # Remember status and be verbose
  83. rc_status -v
  84. ;;
  85. try-restart)
  86. ## Stop the service and if this succeeds (i.e. the
  87. ## service was running before), start it again.
  88. ## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
  89. $0 status >/dev/null && $0 restart
  90. # Remember status and be quiet
  91. rc_status
  92. ;;
  93. restart)
  94. ## Stop the service and regardless of whether it was
  95. ## running or not, start it again.
  96. $0 stop
  97. $0 start
  98. # Remember status and be quiet
  99. rc_status
  100. ;;
  101. force-reload|reload)
  102. ## Like force-reload, but if daemon does not support
  103. ## signalling, do nothing (!)
  104. # If it supports signalling:
  105. echo -n "Reload service LIGHTTPD"
  106. killproc -INT $LIGHTTPD_BIN
  107. $0 start
  108. touch /var/run/lighttpd.pid
  109. rc_status -v
  110. ## Otherwise if it does not support reload:
  111. #rc_failed 3
  112. #rc_status -v
  113. ;;
  114. status)
  115. echo -n "Checking for service LIGHTTPD: "
  116. ## Check status with checkproc(8), if process is running
  117. ## checkproc will return with exit status 0.
  118. # Return value is slightly different for the status command:
  119. # 0 - service running
  120. # 1 - service dead, but /var/run/ pid file exists
  121. # 2 - service dead, but /var/lock/ lock file exists
  122. # 3 - service not running
  123. # NOTE: checkproc returns LSB compliant status values.
  124. checkproc $LIGHTTPD_BIN
  125. rc_status -v
  126. ;;
  127. probe)
  128. ## Optional: Probe for the necessity of a reload,
  129. ## print out the argument which is required for a reload.
  130. test /etc/lighttpd/lighttpd.conf -nt /var/run/lighttpd.pid && echo reload
  131. ;;
  132. *)
  133. echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
  134. exit 1
  135. ;;
  136. esac
  137. rc_exit