summaryrefslogtreecommitdiffstats
path: root/shutdown
blob: aad019808650b88c469c7e2f0af322ce99f8fa37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/ash

findmnt -Rruno TARGET /oldroot | awk '
BEGIN { i = 0 }
! /^\/(proc|dev|sys)/ {
    i++
    mounts[i] = $0
}
END {
    for (j = i; j > 0; j--) {
        print mounts[j]
    }
}
' | while read -r mount; do
    umount -l "$mount"
done

case $1 in
    poweroff|shutdown|halt)
        "$1" -f
        ;;
    *)
        type kexec >/dev/null && kexec -e
        reboot -f
        ;;
esac

# vim: ft=sh ts=4 sw=4