aboutsummaryrefslogtreecommitdiffstats
path: root/systemd
diff options
context:
space:
mode:
Diffstat (limited to 'systemd')
-rwxr-xr-xsystemd/pacman-offline51
-rw-r--r--systemd/pacman-offline-done-poweroff.service22
-rw-r--r--systemd/pacman-offline-done-reboot.service22
-rw-r--r--systemd/pacman-offline-prepare.service6
-rw-r--r--systemd/pacman-offline-prepare.timer3
-rw-r--r--systemd/pacman-offline-reboot.service14
-rw-r--r--systemd/pacman-offline-reboot.timer4
-rw-r--r--systemd/pacman-offline.service14
8 files changed, 103 insertions, 33 deletions
diff --git a/systemd/pacman-offline b/systemd/pacman-offline
index 9471bfc..f7ba48a 100755
--- a/systemd/pacman-offline
+++ b/systemd/pacman-offline
@@ -1,6 +1,6 @@
#!/bin/sh
-# (C) 2017-2024 by Christian Hesse <mail@eworm.de>
+# (C) 2017-2025 by Christian Hesse <mail@eworm.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -14,27 +14,54 @@ if [ "$(readlink '/system-update')" != '/var/cache/pacman/pkg' ]; then
exit 0
fi
+# force the proper action on failure, ...
+if [ -e '/run/pacman-offline-poweroff' ]; then
+ ln -sf ../../../usr/lib/systemd/system/poweroff.target \
+ /run/systemd/system/pacman-offline-failure.target
+else
+ ln -sf ../../../usr/lib/systemd/system/reboot.target \
+ /run/systemd/system/pacman-offline-failure.target
+fi
+# ... remove triggering symlink and reboot & poweroff override, ...
+rm --force \
+ /system-update \
+ /run/systemd/system/systemd-poweroff.service \
+ /run/systemd/system/systemd-reboot.service
+# ... and reload
+systemctl daemon-reload
+
# exclude /etc/pacman.d/offline.conf
function finish { rm -f /run/pacman.conf; }
trap finish EXIT
-sed '/^Include *= *\/etc\/pacman\.d\/offline\.conf$/s|^|#|' < /etc/pacman.conf > /run/pacman.conf
-
-# remove triggering symlink and (soft-)reboot override
-rm -f /system-update
-rm -f /run/systemd/system/systemd-reboot.service
+sed \
+ -e '/^Include *= *\/etc\/pacman\.d\/offline\.conf$/s|^|#|' \
+ -e '/^#Include *= *\/etc\/pacman\.d\/offline-include\.conf$/s|^#||' \
+ < /etc/pacman.conf > /run/pacman.conf
# install updates
-if [ "$(pacman --sync --print --needed archlinux-keyring | wc -l)" -gt 0 ]; then
+if [ "$(pacman --sync --print --needed archlinux-keyring | wc -l)" -gt 0 ]; then
pacman --sync --noconfirm archlinux-keyring
fi
pacman --config /run/pacman.conf --sync --noconfirm --sysupgrade
+# clean up config file, drop trap
+rm -f /run/pacman.conf
+trap - EXIT
+
# clean up package cache
pacman --sync --noconfirm --clean
-# reboot
-if [ -s "/usr/lib/modules/$(uname -r)/pkgbase" ] && systemctl --dry-run soft-reboot 2>/dev/null; then
- systemctl soft-reboot
-else
- systemctl reboot
+# sync the storage
+sync
+
+# prepare for soft-reboot via override when applicable
+if [ ! -e '/run/pacman-offline-poweroff' -a \
+ -s "/usr/lib/modules/$(uname -r)/pkgbase" ]; then
+ ln -sf ../../../usr/lib/systemd/system/systemd-soft-reboot.service \
+ /run/systemd/system/systemd-reboot.service
+ systemctl daemon-reload
fi
+
+# All done, just touch a status file and exit successfully!
+# (Soft-)Reboot or Poweroff is done by specific units.
+touch /run/pacman-offline-done
diff --git a/systemd/pacman-offline-done-poweroff.service b/systemd/pacman-offline-done-poweroff.service
new file mode 100644
index 0000000..441daa9
--- /dev/null
+++ b/systemd/pacman-offline-done-poweroff.service
@@ -0,0 +1,22 @@
+# (C) 2017-2025 by Christian Hesse <mail@eworm.de>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+
+[Unit]
+Description=Offline system update with pacman - Poweroff
+Documentation=https://pacman-offline.eworm.de/
+After=pacman-offline.service
+DefaultDependencies=no
+Conflicts=shutdown.target
+Before=shutdown.target system-update.target
+ConditionPathExists=/run/pacman-offline-done
+ConditionPathExists=/run/pacman-offline-poweroff
+SuccessAction=poweroff
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/rm --force /run/pacman-offline-done /run/pacman-offline-poweroff
diff --git a/systemd/pacman-offline-done-reboot.service b/systemd/pacman-offline-done-reboot.service
new file mode 100644
index 0000000..b4e7b48
--- /dev/null
+++ b/systemd/pacman-offline-done-reboot.service
@@ -0,0 +1,22 @@
+# (C) 2017-2025 by Christian Hesse <mail@eworm.de>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+
+[Unit]
+Description=Offline system update with pacman - Reboot
+Documentation=https://pacman-offline.eworm.de/
+After=pacman-offline.service
+DefaultDependencies=no
+Conflicts=shutdown.target
+Before=shutdown.target system-update.target
+ConditionPathExists=/run/pacman-offline-done
+ConditionPathExists=!/run/pacman-offline-poweroff
+SuccessAction=reboot
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/rm --force /run/pacman-offline-done /run/systemd/system/systemd-reboot.service
diff --git a/systemd/pacman-offline-prepare.service b/systemd/pacman-offline-prepare.service
index c9b5ba5..deb746b 100644
--- a/systemd/pacman-offline-prepare.service
+++ b/systemd/pacman-offline-prepare.service
@@ -1,4 +1,4 @@
-# (C) 2017-2024 by Christian Hesse <mail@eworm.de>
+# (C) 2017-2025 by Christian Hesse <mail@eworm.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -7,7 +7,11 @@
[Unit]
Description=Prepare pacman offline system-update
+Documentation=https://pacman-offline.eworm.de/
ConditionPathExists=!/var/lib/pacman/db.lck
+# Synchronizing databases needs network, see https://systemd.io/NETWORK_ONLINE/
+After=network-online.target
+Wants=network-online.target
[Service]
Type=oneshot
diff --git a/systemd/pacman-offline-prepare.timer b/systemd/pacman-offline-prepare.timer
index 598b387..c4a2cdf 100644
--- a/systemd/pacman-offline-prepare.timer
+++ b/systemd/pacman-offline-prepare.timer
@@ -1,4 +1,4 @@
-# (C) 2017-2024 by Christian Hesse <mail@eworm.de>
+# (C) 2017-2025 by Christian Hesse <mail@eworm.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -7,6 +7,7 @@
[Unit]
Description=Prepare pacman offline system-update
+Documentation=https://pacman-offline.eworm.de/
[Timer]
OnBootSec=5min
diff --git a/systemd/pacman-offline-reboot.service b/systemd/pacman-offline-reboot.service
deleted file mode 100644
index 26dca94..0000000
--- a/systemd/pacman-offline-reboot.service
+++ /dev/null
@@ -1,14 +0,0 @@
-# (C) 2017-2024 by Christian Hesse <mail@eworm.de>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-
-[Unit]
-Description=Reboot for pacman offline system-update
-ConditionPathExists=/system-update
-
-[Service]
-Type=oneshot
-ExecStart=/bin/sh -c "if systemctl --dry-run soft-reboot 2>/dev/null; then systemctl soft-reboot; else systemctl reboot; fi"
diff --git a/systemd/pacman-offline-reboot.timer b/systemd/pacman-offline-reboot.timer
index b6852a9..024c9da 100644
--- a/systemd/pacman-offline-reboot.timer
+++ b/systemd/pacman-offline-reboot.timer
@@ -1,4 +1,4 @@
-# (C) 2017-2024 by Christian Hesse <mail@eworm.de>
+# (C) 2017-2025 by Christian Hesse <mail@eworm.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -7,10 +7,12 @@
[Unit]
Description=Reboot for pacman offline system-update
+Documentation=https://pacman-offline.eworm.de/
[Timer]
OnCalendar=03:00:00
RandomizedDelaySec=2hours
+Unit=systemd-reboot.service
[Install]
WantedBy=timers.target
diff --git a/systemd/pacman-offline.service b/systemd/pacman-offline.service
index 516acae..9ce6639 100644
--- a/systemd/pacman-offline.service
+++ b/systemd/pacman-offline.service
@@ -1,4 +1,4 @@
-# (C) 2017-2024 by Christian Hesse <mail@eworm.de>
+# (C) 2017-2025 by Christian Hesse <mail@eworm.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -7,17 +7,23 @@
[Unit]
Description=Offline system update with pacman
+Documentation=https://pacman-offline.eworm.de/
ConditionPathIsSymbolicLink=/system-update
DefaultDependencies=false
Requires=sysinit.target dbus.socket
-After=sysinit.target dbus.socket
-Before=shutdown.target system-update.target
-OnFailure=reboot.target
+Wants=pacman-offline-done-poweroff.service pacman-offline-done-reboot.service
+After=sysinit.target system-update-pre.target dbus.socket
+Before=pacman-offline-done-poweroff.service pacman-offline-done-reboot.service system-update.target
+OnFailure=pacman-offline-failure.target
[Service]
Type=oneshot
+# Pretty print to tty...
StandardOutput=tty
StandardError=tty
+# ... or use this for debugging - less pretty, but with output in journal.
+#StandardOutput=journal+console
+#StandardError=journal+console
ExecStartPre=-/usr/bin/plymouth change-mode --updates
ExecStartPre=-/usr/bin/plymouth system-update --progress=20
ExecStart=/usr/lib/systemd/scripts/pacman-offline