diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/pacman-offline | 66 |
1 files changed, 39 insertions, 27 deletions
diff --git a/bin/pacman-offline b/bin/pacman-offline index cb46cb4..73723af 100755 --- a/bin/pacman-offline +++ b/bin/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 @@ -10,16 +10,18 @@ set -e function help() { - echo "usage: ${0} [OPTIONS]" - echo - echo ' -a abort pending system-update' - echo ' -c clean before download' - echo ' -f force if other system-update is pending' - echo ' -h this help' - echo ' -p reboot, install and poweroff immediately' - echo ' -r reboot and install immediately' - echo ' -t start timer for nightly reboot' - echo ' -y update sync databases' + cat <<-EOM + usage: ${0} [OPTIONS] + + -a abort pending system-update + -c clean before download + -f force if other system-update is pending + -h this help + -p reboot, install and poweroff immediately + -r reboot and install immediately + -t start timer for nightly reboot + -y update sync databases + EOM } CLEAN=0 @@ -107,14 +109,17 @@ fi # 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 +sed \ + -e '/^Include *= *\/etc\/pacman\.d\/offline\.conf$/s|^|#|' \ + -e '/^#Include *= *\/etc\/pacman\.d\/offline-include\.conf$/s|^#||' \ + < /etc/pacman.conf > /run/pacman.conf # remove the symlink for now, will be recreated it later rm -f /system-update # check for available updates if [ "$(pacman --config /run/pacman.conf --sync --sysupgrade --print | wc -l)" -eq 0 ]; then - echo "No updates available." + echo 'No updates available.' exit 0 fi @@ -129,32 +134,39 @@ pacman --config /run/pacman.conf --sync --noconfirm --sysupgrade --downloadonly # enable system update ln -sf /var/cache/pacman/pkg /system-update if [ ${POWEROFF} -eq 1 ]; then - touch /run/system-update-poweroff + touch /run/pacman-offline-poweroff fi -# (soft-)reboot if requested -if [ ${REBOOT} -eq 1 ]; then - echo "Soft-rebooting for update." - systemctl soft-reboot -else - # force a soft-reboot on (manual) reboot ... - ln -sf ../../../usr/lib/systemd/system/systemd-soft-reboot.service /run/systemd/system/systemd-reboot.service +# force a soft-reboot on (manual) reboot ... +ln -sf ../../../usr/lib/systemd/system/systemd-soft-reboot.service \ + /run/systemd/system/systemd-reboot.service - # ... and also on poweroff, but prepare poweroff - cp /usr/lib/systemd/system/systemd-soft-reboot.service /run/systemd/system/systemd-poweroff.service - cat >> /run/systemd/system/systemd-poweroff.service <<-EOF +# ... and also on poweroff, but prepare poweroff +cp /usr/lib/systemd/system/systemd-soft-reboot.service \ + /run/systemd/system/systemd-poweroff.service +cat >> /run/systemd/system/systemd-poweroff.service <<-EOF [Service] - ExecStart=/usr/bin/touch /run/system-update-poweroff + ExecStart=/usr/bin/touch /run/pacman-offline-poweroff EOF - systemctl daemon-reload +# reload for service changes +systemctl daemon-reload + +# (soft-)reboot if requested +if [ ${REBOOT} -eq 1 ]; then + echo 'Rebooting for update.' + exec systemctl reboot fi +echo 'Updates will be installed on next reboot.' + # start timer if requested if [ ${TIMER} -eq 1 ]; then systemctl start pacman-offline-reboot.timer fi # show the timer (if active) -systemctl --quiet --no-pager list-timers pacman-offline-prepare.timer pacman-offline-reboot.timer +systemctl --quiet --no-pager list-timers \ + pacman-offline-prepare.timer \ + pacman-offline-reboot.timer |