diff options
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/pacman-offline | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/bin/pacman-offline b/bin/pacman-offline index 28d6a2c..73723af 100755 --- a/bin/pacman-offline +++ b/bin/pacman-offline @@ -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 @@ -117,7 +119,7 @@ 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 @@ -132,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." - exec 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 |