From a575eafb661ac7e38df010e4d747bcd5250b563f Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Thu, 16 Jul 2026 16:20:17 +0200 Subject: [PATCH] system-image: implement auto confirm / reject feature This is intended for use in server environments, in the installer, and any situation where you don't want a prompt on the TTY at shutdown/reboot. --- usr/local/sbin/system-image | 55 +++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/usr/local/sbin/system-image b/usr/local/sbin/system-image index 32330fb..9136587 100644 --- a/usr/local/sbin/system-image +++ b/usr/local/sbin/system-image @@ -16,7 +16,15 @@ function echo_tty { fi } +AUTO_CONFIRM="false" +AUTO_REJECT="false" function yesno { + if "$AUTO_CONFIRM"; then + return 0 + fi + if "$AUTO_REJECT"; then + return 1 + fi unset DISCARD_ME while [ -z "$DISCARD_ME" ]; do echo_tty -n "[y/n] " @@ -43,27 +51,36 @@ function yesno { #TODO: refuse to run if system is running if [ "$1" = "--yes" ]; then - DONT_ASK="true" + AUTO_CONFIRM="true" else - DONT_ASK="false" - - #TODO: use a bright color for ==== and the question - echo_tty "==========================" - echo_tty "Create a new system image?" - echo_tty "==========================" - echo_tty - echo_tty "This will replace the existing system image with a snapshot of the currently" - echo_tty "running system. Choosing no here will discard any newly installed programs," - echo_tty "updates, system configuration changes, etc." - echo_tty - echo_tty "This should not affect your files in /home as they are stored to disk directly." - echo_tty "Check /TODO/README.txt for more information." - echo_tty - echo_tty "Creating a new system image will take some time." - echo_tty + if [ -e "/run/void-usb/system-image-auto-confirm-marker" ]; then + AUTO_CONFIRM="true" + else + if [ -e "/run/void-usb/system-image-auto-reject-marker" ]; then + AUTO_REJECT="true" + else + #TODO: use a bright color for ==== and the question + echo_tty "==========================" + echo_tty "Create a new system image?" + echo_tty "==========================" + echo_tty + echo_tty "This will replace the existing system image with a snapshot of the currently" + echo_tty "running system. Choosing no here will discard any newly installed programs," + echo_tty "updates, system configuration changes, etc." + echo_tty + echo_tty "This should not affect your files in /home as they are stored to disk directly." + echo_tty "Check /TODO/README.txt for more information." + echo_tty + echo_tty "Creating a new system image will take some time." + echo_tty + fi + fi fi -if $DONT_ASK || yesno; then +if yesno; then + echo_tty "==========================" + echo_tty "Building new system image." + echo_tty "==========================" echo_tty -n "Generating exclusion list... " # cutting off the leading slash allows us to just ignore empty lines below readarray -t MOUNT_LIST <<< "$(findmnt --output TARGET --noheadings --raw | sed -e 's|^/||' | sort)" @@ -107,7 +124,9 @@ if $DONT_ASK || yesno; then echo_tty "done" fi else + echo_tty "==========================" echo_tty "Discarding system changes." + echo_tty "==========================" fi echo_tty -n "Syncing... "