nut-debian/scripts/systemd/nutshutdown.in

24 lines
709 B
Plaintext
Raw Normal View History

2011-09-29 21:14:46 +03:00
#!/bin/sh
2022-07-10 10:23:45 +03:00
# This script requires both nut-server (drivers)
# and nut-client (upsmon) to be present locally
# and on mounted filesystems
[ -x "@SBINDIR@/upsmon" ] && [ -x "@SBINDIR@/upsdrvctl" ] || exit
if @SBINDIR@/upsmon -K >/dev/null 2>&1; then
# The argument may be anything compatible with sleep
# (not necessarily a non-negative integer)
wait_delay="`/bin/sed -ne 's#^ *POWEROFF_WAIT= *\(.*\)$#\1#p' @CONFPATH@/nut.conf`" || wait_delay=""
@SBINDIR@/upsdrvctl shutdown
if [ -n "$wait_delay" ] ; then
/bin/sleep $wait_delay
# We need to pass --force twice here to bypass systemd and execute the
# reboot directly ourself.
/bin/systemctl reboot --force --force
fi
fi
exit 0