From cc596b196542aff3441eb5849715515cb0799437 Mon Sep 17 00:00:00 2001 From: "Michael K. Johnson" Date: Tue, 10 Feb 1998 19:35:32 +0000 Subject: Added full instructions on writing a System V init script for Red Hat Linux. --- sysvinitfiles | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 2 deletions(-) (limited to 'sysvinitfiles') diff --git a/sysvinitfiles b/sysvinitfiles index ab0c510d..7fed5046 100644 --- a/sysvinitfiles +++ b/sysvinitfiles @@ -1,9 +1,110 @@ +Writing a System V init script for Red Hat Linux +================================================ + +All System V init scripts are named /etc/rc.d/init.d/ +where is the name of the service. There must be no +".init" suffix. + + +Sample Script +============= + +#!/bin/bash +# +# /etc/rc.d/init.d/ +# +# +# +# +# + +# Source function library. +. /etc/rc.d/init.d/functions + + + +case "$1" in + start) + echo -n "Starting services: " + + touch /var/lock/subsys/ + ;; + stop) + echo -n "Shutting down services: " + + rm -f /var/lock/subsys/ + ;; + status) + + ;; + restart) + + ;; + reload) + + ;; + probe) + + ;; + *) + echo "Usage: {start|stop|status|reload|restart[|probe]" + exit 1 + ;; +esac + + + +Functions in /etc/rc.d/init.d/functions +======================================= + +daemon [+/-nicelevel] program [arguments] [&] + + Starts a daemon, if it is not already running. Does + other useful things like keeping the daemon from dumping + core if it terminates unexpectedly. + +killproc program [signal] + + Sends a signal to the program; by default it sends a SIGTERM, + and if the process doesn't die, it sends a SIGKILL a few + seconds later. + + It also tries to remove the pidfile, if it finds one. + +pidofproc program + + Tries to find the pid of a program; checking likely pidfiles, + using the pidof program, or even using ps. Used mainly from + within other functions in this file, but also available to + scripts. + +status program + + Prints status information. Assumes that the program name is + the same as the servicename. + + +Tags +==== + # chkconfig: Required. is a list of levels in which the service should be started by default. and are priority numbers. For example: # chkconfig: 2345 20 80 + Read 'man chkconfig' for more information. # description: @@ -45,7 +146,19 @@ Optional, used IN PLACE of autoreload, processname, config, and pidfile. If it exists, then a proper reload-if-necessary - cycle may be acheived by running this command: - /etc/rc.d/init.d/SCRIPT `/etc/rd.d/init.d/SCRIPT probe` + cycle may be acheived by running these commands: + + command=$(/etc/rd.d/init.d/SCRIPT probe) + [ -n "$command" ] && /etc/rc.d/init.d/SCRIPT $command + where SCRIPT is the name of the service's sysv init script. + Scripts that need to do complex processing could, as an + example, return "run /var/tmp/