aboutsummaryrefslogtreecommitdiff
path: root/etc/rc.shutdown
diff options
context:
space:
mode:
authorGordon Tetlow <gordon@FreeBSD.org>2002-06-13 22:30:02 +0000
committerGordon Tetlow <gordon@FreeBSD.org>2002-06-13 22:30:02 +0000
commit825bb041251952ecc17ae2cfd184b46958924aba (patch)
tree1507ceaafbb91402503acd68aeecbe74212b3649 /etc/rc.shutdown
parent29527678370faec53214e8afb0564cb09257241f (diff)
downloadsrc-825bb041251952ecc17ae2cfd184b46958924aba.tar.gz
src-825bb041251952ecc17ae2cfd184b46958924aba.zip
Add the final bits that allow the use of rc.d. Note that you can toggle
between rc.d and the classic boot scripts based on the rcng variable in your rc.conf. Defaults to classic boot scripts. Submitted by: Mike Makonnen
Notes
Notes: svn path=/head/; revision=98189
Diffstat (limited to 'etc/rc.shutdown')
-rw-r--r--etc/rc.shutdown51
1 files changed, 51 insertions, 0 deletions
diff --git a/etc/rc.shutdown b/etc/rc.shutdown
index 25c1e429a83f..0f4bd3db2c1d 100644
--- a/etc/rc.shutdown
+++ b/etc/rc.shutdown
@@ -44,6 +44,7 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
export HOME PATH
# If there is a global system configuration file, suck it in.
+# XXX - It's only purpose is to catch rc_ng="YES".
#
if [ -r /etc/defaults/rc.conf ]; then
. /etc/defaults/rc.conf
@@ -52,6 +53,56 @@ elif [ -r /etc/rc.conf ]; then
. /etc/rc.conf
fi
+case ${rc_ng} in
+[Yy][Ee][Ss])
+ . /etc/rc.subr
+
+ load_rc_config 'XXX'
+
+ # If requested, start a watchdog timer in the background which
+ # will terminate rc.shutdown if rc.shutdown doesn't complete
+ # within the specified time.
+ #
+ _rcshutdown_watchdog=
+ if [ -n "$rcshutdown_timeout" ]; then
+ debug "Initiating watchdog timer."
+ sleep $rcshutdown_timeout && (
+ _msg="$rcshutdown_timeout second watchdog" \
+ " timeout expired. Shutdown terminated."
+ logger -t rc.shutdown "$_msg"
+ echo "$_msg"
+ date
+ kill -KILL $$ >/dev/null 2>&1
+ ) &
+ _rcshutdown_watchdog=$!
+ fi
+
+ # Determine the shutdown order of the /etc/rc.d scripts,
+ # and perform the operation
+ # XXX - rcorder(8) with multiple -k switches works as a logical OR,
+ # so, we can't do this: rcorder -k shutdown -k FreeBSD.
+ #
+ files=`eval grep -l \'^# KEYWORD:.*FreeBSD\' \`rcorder -k shutdown /etc/rc.d/*\``
+
+ for _rc_elem in `reverse_list $files`; do
+ debug "run_rc_script $_rc_elem stop"
+ run_rc_script $_rc_elem stop
+ done
+
+ # Terminate the background watchdog timer (if it is running)
+ #
+ if [ -n "$_rcshutdown_watchdog" ]; then
+ kill -TERM $_rcshutdown_watchdog >/dev/null 2>&1
+ fi
+
+ echo '.'
+ exit 0
+ ;;
+*)
+ # fall-through to the old rc scripts
+ ;;
+esac
+
# reverse_list list
# print the list in reverse order
#