blob: 029cd6556d57b076eb16c66b26b6b3f5a3105f80 [file] [log] [blame]
Milton D. Miller IId89d5e02016-01-20 14:57:54 -06001#!/bin/sh
2
3echo shutdown: "$@"
4
5export PS1=shutdown-sh#\
6# exec bin/sh
7
8if [ ! -e /proc/mounts ]
9then
10 mkdir -p /proc
11 mount proc proc -tproc
12 umount_proc=1
13else
14 umount_proc=
15fi
16
17# remove an empty oldroot, that means we are not invoked from systemd-shutdown
18rmdir /oldroot 2>/dev/null
19
20set -x
21for f in $( awk '/oldroot/ { print $2 }' < /proc/mounts | sort -r )
22do
23 umount $f
24done
25set +x
26
27
28if test -x /update && ls image-* > /dev/null 2>&1
29then
30 exec /update ${1+"$@"}
31fi
32
33echo Remaining mounts:
34cat /proc/mounts
35
36test "umount_proc" && umount /proc && rmdir /proc
37
38
39
40# Execute the command systemd told us to ...
41if test -d /oldroot && test "$1"
42then
43 if test "$1" == kexec
44 then
45 $1 -f -e
46 else
47 $1 -f
48 fi
49fi
50
51
52echo "Execute ${1-reboot} -f if all unounted ok, or exec /init"
53
54export PS1=shutdown-sh#\
55exec /bin/sh