backup-fs: Attempt to fix input some more

master
BodgeMaster 2023-06-29 14:02:50 +02:00
parent 48f01de830
commit 175ad8e3be
1 changed files with 11 additions and 4 deletions

View File

@ -1,10 +1,17 @@
#!/usr/bin/env bash
# used to work around cases where stdin is unavailable or not a terminal
if bash -c ': > /dev/tty' > /dev/null 2>&1; then
TTY_OR_CONSOLE="/dev/tty"
else
TTY_OR_CONSOLE="/dev/console"
fi
function yesno {
unset DISCARD_ME
while [ -z "$DISCARD_ME" ]; do
# get input from /dev/tty to work around missing stdin
read -p "[y/n] " -n1 DISCARD_ME < /dev/tty
read -p "[y/n] " -n1 DISCARD_ME < $TTY_OR_CONSOLE
case "$DISCARD_ME" in
y)
return 0
@ -25,14 +32,14 @@ function yesno {
cat /proc/mounts
read -p "
press any key" -n1 DISCARD_ME < /dev/tty
press any key" -n1 DISCARD_ME < $TTY_OR_CONSOLE
# And no services running?
ps aux | grep -vF "[kworker"
read -p "
press any key" -n1 DISCARD_ME < /dev/tty
press any key" -n1 DISCARD_ME < $TTY_OR_CONSOLE
#TODO: remove above debugging sanity checks