summaryrefslogtreecommitdiffstats
path: root/shutdown
diff options
context:
space:
mode:
Diffstat (limited to 'shutdown')
-rwxr-xr-xshutdown29
1 files changed, 29 insertions, 0 deletions
diff --git a/shutdown b/shutdown
new file mode 100755
index 0000000..100f505
--- /dev/null
+++ b/shutdown
@@ -0,0 +1,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