summaryrefslogtreecommitdiffstats
path: root/shutdown
blob: 100f5058afb401c6452766bb589eb15fba645df0 (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
29
#!/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
  reboot)
    type kexec >/dev/null && kexec -e
    reboot -f
    ;;
  poweroff|shutdown|halt)
    "$1" -f
    ;;
  *)
    poweroff -f
    ;;
esac