Debian Codegraph @

examples/shutdown-1.0/script/stop_storage

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 # Do unmount/remount-ro. Wait.
3 # KILL everybody. Wait.
4 # Repeat.
5
6 umountcnt=2
7 writeout=0 # increase if your kernel does not guarantee writes to complete
8
9 # No /usr - we are expecting all binaries to be accessible
10 # from root fs alone
11 PATH=/sbin:/binscip-shell filesystem . . `/sbin:/bin`.
12
13 sayscip-shell shell shell-project 0.0.0 say().() {
14 printfscip-shell system . . printf. "\r%s\n\r" "$*"
15 }
16
17 showpsscip-shell shell shell-project 0.0.0 showps().() {
18 # sleep 1 ensures that xargs will have time to start up
19 # this makes pslist less prone to random jitter
20 pslist=`{ sleepscip-shell system . . sleep. 1; psscip-shell system . . ps. -A -o comm=; } | sortscip-shell system . . sort. | xargsscip-shell system . . xargs.`
21 pscnt=$(( `sayscip-shell shell shell-project 0.0.0 say(). "$pslist" | wcscip-shell system . . wc. -w` + 0 ))
22 if testscip-shell system . . test. x"$VERBOSE" = x; then
23 sayscip-shell shell shell-project 0.0.0 say(). "* `datescip-shell system . . date. '+%H:%M:%S'` $pscnt processes"
24 else
25 sayscip-shell shell shell-project 0.0.0 say(). "* `datescip-shell system . . date. '+%H:%M:%S'` Processes ($pscnt): $pslist"
26 fi
27 }
28
29 sayscip-shell shell shell-project 0.0.0 say(). "<*> `datescip-shell system . . date. '+%Y-%m-%d %H:%M:%S'` Executing '$0 $*'"
30
31 showpsscip-shell shell shell-project 0.0.0 showps().
32
33 i="$umountcnt"
34 while testscip-shell system . . test. "$i" -gt 0; do
35 sayscip-shell shell shell-project 0.0.0 say(). "* `datescip-shell system . . date. '+%H:%M:%S'` Unmounting filesystems"
36 umountscip-shell system . . umount. -a -n -r -f
37 # In case we unmounted proc...
38 testscip-shell system . . test. -e /proc/versionscip-shell filesystem . . `/proc/version`. || mountscip-shell system . . mount. -t proc none /procscip-shell filesystem . . `/proc`.
39 # Remounting / RO isn't necessary when /etc/mtab is linked to /proc/mounts:
40 # already done. But let's be more paranoid here...
41 sayscip-shell shell shell-project 0.0.0 say(). "* `datescip-shell system . . date. '+%H:%M:%S'` Remounting root filesystem read-only"
42 mountscip-shell system . . mount. -n -o remount,ro /scip-shell filesystem . . `/`.
43 sayscip-shell shell shell-project 0.0.0 say(). "* `datescip-shell system . . date. '+%H:%M:%S'` Freeing loop devices"
44 for a in /dev/loop*; do
45 testscip-shell system . . test. -b "$a" && losetupscip-shell system . . losetup. -d "$a"
46 done
47 sayscip-shell shell shell-project 0.0.0 say(). "* `datescip-shell system . . date. '+%H:%M:%S'` Syncing"
48 syncscip-shell system . . sync.
49 sayscip-shell shell shell-project 0.0.0 say(). "* `datescip-shell system . . date. '+%H:%M:%S'` Executing: killall5 -KILL"
50 killall5scip-shell system . . killall5. -9
51 showpsscip-shell shell shell-project 0.0.0 showps().
52 i=$((i-1))
53 done
54
55 sayscip-shell shell shell-project 0.0.0 say(). "* `datescip-shell system . . date. '+%H:%M:%S'` Filesystem status (/proc/mounts)"
56 catscip-shell system . . cat. /proc/mountsscip-shell filesystem . . `/proc/mounts`. \
57 | {
58 bad=false
59 while read dev mntpoint fstype opt n1 n2; do
60 case "$fstype" in
61 ( proc | sysfs | usbfs | devpts | rpc_pipefs | binfmt_misc | autofs | rootfs | tmpfs | ramfs )
62 sayscip-shell shell shell-project 0.0.0 say(). "$dev $mntpoint $fstype $opt $n1 $n2"
63 continue
64 ;;
65 esac
66 if testscip-shell system . . test. "${opt:0:2}" = "rw"; then
67 sayscip-shell shell shell-project 0.0.0 say(). "$dev $mntpoint $fstype $opt $n1 $n2 - RW!"
68 bad=true
69 else
70 sayscip-shell shell shell-project 0.0.0 say(). "$dev $mntpoint $fstype $opt $n1 $n2"
71 fi
72 done
73 if $bad; then
74 sayscip-shell shell shell-project 0.0.0 say(). "ERROR: we have filesystems mounted RW! Press <Enter> (^J)..."
75 read junk </dev/consolescip-shell filesystem . . `/dev/console`.
76 #sh </dev/console >&0 2>&0 # debug
77 fi
78 }
79
80 # Disk cache writeout
81 sleepscip-shell system . . sleep. "$writeout"