ebbac937bbdc2854ff272d7011558327eb8e8927
[mirror/dsa-puppet.git] / modules / debian-org / files / molly-guard / 15-acquire-reboot-lock
1 #!/bin/bash
2
3 # Copyright 2012 Peter Palfrader
4
5 l=/var/run/reboot-lock
6 exec 3> $l
7
8 if ! flock --exclusive -w 0  3; then
9         echo >&2 "Cannot acquire reboot lock."
10         exit 1
11 fi
12 echo "Reboot lock acquired."
13
14 ppid="$PPID"
15 (
16         while kill -0 "$ppid" 2>/dev/null; do
17                 sleep 1
18         done
19 ) &
20 disown
21 exit 0