Commit | Line | Data |
---|---|---|
074f2b6a S |
1 | #!/bin/bash |
2 | ||
3 | # we use this to boot up cause runit will not handle TERM and will not exit when done | |
4 | ||
d821539c S |
5 | shutdown() { |
6 | echo Shutting Down | |
7 | /etc/runit/3 | |
8 | ls /etc/service | SHELL=/bin/sh parallel sv force-stop {} | |
9 | kill -HUP $RUNSVDIR | |
10 | wait $RUNSVDIR | |
11 | ||
12 | # give stuff a bit of time to finish | |
13 | sleep 0.1 | |
14 | ||
15 | ORPHANS=`ps -eo pid | grep -v PID | tr -d ' ' | grep -v '^1$'` | |
16 | SHELL=/bin/bash parallel 'timeout 5 /bin/bash -c "kill {} && wait {}" || kill -9 {}' ::: $ORPHANS 2> /dev/null | |
17 | exit | |
18 | } | |
19 | ||
6be5513f | 20 | /etc/runit/1 || exit $? |
074f2b6a S |
21 | /etc/runit/2& |
22 | RUNSVDIR=$! | |
23 | echo "Started runsvdir, PID is $RUNSVDIR" | |
d821539c | 24 | trap shutdown SIGTERM SIGHUP |
074f2b6a | 25 | wait $RUNSVDIR |
d821539c S |
26 | |
27 | shutdown |