Add shutdown timer to droppie
This commit is contained in:
parent
60ca29289e
commit
b416e63d18
|
@ -1,5 +1,7 @@
|
||||||
{ pkgs, ... }:
|
{ pkgs, config, ... }:
|
||||||
|
let
|
||||||
|
psCfg = config.pub-solar;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
config = {
|
config = {
|
||||||
services.openssh.knownHosts = {
|
services.openssh.knownHosts = {
|
||||||
|
|
|
@ -3,34 +3,34 @@
|
||||||
let
|
let
|
||||||
shutdownWaitMinutes = 15;
|
shutdownWaitMinutes = 15;
|
||||||
shutdownScript = pkgs.writeScript "shutdown" ''
|
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 started
|
||||||
declare finished
|
declare finished
|
||||||
|
|
||||||
started=$(source $f ; echo ''${BACKUP_STARTED})
|
started=$(source $f ; echo ''${BACKUP_STARTED})
|
||||||
finished=$(source $f ; echo ''${BACKUP_FINISHED})
|
finished=$(source $f ; echo ''${BACKUP_FINISHED})
|
||||||
|
|
||||||
if [ -z "''${finished}" ]; then
|
if [ -z "''${finished}" ]; then
|
||||||
echo "backup $(dirname $f) still running"
|
echo "backup $(dirname $f) still running"
|
||||||
running="yes"
|
running="yes"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -n "''${running}" ] && [ "''${running}" = "yes" ]; then
|
if [ -n "''${running}" ] && [ "''${running}" = "yes" ]; then
|
||||||
echo "backups are still running"
|
echo "backups are still running"
|
||||||
exit 1
|
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
|
in
|
||||||
{
|
{
|
||||||
|
@ -43,7 +43,7 @@ in
|
||||||
|
|
||||||
systemd.timers."shutdown-after-backup" = {
|
systemd.timers."shutdown-after-backup" = {
|
||||||
enable = true;
|
enable = true;
|
||||||
serviceConfig = {
|
timerConfig = {
|
||||||
OnCalendar = "3..9:*";
|
OnCalendar = "3..9:*";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue