Add shutdown timer to droppie

This commit is contained in:
Benjamin Bädorf 2022-11-27 21:36:46 +01:00
parent 60ca29289e
commit b416e63d18
No known key found for this signature in database
GPG key ID: 4406E80E13CD656C
2 changed files with 25 additions and 23 deletions

View file

@ -1,5 +1,7 @@
{ pkgs, ... }:
{ pkgs, config, ... }:
let
psCfg = config.pub-solar;
in
{
config = {
services.openssh.knownHosts = {

View file

@ -3,11 +3,11 @@
let
shutdownWaitMinutes = 15;
shutdownScript = pkgs.writeScript "shutdown" ''
STATUS_FILES="/media/internal/backups-pub-solar/status"
STATUS_FILES="/media/internal/backups-pub-solar/status"
running=""
running=""
for f in $STATUS_FILES; do
for f in $STATUS_FILES; do
declare started
declare finished
@ -19,18 +19,18 @@ for f in $STATUS_FILES; do
running="yes"
break
fi
done
done
if [ -n "''${running}" ] && [ "''${running}" = "yes" ]; then
if [ -n "''${running}" ] && [ "''${running}" = "yes" ]; then
echo "backups are still running"
exit 1
fi
fi
echo "WARNING: System will be shut down within the next 15 minutes" | wall
echo "WARNING: System will be shut down within the next 15 minutes" | wall
sleep 10
sleep 10
shutdown -P +${builtins.toString shutdownWaitMinutes}
shutdown -P +${builtins.toString shutdownWaitMinutes}
'';
in
{
@ -43,7 +43,7 @@ in
systemd.timers."shutdown-after-backup" = {
enable = true;
serviceConfig = {
timerConfig = {
OnCalendar = "3..9:*";
};
};