SVN: rc-scripts/trunk/rc.d/init.d/template.init
glen
glen at pld-linux.org
Sun Sep 17 19:10:34 CEST 2006
Author: glen
Date: Sun Sep 17 19:10:34 2006
New Revision: 7778
Modified:
rc-scripts/trunk/rc.d/init.d/template.init
Log:
Demonstrate use of functions.
Modified: rc-scripts/trunk/rc.d/init.d/template.init
==============================================================================
--- rc-scripts/trunk/rc.d/init.d/template.init (original)
+++ rc-scripts/trunk/rc.d/init.d/template.init Sun Sep 17 19:10:34 2006
@@ -33,9 +33,7 @@
exit 0
fi
-# See how we were called.
-case "$1" in
- start)
+start() {
# Check if the service is already running?
if [ ! -f /var/lock/subsys/<service> ]; then
msg_starting <service>
@@ -45,8 +43,9 @@
else
msg_already_running <service>
fi
- ;;
- stop)
+}
+
+stop() {
if [ -f /var/lock/subsys/<service> ]; then
# Stop daemons.
msg_stopping <service>
@@ -55,28 +54,43 @@
else
msg_not_running <service>
fi
- ;;
- restart)
- $0 stop
- $0 start
- exit $?
- ;;
- reload)
+}
+
+reload() {
if [ -f /var/lock/subsys/<service> ]; then
msg_reloading <service>
killproc <service> -HUP
RETVAL=$?
else
- msg_not_running <service> >&2
+ msg_not_running <service>
RETVAL=7
fi
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ exit $?
+ ;;
+ reload)
+ reload
;;
force-reload)
# if program allows reloading without stopping
- $0 reload
+ reload
# or if it doesn't
- $0 restart
+ stop
+ start
exit $?
;;
More information about the pld-cvs-commit
mailing list