2 # Copyright (c) 1995-2002 SuSE Linux AG, Nuernberg, Germany.
5 # Author: Kurt Garloff <feedback@suse.de>
9 # and symbolic its link
13 # LSB compliant service control script; see http://www.linuxbase.org/spec/
15 # System startup script for some example service or daemon FOO (template)
19 # Required-Start: $remote_fs $syslog
20 # Required-Stop: $remote_fs $syslog
22 # Default-Stop: 0 1 2 6
23 # Description: Start FOO to allow XY and provide YZ
24 # continued on second line by '#<TAB>'
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.
31 # Source SuSE config (if still necessary, most info has been moved)
32 test -r /etc
/rc.config
&& .
/etc
/rc.config
34 # Check for missing binaries (stale symlinks should not happen)
35 LIGHTTPD_BIN
=/usr
/sbin
/lighttpd
36 test -x $LIGHTTPD_BIN ||
exit 5
38 # Check for existence of needed config file and read it
39 LIGHTTPD_CONFIG
=/etc
/sysconfig
/lighttpd
40 test -r $LIGHTTPD_CONFIG ||
exit 6
43 # Shell functions sourced from /etc/rc.status:
44 # rc_check check and set local and overall rc status
45 # rc_status check and set local and overall rc status
46 # rc_status -v ditto but be verbose in local rc status
47 # rc_status -v -r ditto and clear the local rc status
48 # rc_failed set local and overall rc status to failed
49 # rc_failed <num> set local and overall rc status to <num><num>
50 # rc_reset clear local rc status (overall remains)
51 # rc_exit exit appropriate to overall rc status
52 # rc_active checks whether a service is activated by symlinks
55 # First reset status of this service
58 # Return values acc. to LSB for all commands but status:
60 # 1 - generic or unspecified error
61 # 2 - invalid or excess argument(s)
62 # 3 - unimplemented feature (e.g. "reload")
63 # 4 - insufficient privilege
64 # 5 - program is not installed
65 # 6 - program is not configured
66 # 7 - program is not running
68 # Note that starting an already running service, stopping
69 # or restarting a not-running service as well as the restart
70 # with force-reload (in case signalling is not supported) are
71 # considered a success.
75 echo -n "Starting lighttpd"
76 ## Start daemon with startproc(8). If this fails
77 ## the echo return value is set appropriate.
79 # NOTE: startproc returns 0, even if service is
80 # already running to match LSB spec.
81 startproc
$LIGHTTPD_BIN -f $LIGHTTPD_CONF_PATH
83 # Remember status and be verbose
87 echo -n "Shutting down lighttpd"
88 ## Stop daemon with killproc(8) and if this fails
89 ## set echo the echo return value.
91 killproc
-TERM $LIGHTTPD_BIN
93 # Remember status and be verbose
97 ## Stop the service and if this succeeds (i.e. the
98 ## service was running before), start it again.
99 ## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
100 $0 status
>/dev
/null
&& $0 restart
102 # Remember status and be quiet
106 ## Stop the service and regardless of whether it was
107 ## running or not, start it again.
111 # Remember status and be quiet
115 ## Like force-reload, but if daemon does not support
116 ## signalling, do nothing (!)
118 # If it supports signalling:
119 echo -n "Reload service LIGHTTPD"
120 killproc
-INT $LIGHTTPD_BIN
122 touch /var
/run
/lighttpd.pid
125 ## Otherwise if it does not support reload:
130 echo -n "Checking for service LIGHTTPD: "
131 ## Check status with checkproc(8), if process is running
132 ## checkproc will return with exit status 0.
134 # Return value is slightly different for the status command:
135 # 0 - service running
136 # 1 - service dead, but /var/run/ pid file exists
137 # 2 - service dead, but /var/lock/ lock file exists
138 # 3 - service not running
140 # NOTE: checkproc returns LSB compliant status values.
141 checkproc
$LIGHTTPD_BIN
145 ## Optional: Probe for the necessity of a reload,
146 ## print out the argument which is required for a reload.
148 test /etc
/lighttpd
/lighttpd.conf
-nt /var
/run
/lighttpd.pid
&& echo reload
151 echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"