LDP/LDP/guide/docbook/abs-guide/ex55.sh

43 lines
1.5 KiB
Bash
Raw Normal View History

2001-07-10 14:25:50 +00:00
#!/bin/sh
2001-09-04 13:27:31 +00:00
# --> Comments added by the author of this document marked by "# -->".
2001-07-10 14:25:50 +00:00
# --> This is part of the 'rc' script package
2005-02-09 20:53:43 +00:00
# --> by Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>.
2001-07-10 14:25:50 +00:00
2005-02-09 20:53:43 +00:00
# --> This particular script seems to be Red Hat / FC specific
2001-07-10 14:25:50 +00:00
# --> (may not be present in other distributions).
2005-02-09 20:53:43 +00:00
# Bring down all unneeded services that are still running
#+ (there shouldn't be any, so this is just a sanity check)
2001-07-10 14:25:50 +00:00
for i in /var/lock/subsys/*; do
# --> Standard for/in loop, but since "do" is on same line,
# --> it is necessary to add ";".
2005-02-09 20:53:43 +00:00
# Check if the script is there.
[ ! -f $i ] && continue
2005-02-09 20:53:43 +00:00
# --> This is a clever use of an "and list", equivalent to:
# --> if [ ! -f "$i" ]; then continue
# Get the subsystem name.
subsys=${i#/var/lock/subsys/}
# --> Match variable name, which, in this case, is the file name.
# --> This is the exact equivalent of subsys=`basename $i`.
2001-07-10 14:25:50 +00:00
2005-02-09 20:53:43 +00:00
# --> It gets it from the lock file name
# -->+ (if there is a lock file,
# -->+ that's proof the process has been running).
# --> See the "lockfile" entry, above.
2001-07-10 14:25:50 +00:00
2005-02-09 20:53:43 +00:00
# Bring the subsystem down.
if [ -f /etc/rc.d/init.d/$subsys.init ]; then
/etc/rc.d/init.d/$subsys.init stop
else
/etc/rc.d/init.d/$subsys stop
2004-10-03 17:40:48 +00:00
# --> Suspend running jobs and daemons.
# --> Note that "stop" is a positional parameter,
# -->+ not a shell builtin.
2005-02-09 20:53:43 +00:00
fi
2001-07-10 14:25:50 +00:00
done