summaryrefslogtreecommitdiff
path: root/old-school/init.shutdown
blob: 6bfce8457fb469cfad8ac2c8facc71128231f1b3 (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
30
#!/bin/sh
read omitpids < /run/sendsigs.omit.d/samizdat
for pid in $omitpids; do
  if [ -e /proc/$pid/root ]; then
    initroot=/proc/$pid/root
    break
  fi
done

warn() { echo "$*" >/dev/console; }
error() { umount /sbin/init; exec /sbin/init; }

[ -e "$initroot" ] || error

if [ $$ != 1 ]; then
  exec $initroot/init "$@"
else
  set --
  for pid in $omitpids; do
    set -- "$@" -o $pid
  done
  if killall5 -15 "$@"; then
    sleep 5
    killall5 -9 "$@"
  fi
  exec <$initroot/dev/console >$initroot/dev/console 2>$initroot/dev/console
  exec chroot $initroot umountall.sh

  error
fi