summaryrefslogtreecommitdiffstats
path: root/etc/rc.shutdown
diff options
context:
space:
mode:
authorgordon <gordon@FreeBSD.org>2002-06-13 22:30:02 +0000
committergordon <gordon@FreeBSD.org>2002-06-13 22:30:02 +0000
commit71e9fd7b1ab1a0ffb8cf3c2ebb80c97ea3364b2e (patch)
tree1507ceaafbb91402503acd68aeecbe74212b3649 /etc/rc.shutdown
parentc61b4c2e3d37d795fa74f9d97e181d9de2fc77a8 (diff)
downloadFreeBSD-src-71e9fd7b1ab1a0ffb8cf3c2ebb80c97ea3364b2e.zip
FreeBSD-src-71e9fd7b1ab1a0ffb8cf3c2ebb80c97ea3364b2e.tar.gz
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
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 25c1e42..0f4bd3d 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
#
OpenPOWER on IntegriCloud