summaryrefslogtreecommitdiffstats
path: root/shutdown
blob: 39bcb976b3247ba74d83edc8a1fdac2a8064eb9a (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
#!/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