diff options
author | mtm <mtm@FreeBSD.org> | 2007-05-18 12:04:41 +0000 |
---|---|---|
committer | mtm <mtm@FreeBSD.org> | 2007-05-18 12:04:41 +0000 |
commit | 6d5baaa0915889111c959912b06a8315052876c5 (patch) | |
tree | 6358eeee7fccccd9b0299bd803dcf2ec18d52606 /etc/rc.subr | |
parent | e1996cb9609d2e55a26ee78dddbfce4ba4073b53 (diff) | |
download | FreeBSD-src-6d5baaa0915889111c959912b06a8315052876c5.zip FreeBSD-src-6d5baaa0915889111c959912b06a8315052876c5.tar.gz |
o Implement the stop_boot subroutine [1]. This subroutine can be used by
scripts in rc.d to stop rc(8) from booting into multi-user mode when
a critical or severe error condition is encountered.
o Modify scripts in etc/rc.d that already implemented this functionality
independently.
o Document it.
[1] - This subroutine was implemented in FreeBSD in rc.d/fsck. I moved it
to rc.subr(8). Our version differs slightly in that it takes an
optional argument to stop the boot even if "autoboot" is not set.
Obtained from: NetBSD
MFC after: 2 weeks
Diffstat (limited to 'etc/rc.subr')
-rw-r--r-- | etc/rc.subr | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/etc/rc.subr b/etc/rc.subr index 8cdb6e7..061f0b9 100644 --- a/etc/rc.subr +++ b/etc/rc.subr @@ -40,6 +40,7 @@ # : ${rcvar_manpage:='rc.conf(5)'} +: ${RC_PID:=$$}; export RC_PID # # Operating System dependent/independent variables @@ -161,6 +162,27 @@ reverse_list() echo $_revlist } +# stop_boot always +# If booting directly to multiuser or $always is enabled, +# send SIGTERM to the parent (/etc/rc) to abort the boot. +# Otherwise just exit. +# +stop_boot() +{ + local always + + if [ -n "$1" ] && checkyesno $1; then + always=true + else + always=false + fi + if [ "$autoboot" = yes -o "$always" = true ]; then + echo "ERROR: ABORTING BOOT (sending SIGTERM to parent)!" + kill -TERM ${RC_PID} + fi + exit 1 +} + # # mount_critical_filesystems type # Go through the list of critical filesystems as provided in |