aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-26 10:10:25 +0200
committerDanilo M. <danix@danix.xyz>2026-09-26 10:10:25 +0200
commit7b07552c1e0fe5798c993b1c8cd54b0465921f34 (patch)
tree8974144ce4a2ddcb00a17b43b02ae1ebdcde45c1
parent83b30e4076356e7a2a104e7f67f727c792699107 (diff)
downloaddist-upgrade-7b07552c1e0fe5798c993b1c8cd54b0465921f34.tar.gz
dist-upgrade-7b07552c1e0fe5798c993b1c8cd54b0465921f34.zip
Append run output to a log and list leftover .new configs
Non-interactive runs leave obsolete .new config files in place: new-config exits without acting and there was no record to debug later. Tee the whole run (script messages plus slackpkg output) to LOG, default /var/log/dist-upgrade.log, with a timestamped header per run (a second one on a 50-restart). LOG= disables it. Also report leftover .new files under /etc and /boot at the end of a run.
-rw-r--r--README.md8
-rwxr-xr-xdist-upgrade33
2 files changed, 40 insertions, 1 deletions
diff --git a/README.md b/README.md
index 941808c..63e35b3 100644
--- a/README.md
+++ b/README.md
@@ -22,6 +22,8 @@ Options:
Environment:
- `INITRD` initrd to inspect (default `/boot/initrd-generic.img`)
+- `LOG` append the whole run, slackpkg output included, to this file
+ (default `/var/log/dist-upgrade.log`; set it empty to disable)
## What it does
@@ -33,7 +35,11 @@ Environment:
- the modules `mkinitrd_command_generator.sh` says are needed against the
initrd's contents,
- the module set against the pre-upgrade snapshot (notices modules lost).
-4. Reports whether a reboot is recommended.
+4. Lists any leftover `.new` config files.
+5. Reports whether a reboot is recommended.
+
+The full run is appended to `LOG`, with a timestamped header per run, so an
+unattended upgrade can be reviewed afterwards.
If slackpkg upgrades itself mid-run (exit status 50) the script re-executes
once from the top to finish the operation, exactly as slackpkg's own message
diff --git a/dist-upgrade b/dist-upgrade
index 39b40a8..57594ed 100755
--- a/dist-upgrade
+++ b/dist-upgrade
@@ -19,6 +19,7 @@ export LC_ALL=C
INITRD=${INITRD:-/boot/initrd-generic.img}
MKINITRD_GEN=/usr/share/mkinitrd/mkinitrd_command_generator.sh
+LOG=${LOG-/var/log/dist-upgrade.log}
INTERACTIVE=0
TMPDIR_SNAP=""
@@ -44,6 +45,8 @@ to boot.
Environment:
INITRD initrd to inspect (default /boot/initrd-generic.img)
+ LOG append run output here (default /var/log/dist-upgrade.log;
+ set empty to disable)
EOF
}
@@ -136,6 +139,32 @@ run_step() {
handle_rc "$cmd" $?
}
+setup_log() {
+ [ -n "$LOG" ] || return 0
+ if ! : >> "$LOG" 2>/dev/null; then
+ warn "cannot write log $LOG, continuing without logging"
+ LOG=""
+ return 0
+ fi
+ local mode=non-interactive
+ [ "$INTERACTIVE" -eq 1 ] && mode=interactive
+ {
+ printf '\n===== dist-upgrade %s =====\n' "$(date '+%Y-%m-%d %H:%M:%S')"
+ printf 'mode: %s\n' "$mode"
+ printf 'args:%s\n' "$(printf ' %s' "${ORIG_ARGS[@]}")"
+ } >> "$LOG"
+ exec > >(tee -a "$LOG") 2>&1
+}
+
+# ponytail: only /etc and /boot are scanned for .new files; other paths are not
+report_leftovers() {
+ local found
+ found=$(find /etc /boot -name '*.new' 2>/dev/null | sort)
+ [ -n "$found" ] || return 0
+ info "Leftover .new config files (review, then adopt or delete):"
+ printf '%s\n' "$found"
+}
+
snapshot_initrd() {
if [ ! -e "$INITRD" ] && [ ! -L "$INITRD" ]; then
info "snapshot: no initrd at $INITRD, skipping initrd checks."
@@ -265,6 +294,8 @@ done
[ "$(id -u)" -eq 0 ] || die "must be run as root"
+setup_log
+
TMPDIR_SNAP=$(mktemp -d) || die "mktemp failed"
trap 'rm -rf "$TMPDIR_SNAP"' EXIT
@@ -284,6 +315,8 @@ run_step new-config
check_initrd
+report_leftovers
+
running=$(uname -r)
newver=$(newest_kernel)
if [ -n "$newver" ] && [ "$running" != "$newver" ]; then