Retire dsa-is-shutdown-scheduled in favor of test -e /run/systemd/shutdown/scheduled
[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 [ -e /run/systemd/shutdown/scheduled ]; do
16                 sleep 1
17         done
18 ) &
19 disown
20 exit 0