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.master
parent
fac6679f4e
commit
a575eafb66
|
|
@ -16,7 +16,15 @@ function echo_tty {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AUTO_CONFIRM="false"
|
||||||
|
AUTO_REJECT="false"
|
||||||
function yesno {
|
function yesno {
|
||||||
|
if "$AUTO_CONFIRM"; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
if "$AUTO_REJECT"; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
unset DISCARD_ME
|
unset DISCARD_ME
|
||||||
while [ -z "$DISCARD_ME" ]; do
|
while [ -z "$DISCARD_ME" ]; do
|
||||||
echo_tty -n "[y/n] "
|
echo_tty -n "[y/n] "
|
||||||
|
|
@ -43,10 +51,14 @@ function yesno {
|
||||||
#TODO: refuse to run if system is running
|
#TODO: refuse to run if system is running
|
||||||
|
|
||||||
if [ "$1" = "--yes" ]; then
|
if [ "$1" = "--yes" ]; then
|
||||||
DONT_ASK="true"
|
AUTO_CONFIRM="true"
|
||||||
|
else
|
||||||
|
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
|
else
|
||||||
DONT_ASK="false"
|
|
||||||
|
|
||||||
#TODO: use a bright color for ==== and the question
|
#TODO: use a bright color for ==== and the question
|
||||||
echo_tty "=========================="
|
echo_tty "=========================="
|
||||||
echo_tty "Create a new system image?"
|
echo_tty "Create a new system image?"
|
||||||
|
|
@ -62,8 +74,13 @@ else
|
||||||
echo_tty "Creating a new system image will take some time."
|
echo_tty "Creating a new system image will take some time."
|
||||||
echo_tty
|
echo_tty
|
||||||
fi
|
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... "
|
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)"
|
||||||
|
|
@ -107,7 +124,9 @@ if $DONT_ASK || yesno; then
|
||||||
echo_tty "done"
|
echo_tty "done"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
echo_tty "=========================="
|
||||||
echo_tty "Discarding system changes."
|
echo_tty "Discarding system changes."
|
||||||
|
echo_tty "=========================="
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo_tty -n "Syncing... "
|
echo_tty -n "Syncing... "
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue