diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-26 11:44:59 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-26 11:44:59 +0200 |
| commit | 1ea812660c92e768a93af5e2f3e1ef20ac1e2500 (patch) | |
| tree | 55d9d5830049115edd0cf89f99be72ed57472e52 | |
| parent | 5886c8d4919f7b8902f3eeb8fd3ea26a83033d13 (diff) | |
| download | dist-upgrade-1ea812660c92e768a93af5e2f3e1ef20ac1e2500.tar.gz dist-upgrade-1ea812660c92e768a93af5e2f3e1ef20ac1e2500.zip | |
exec > >(tee ...) sent slackpkg's TUI (dialog writes to stderr) into the
log pipe, so the curses interface never reached the terminal and output
was mangled. Only tee non-interactive runs now; interactive runs skip
logging and keep fds 0/1/2 on the tty. Add an INT trap so Ctrl+C aborts
with 130 instead of letting the run continue.
| -rw-r--r-- | README.md | 8 | ||||
| -rwxr-xr-x | dist-upgrade | 13 |
2 files changed, 13 insertions, 8 deletions
@@ -22,7 +22,7 @@ Options: Environment: - `INITRD` initrd to inspect (default `/boot/initrd-generic.img`) -- `LOG` append the whole run, slackpkg output included, to this file +- `LOG` append the non-interactive run, slackpkg output included, to this file (default `/var/log/dist-upgrade.log`; set it empty to disable) A logrotate rule for that log ships in `logrotate.d/dist-upgrade`; install it @@ -41,8 +41,10 @@ to `/etc/logrotate.d/`. 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. +A non-interactive run is appended to `LOG`, with a timestamped header per run, +so an unattended upgrade can be reviewed afterwards. Interactive runs are not +logged: slackpkg's TUI needs the terminal, and redirecting it through the log +breaks the curses interface. 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 0b2f7a1..a71d224 100755 --- a/dist-upgrade +++ b/dist-upgrade @@ -46,8 +46,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) + LOG append non-interactive run output here (default + /var/log/dist-upgrade.log; set empty to disable) EOF } @@ -142,16 +142,18 @@ run_step() { setup_log() { [ -n "$LOG" ] || return 0 + if [ "$INTERACTIVE" -eq 1 ]; then + info "interactive run: not logging (slackpkg's TUI needs the terminal)" + return 0 + fi 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 'mode: non-interactive\n' printf 'args:%s\n' "$(printf ' %s' "${ORIG_ARGS[@]}")" } >> "$LOG" exec > >(tee -a "$LOG") 2>&1 @@ -299,6 +301,7 @@ setup_log TMPDIR_SNAP=$(mktemp -d) || die "mktemp failed" trap 'rm -rf "$TMPDIR_SNAP"' EXIT +trap 'exit 130' INT snapshot_initrd |
