c97861bfa751f0db993391d3ebe80e563138cdc1
[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 (
15         while dsa-is-shutdown-scheduled; do
16                 sleep 1
17         done
18 ) &
19 disown
20 exit 0