diff --git a/README.md b/README.md index 4e283ab..cf568a5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # arch-linux-update-and-restart -A systemd unit to auto-update Arch Linux and do a restart when updated libs or kernel remain in use. \ No newline at end of file +A systemd unit to auto-update Arch Linux and do a restart when updated libs or kernel remain in use. + +Requires https://quico.space/quico-os-setup/arch-needs-restart. diff --git a/arch-linux-update-and-restart.service b/arch-linux-update-and-restart.service new file mode 100644 index 0000000..7c0fb6d --- /dev/null +++ b/arch-linux-update-and-restart.service @@ -0,0 +1,13 @@ +[Unit] +Description=Update and restart OS +Requires=network.target +After=network.target + +[Service] +Type=oneshot +IgnoreSIGPIPE=no +ExecStart=/usr/bin/paru -Syu --noconfirm +ExecStartPost=/bin/bash -c '/usr/local/bin/arch-needs-restart | grep -Piq '"'"'# [^:]+: reboot required'"'"' && reboot || true' + +[Install] +WantedBy=multi-user.target diff --git a/arch-linux-update-and-restart.timer b/arch-linux-update-and-restart.timer new file mode 100644 index 0000000..047e3b3 --- /dev/null +++ b/arch-linux-update-and-restart.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Update and restart OS + +[Timer] +OnCalendar=*-*-* 03:00:00 +RandomizedDelaySec=1h + +[Install] +WantedBy=multi-user.target