system-image: allow for running non-interactively using --yes

master
BodgeMaster 2023-07-21 18:59:27 +02:00
parent ba95ba6294
commit 600bd0a7f5
2 changed files with 19 additions and 15 deletions

View File

@ -460,7 +460,6 @@ The installer will now create a system image and reboot the computer.
press_any_key press_any_key
echo "Creating system image..." echo "Creating system image..."
#TODO: make this work without user interaction run_in_target /opt/void-usb/system-image --yes
run_in_target /opt/void-usb/system-image
reboot reboot
# #

View File

@ -39,22 +39,27 @@ function yesno {
#TODO: refuse to run if system is running #TODO: refuse to run if system is running
#TODO: add a way to force a new system image without asking (for example a file in /run/void-usb) if [ "$1" = "--yes" ]; then
DONT_ASK="true"
else
DONT_ASK="false"
echo_tty "Create a new system image?"
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
#TODO: colors (bright white / light gray for readability) #TODO: colors (bright white / light gray for readability)
echo_tty "Create a new system image?
This will replace the existing system image with a snapshot of the currently if $DONT_ASK || yesno; then
running system. Choosing no here will discard any newly installed programs,
updates, system configuration changes, etc.
This should not affect your files in /home as they are stored to disk directly.
Check /TODO/README.txt for more information.
Creating a new system image will take some time.
"
if yesno; then
echo_tty -n "Generating exclusion list... " echo_tty -n "Generating exclusion list... "
# cutting off the leading slash allows us to just ignore empty lines below # 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)" readarray -t MOUNT_LIST <<< "$(findmnt --output TARGET --noheadings --raw | sed -e 's|^/||' | sort)"