[BACK]Return to rc.shutdown CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / etc

Annotation of src/etc/rc.shutdown, Revision 1.8

1.3       lukem       1: #!/bin/sh
                      2: #
1.8     ! lukem       3: # $NetBSD: rc.shutdown,v 1.7 2001/11/19 03:19:28 lukem Exp $
1.3       lukem       4: #
1.5       lukem       5: # rc.shutdown --
1.3       lukem       6: #      Run the scripts in /etc/rc.d with reverse rcorder.
1.5       lukem       7:
                      8: #      System shutdown script run by shutdown(8) at system shutdown time.
                      9: #      Note that halt(8) and reboot(8) do NOT invoke this script.
1.1       bad        10:
                     11: export HOME=/
1.3       lukem      12: export PATH=/sbin:/bin:/usr/sbin:/usr/bin
1.1       bad        13:
1.3       lukem      14: . /etc/rc.subr
                     15: . /etc/rc.conf
1.1       bad        16:
1.3       lukem      17: if ! checkyesno do_rcshutdown; then
1.1       bad        18:        echo "Skipping shutdown hooks."
                     19:        exit 0
                     20: fi
                     21:
1.3       lukem      22: stty status '^T'
1.1       bad        23:
1.6       lukem      24: #      Set shell to ignore SIGINT, but not children;
                     25: #      shell catches SIGQUIT and returns to single user.
1.3       lukem      26: #
1.6       lukem      27: trap : INT
                     28: trap "echo 'Shutdown interrupted.'; exit 1" QUIT
1.3       lukem      29:
1.6       lukem      30: #      If requested, start a watchdog timer in the background which
                     31: #      will terminate rc.shutdown if rc.shutdown doesn't complete
                     32: #      within the specified time.
                     33: #
                     34: _rcshutdown_watchdog=
                     35: if [ -n "$rcshutdown_timeout" ]; then
                     36:        sleep $rcshutdown_timeout && (
                     37:            _msg="$rcshutdown_timeout second watchdog timeout expired. Shutdown terminated."
                     38:            logger -t rc.shutdown "$_msg"
                     39:            echo "$_msg"
                     40:            date
                     41:            kill -KILL $$ >/dev/null 2>&1
                     42:            ) &
                     43:        _rcshutdown_watchdog=$!
                     44: fi
                     45:
                     46:
                     47: #      Determine the shutdown order of the /etc/rc.d scripts,
                     48: #      and perform the operation
                     49: #
1.8     ! lukem      50: files=$(rcorder -k shutdown ${rcshutdown_rcorder_flags} /etc/rc.d/*)
1.3       lukem      51:
1.8     ! lukem      52: for _rc_elem in $(reverse_list $files); do
1.7       lukem      53:        run_rc_script $_rc_elem stop
1.3       lukem      54: done
1.6       lukem      55:
                     56:
                     57: #      Terminate the background watchdog timer (if it is running)
                     58: #
                     59: if [ -n "$_rcshutdown_watchdog" ]; then
                     60:        kill -TERM $_rcshutdown_watchdog >/dev/null 2>&1
                     61: fi
1.1       bad        62:
1.3       lukem      63: date
1.1       bad        64: exit 0

CVSweb <webmaster@jp.NetBSD.org>