summaryrefslogtreecommitdiffstats
path: root/urunlevel/runlevel/skeleton
diff options
context:
space:
mode:
Diffstat (limited to 'urunlevel/runlevel/skeleton')
-rwxr-xr-xurunlevel/runlevel/skeleton282
1 files changed, 282 insertions, 0 deletions
diff --git a/urunlevel/runlevel/skeleton b/urunlevel/runlevel/skeleton
new file mode 100755
index 0000000..cbd8b0e
--- /dev/null
+++ b/urunlevel/runlevel/skeleton
@@ -0,0 +1,282 @@
1#! /bin/sh
2# Copyright (c) 1995-2004 SUSE Linux AG, Nuernberg, Germany.
3# All rights reserved.
4#
5# Author: Kurt Garloff
6# Please send feedback to http://www.suse.de/feedback/
7#
8# /etc/init.d/FOO
9# and its symbolic link
10# /(usr/)sbin/rcFOO
11#
12# This program is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2 of the License, or
15# (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, write to the Free Software
24# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25#
26# Template system startup script for some example service/daemon FOO
27#
28# LSB compatible service control script; see http://www.linuxbase.org/spec/
29#
30# Note: This template uses functions rc_XXX defined in /etc/rc.status on
31# UnitedLinux (UL) based Linux distributions. If you want to base your
32# script on this template and ensure that it works on non UL based LSB
33# compliant Linux distributions, you either have to provide the rc.status
34# functions from UL or change the script to work without them.
35#
36### BEGIN INIT INFO
37# Provides: FOO
38# Required-Start: $syslog $remote_fs
39# Should-Start: $time ypbind sendmail
40# Required-Stop: $syslog $remote_fs
41# Should-Stop: $time ypbind sendmail
42# Default-Start: 3 5
43# Default-Stop: 0 1 2 6
44# Short-Description: FOO XYZ daemon providing ZYX
45# Description: Start FOO to allow XY and provide YZ
46# continued on second line by '#<TAB>'
47# should contain enough info for the runlevel editor
48# to give admin some idea what this service does and
49# what it's needed for ...
50# (The Short-Description should already be a good hint.)
51### END INIT INFO
52#
53# Any extensions to the keywords given above should be preceeded by
54# X-VendorTag- (X-UnitedLinux- X-SuSE- for us) according to LSB.
55#
56# Notes on Required-Start/Should-Start:
57# * There are two different issues that are solved by Required-Start
58# and Should-Start
59# (a) Hard dependencies: This is used by the runlevel editor to determine
60# which services absolutely need to be started to make the start of
61# this service make sense. Example: nfsserver should have
62# Required-Start: $portmap
63# Also, required services are started before the dependent ones.
64# The runlevel editor will warn about such missing hard dependencies
65# and suggest enabling. During system startup, you may expect an error,
66# if the dependency is not fulfilled.
67# (b) Specifying the init script ordering, not real (hard) dependencies.
68# This is needed by insserv to determine which service should be
69# started first (and at a later stage what services can be started
70# in parallel). The tag Should-Start: is used for this.
71# It tells, that if a service is available, it should be started
72# before. If not, never mind.
73# * When specifying hard dependencies or ordering requirements, you can
74# use names of services (contents of their Provides: section)
75# or pseudo names starting with a $. The following ones are available
76# according to LSB (1.1):
77# $local_fs all local file systems are mounted
78# (most services should need this!)
79# $remote_fs all remote file systems are mounted
80# (note that /usr may be remote, so
81# many services should Require this!)
82# $syslog system logging facility up
83# $network low level networking (eth card, ...)
84# $named hostname resolution available
85# $netdaemons all network daemons are running
86# The $netdaemons pseudo service has been removed in LSB 1.2.
87# For now, we still offer it for backward compatibility.
88# These are new (LSB 1.2):
89# $time the system time has been set correctly
90# $portmap SunRPC portmapping service available
91# UnitedLinux extensions:
92# $ALL indicates that a script should be inserted
93# at the end
94# * The services specified in the stop tags
95# (Required-Stop/Should-Stop)
96# specify which services need to be still running when this service
97# is shut down. Often the entries there are just copies or a subset
98# from the respective start tag.
99# * Should-Start/Stop are now part of LSB as of 2.0,
100# formerly SUSE/Unitedlinux used X-UnitedLinux-Should-Start/-Stop.
101# insserv does support both variants.
102# * X-UnitedLinux-Default-Enabled: yes/no is used at installation time
103# (%fillup_and_insserv macro in %post of many RPMs) to specify whether
104# a startup script should default to be enabled after installation.
105# It's not used by insserv.
106#
107# Note on runlevels:
108# 0 - halt/poweroff 6 - reboot
109# 1 - single user 2 - multiuser without network exported
110# 3 - multiuser w/ network (text mode) 5 - multiuser w/ network and X11 (xdm)
111#
112# Note on script names:
113# http://www.linuxbase.org/spec/refspecs/LSB_1.3.0/gLSB/gLSB/scrptnames.html
114# A registry has been set up to manage the init script namespace.
115# http://www.lanana.org/
116# Please use the names already registered or register one or use a
117# vendor prefix.
118
119
120# Check for missing binaries (stale symlinks should not happen)
121# Note: Special treatment of stop for LSB conformance
122FOO_BIN=/usr/sbin/FOO
123test -x $FOO_BIN || { echo "$FOO_BIN not installed";
124 if [ "$1" = "stop" ]; then exit 0;
125 else exit 5; fi; }
126
127# Check for existence of needed config file and read it
128FOO_CONFIG=/etc/sysconfig/FOO
129test -r $FOO_CONFIG || { echo "$FOO_CONFIG not existing";
130 if [ "$1" = "stop" ]; then exit 0;
131 else exit 6; fi; }
132
133# Read config
134. $FOO_CONFIG
135
136# Source LSB init functions
137# providing start_daemon, killproc, pidofproc,
138# log_success_msg, log_failure_msg and log_warning_msg.
139# This is currently not used by UnitedLinux based distributions and
140# not needed for init scripts for UnitedLinux only. If it is used,
141# the functions from rc.status should not be sourced or used.
142#. /lib/lsb/init-functions
143
144# Shell functions sourced from /etc/rc.status:
145# rc_check check and set local and overall rc status
146# rc_status check and set local and overall rc status
147# rc_status -v be verbose in local rc status and clear it afterwards
148# rc_status -v -r ditto and clear both the local and overall rc status
149# rc_status -s display "skipped" and exit with status 3
150# rc_status -u display "unused" and exit with status 3
151# rc_failed set local and overall rc status to failed
152# rc_failed <num> set local and overall rc status to <num>
153# rc_reset clear both the local and overall rc status
154# rc_exit exit appropriate to overall rc status
155# rc_active checks whether a service is activated by symlinks
156. /etc/rc.status
157
158# Reset status of this service
159rc_reset
160
161# Return values acc. to LSB for all commands but status:
162# 0 - success
163# 1 - generic or unspecified error
164# 2 - invalid or excess argument(s)
165# 3 - unimplemented feature (e.g. "reload")
166# 4 - user had insufficient privileges
167# 5 - program is not installed
168# 6 - program is not configured
169# 7 - program is not running
170# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
171#
172# Note that starting an already running service, stopping
173# or restarting a not-running service as well as the restart
174# with force-reload (in case signaling is not supported) are
175# considered a success.
176
177case "$1" in
178 start)
179 echo -n "Starting FOO "
180 ## Start daemon with startproc(8). If this fails
181 ## the return value is set appropriately by startproc.
182 startproc $FOO_BIN
183
184 # Remember status and be verbose
185 rc_status -v
186 ;;
187 stop)
188 echo -n "Shutting down FOO "
189 ## Stop daemon with killproc(8) and if this fails
190 ## killproc sets the return value according to LSB.
191
192 killproc -TERM $FOO_BIN
193
194 # Remember status and be verbose
195 rc_status -v
196 ;;
197 try-restart|condrestart)
198 ## Do a restart only if the service was active before.
199 ## Note: try-restart is now part of LSB (as of 1.9).
200 ## RH has a similar command named condrestart.
201 if test "$1" = "condrestart"; then
202 echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
203 fi
204 $0 status
205 if test $? = 0; then
206 $0 restart
207 else
208 rc_reset # Not running is not a failure.
209 fi
210 # Remember status and be quiet
211 rc_status
212 ;;
213 restart)
214 ## Stop the service and regardless of whether it was
215 ## running or not, start it again.
216 $0 stop
217 $0 start
218
219 # Remember status and be quiet
220 rc_status
221 ;;
222 force-reload)
223 ## Signal the daemon to reload its config. Most daemons
224 ## do this on signal 1 (SIGHUP).
225 ## If it does not support it, restart.
226
227 echo -n "Reload service FOO "
228 ## if it supports it:
229 killproc -HUP $FOO_BIN
230 #touch /var/run/FOO.pid
231 rc_status -v
232
233 ## Otherwise:
234 #$0 try-restart
235 #rc_status
236 ;;
237 reload)
238 ## Like force-reload, but if daemon does not support
239 ## signaling, do nothing (!)
240
241 # If it supports signaling:
242 echo -n "Reload service FOO "
243 killproc -HUP $FOO_BIN
244 #touch /var/run/FOO.pid
245 rc_status -v
246
247 ## Otherwise if it does not support reload:
248 #rc_failed 3
249 #rc_status -v
250 ;;
251 status)
252 echo -n "Checking for service FOO "
253 ## Check status with checkproc(8), if process is running
254 ## checkproc will return with exit status 0.
255
256 # Return value is slightly different for the status command:
257 # 0 - service up and running
258 # 1 - service dead, but /var/run/ pid file exists
259 # 2 - service dead, but /var/lock/ lock file exists
260 # 3 - service not running (unused)
261 # 4 - service status unknown :-(
262 # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
263
264 # NOTE: checkproc returns LSB compliant status values.
265 checkproc $FOO_BIN
266 # NOTE: rc_status knows that we called this init script with
267 # "status" option and adapts its messages accordingly.
268 rc_status -v
269 ;;
270 probe)
271 ## Optional: Probe for the necessity of a reload, print out the
272 ## argument to this init script which is required for a reload.
273 ## Note: probe is not (yet) part of LSB (as of 1.9)
274
275 test /etc/FOO/FOO.conf -nt /var/run/FOO.pid && echo reload
276 ;;
277 *)
278 echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
279 exit 1
280 ;;
281esac
282rc_exit