aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-05-28 16:50:37 +0200
committerGravatar Christian Hesse <mail@eworm.de>2024-05-29 09:23:49 +0200
commitb1e3a9fc3d3b1b8111cca1a134861a7da8f917d0 (patch)
treed3b0ed5ba04f2f79fc3ad7a5f7b689734447a48f
parent3686c619c00b04e4104565532bbad2e76c8fab2c (diff)
downloadpacman-offline-b1e3a9fc3d3b1b8111cca1a134861a7da8f917d0.tar.gz
pacman-offline-b1e3a9fc3d3b1b8111cca1a134861a7da8f917d0.tar.zst
support poweroff after update
-rw-r--r--README.md1
-rwxr-xr-xbin/pacman-offline13
-rwxr-xr-xsystemd/pacman-offline6
3 files changed, 16 insertions, 4 deletions
diff --git a/README.md b/README.md
index 3f10fa9..7f7b3c1 100644
--- a/README.md
+++ b/README.md
@@ -29,6 +29,7 @@ It accepts some arguments:
* *-c*: clean before download
* *-f*: force if other system-update is pending
* *-h*: show help
+* *-p*: reboot, install and poweroff immediately
* *-r*: reboot and install immediately
* *-t*: start timer for nightly reboot
* *-y*: update sync databases
diff --git a/bin/pacman-offline b/bin/pacman-offline
index 7ca2d25..edb608f 100755
--- a/bin/pacman-offline
+++ b/bin/pacman-offline
@@ -15,16 +15,18 @@ function help() {
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'
}
CLEAN=0
+POWEROFF=0
REBOOT=0
TIMER=0
-while getopts 'cfhrty' opt; do
+while getopts 'cfhprty' opt; do
case ${opt} in
h)
help
@@ -44,7 +46,7 @@ if [ "${UID}" -ne 0 ]; then
fi
OPTIND=1
-while getopts 'cfhrty' opt; do
+while getopts 'cfhprty' opt; do
case ${opt} in
c)
if pacman-conf 'CleanMethod' | grep -q 'KeepCurrent'; then
@@ -56,6 +58,10 @@ while getopts 'cfhrty' opt; do
f)
rm -f /system-update
;;
+ p)
+ POWEROFF=1
+ REBOOT=1
+ ;;
r)
REBOOT=1
;;
@@ -98,6 +104,9 @@ 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
+fi
# (soft-)reboot if requested
if [ ${REBOOT} -eq 1 ]; then
diff --git a/systemd/pacman-offline b/systemd/pacman-offline
index bacf696..83d2791 100755
--- a/systemd/pacman-offline
+++ b/systemd/pacman-offline
@@ -32,8 +32,10 @@ pacman --config /run/pacman.conf --sync --noconfirm --sysupgrade
# clean up package cache
pacman --sync --noconfirm --clean
-# (soft-)reboot
-if [ -s "/usr/lib/modules/$(uname -r)/pkgbase" ]; then
+# poweroff or (soft-)reboot
+if [ -e '/run/system-update-poweroff' ]; then
+ systemctl poweroff
+elif [ -s "/usr/lib/modules/$(uname -r)/pkgbase" ]; then
systemctl soft-reboot
else
systemctl reboot