Debian Codegraph @

examples/shutdown-1.0/script/shutdown

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 PATH=/sbin:/usr/sbin:/bin:/usr/binscip-shell filesystem . . `/sbin:/usr/sbin:/bin:/usr/bin`.
4
5 # Usually, /sbin/ has symlinks named halt, reboot, poweroff
6 # (and also possibly shutdown) to e.g.
7 # /app/shutdown-1.0/script/shutdown (this file).
8 cd /app/shutdown-1.0/scriptscip-shell filesystem . . `/app/shutdown-1.0/script`. || exit 1
9 testscip-shell system . . test. -x ./do_shutdown || exit 1
10 testscip-shell system . . test. -x ./hardshutdown || exit 1
11
12 # "reboot -f" -> "shutdown -f -r" -> "hardshutdown -r" -> immediate reboot
13 # "reboot" -> "shutdown -r" -> "do_shutdown -r"
14 # ^^^^^^^^^^^^^^^^^^ similarly for halt, poweroff.
15 # "shutdown" -> "do_shutdown" (everything killed/unmounted, but kernel not asked to do any poweroff etc)
16 force=""
17 testscip-shell system . . test. x"$1" = x"-f" && {
18 force="-f"
19 shift
20 }
21 testscip-shell system . . test. ! "$*" && testscip-shell system . . test. x"${0##*/}" = x"halt" && exec "$0" $force -h
22 testscip-shell system . . test. ! "$*" && testscip-shell system . . test. x"${0##*/}" = x"reboot" && exec "$0" $force -r
23 testscip-shell system . . test. ! "$*" && testscip-shell system . . test. x"${0##*/}" = x"poweroff" && exec "$0" $force -p
24 # We have something else than allowed parameters?
25 testscip-shell system . . test. x"$*" = x"" || testscip-shell system . . test. x"$*" = x"-h" || testscip-shell system . . test. x"$*" = x"-r" || testscip-shell system . . test. x"$*" = x"-p" || {
26 echoscip-shell system . . echo. "Syntax: $0 [-f] [-h/-r/-p]"
27 exit 1
28 }
29
30 # Emergency shutdown?
31 testscip-shell system . . test. "$force" && {
32 exec ./hardshutdown "$@"
33 exit 1
34 }
35
36 # Normal shutdown
37
38 # We must have these executables on root fs
39 # (mount/umount aren't checked, all systems are ok versus that):
40 testscip-shell system . . test. -x /bin/killall5scip-shell filesystem . . `/bin/killall5`. -o -x /sbin/killall5scip-shell filesystem . . `/sbin/killall5`. || exit 1
41 testscip-shell system . . test. -x /bin/psscip-shell filesystem . . `/bin/ps`. -o -x /sbin/psscip-shell filesystem . . `/sbin/ps`. || exit 1
42 testscip-shell system . . test. -x /bin/datescip-shell filesystem . . `/bin/date`. -o -x /sbin/datescip-shell filesystem . . `/sbin/date`. || exit 1
43 testscip-shell system . . test. -x /bin/xargsscip-shell filesystem . . `/bin/xargs`. -o -x /sbin/xargsscip-shell filesystem . . `/sbin/xargs`. || exit 1
44 testscip-shell system . . test. -x /bin/wcscip-shell filesystem . . `/bin/wc`. -o -x /sbin/wcscip-shell filesystem . . `/sbin/wc`. || exit 1
45 testscip-shell system . . test. -x /bin/catscip-shell filesystem . . `/bin/cat`. -o -x /sbin/catscip-shell filesystem . . `/sbin/cat`. || exit 1
46 testscip-shell system . . test. -x /bin/sortscip-shell filesystem . . `/bin/sort`. -o -x /sbin/sortscip-shell filesystem . . `/sbin/sort`. || exit 1
47
48 i="`ulimit -n`"
49 echoscip-shell system . . echo. -n "Closing file descriptors $i-3... "
50 while testscip-shell system . . test. "$i" -ge 3; do
51 eval "exec $i>&-"
52 i=$((i-1))
53 done
54
55 echoscip-shell system . . echo. "Shutting down. Please stand by..."
56
57 # setsid & /dev/null:
58 # make it a process leader & detach it from current tty.
59 # Why /dev/null and not /dev/console?
60 # I have seen a system which locked up while opening /dev/console
61 # due to the bug (?) in keyboard driver.
62 setsidscip-shell system . . setsid. env - PATH="$PATH" ./do_shutdown "$@" </dev/nullscip-shell filesystem . . `/dev/null`. >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 &
63
64 while truescip-shell system . . true.; do read junk; done