summaryrefslogtreecommitdiff
path: root/old-school/halt.montecarlo
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2016-04-29 14:36:26 -0400
committerAndrew Cady <d@jerkface.net>2016-04-29 14:36:30 -0400
commit153d299a41b9be4e15dab1ca29bb93a74bd2445d (patch)
tree96fbfbe7c64f0b3f02f3d755e2b129917785bb98 /old-school/halt.montecarlo
parent5f41fb879ca830e5ad3345878e59072f3d6573bc (diff)
fix paths (in progress)
Diffstat (limited to 'old-school/halt.montecarlo')
-rwxr-xr-xold-school/halt.montecarlo39
1 files changed, 0 insertions, 39 deletions
diff --git a/old-school/halt.montecarlo b/old-school/halt.montecarlo
deleted file mode 100755
index 67dac17..0000000
--- a/old-school/halt.montecarlo
+++ /dev/null
@@ -1,39 +0,0 @@
1#!/bin/bash
2
3cmd=${0##*/}
4dashf=
5for arg in "$@"; do
6 case "$arg" in -*f*) dashf=1 ;; esac
7 case "$arg" in -*p*) [ "$cmd" = halt ] && cmd=poweroff ;; esac
8done
9
10[ "$dashf" ] || exec -a "$0" /sbin/halt.distrib "$@"
11
12read pids < /run/sendsigs.omit.d/samizdat
13for p in $pids; do
14 if [ -e /proc/$p/root -a ! /proc/$p/root -ef / ]; then
15 initramfs=/proc/$p/root
16 break
17 fi
18done
19
20panic()
21{
22 set -x
23 sync
24 exec -a "$0" /sbin/halt.distrib "$@"
25}
26
27[ "$initramfs" ] || panic
28
29cp /sbin/init $initramfs/telinit
30
31# Apparently, linux does not allow a direct bind mount of a file on
32# the initramfs. Therefore, copy the file from the initramfs and bind
33# mount the copy.
34
35mount -o remount,exec /run
36cp $initramfs/lib/samizdat/init.shutdown /run/ && mount --bind /run/init.shutdown /sbin/init || panic
37
38echo $cmd -f > $initramfs/halt
39$initramfs/telinit u