Fix askYesNo function breakage

Paper bag time.  If you redirect stdin and read it, you have no stdin to
answer the question asked.  *facepalm*  What was I thinking?
This commit is contained in:
T. Joseph Carter 2015-10-12 16:56:43 -07:00
parent 3af93d72ae
commit 3bca3a12b4
2 changed files with 45 additions and 52 deletions

View File

@ -29,9 +29,9 @@ adtproDir=$commDir/ADTPRO
function askYesNo()
# Ask a yes/no question of the user, with potential default
# stdin: Info text for the user
# arg1: Prompt text
# arg2: Default; 0 for yes, 1 for no, anything else for no default
# arg3: Info text for the user
# returns: 0 for yes, 1 for no
{
local default
@ -46,9 +46,11 @@ function askYesNo()
return $2
fi
echo
cat -
echo
if [ -n "$3" ]; then
echo
echo "$3"
echo
fi
while :; do
echo -n "$1 "
[ -n "$default" ] && echo -n "[$default] "
@ -66,10 +68,9 @@ function askYesNo()
[[ -f /tmp/a2server-autoAnswerDefault ]] && autoAnswerDefault=1 || autoAnswerDefault=
if [[ ! $autoAnswerDefault || -f /tmp/a2server-setupNetBoot ]]; then
askYesNo "Configure Apple II network boot?" 0 <<EOT
Your Apple II computers can boot directly via the network
if ProDOS and/or GS/OS are installed onto A2SERVER.
EOT
askYesNo "Configure Apple II network boot?" 0 \
"Your Apple II computers can boot directly via the network
if ProDOS and/or GS/OS are installed onto A2SERVER."
if [ $? -eq 0 ]; then
@ -160,12 +161,11 @@ EOT
echo "A2SERVER: GS/OS has already been downloaded and installed."
gsosInstall=1
else
askYesNo "Download and install GS/OS now?" 0 <<EOT
You can opt to download and install GS/OS 6.0.1 now to you
askYesNo "Download and install GS/OS now?" 0 \
"You can opt to download and install GS/OS 6.0.1 now to you
network drive in order to boot GS/OS on Apple IIgs systems.
This may take some time, particularly if you have a slower
network connection.
EOT
network connection."
if [ $? -eq 0 ]; then
gsosInstall=1
@ -258,14 +258,13 @@ EOT
fi
fi
askYesNo "Install GS/OS image/archive tools?" 0 <<EOT
GS/OS tools may be installed for working with disk images
askYesNo "Install GS/OS image/archive tools?" 0 \
"GS/OS tools may be installed for working with disk images
and Apple II archives. At the moment, these include:
- Asimov 2.0
- GS-ShrinkIt 1.1
- MountIt 1.4
EOT
- MountIt 1.4"
if [ $? -eq 0 ]; then
@ -318,14 +317,13 @@ EOT
fi
fi
askYesNo "Install ProDOS image/archive tools?" 0 <<EOT
ProDOS tools may be installed for working with disk images
askYesNo "Install ProDOS image/archive tools?" 0 \
"ProDOS tools may be installed for working with disk images
and Apple II archives. At the moment, these include:
- ShrinkIt 3.4
- DSK2FILE 5.8
- Apple System Utilities 3.1
EOT
- Apple System Utilities 3.1"
if [ $? -eq 0 ]; then
@ -380,8 +378,8 @@ EOT
fi
askYesNo "Install communications software?" 0 <<EOT
Serial communications software (a terminal program) allows
askYesNo "Install communications software?" 0 \
"Serial communications software (a terminal program) allows
you to connect to A2CLOUD, use analog modems for dialup BBS
access, and otherwise interactively use a serial port on
your Apple II. In addition, Spectrum for the IIgs can also
@ -390,8 +388,8 @@ install:
- Spectrum 2.53
- ProTERM 3.1
- Z-Link
EOT
- Z-Link"
if [ $? -eq 0 ]; then
echo "A2SERVER: Downloading communications software..."
@ -468,15 +466,13 @@ EOT
fi
askYesNo "Download and patch GS/OS for the Farallon bridge?" 0 <<EOT
There is a bug between the Farallon LocalTalk-to-Ethernet bridge
askYesNo "Download and patch GS/OS for the Farallon bridge?" 0 \
"There is a bug between the Farallon LocalTalk-to-Ethernet bridge
and the Apple IIgs which causes the system to freeze. GS/OS can
be patched to work around the issue, but the bug will persist if
you boot directly into ProDOS 8 on a IIgs. Apple IIe users are
not affected by this bug at all.
EOT
not affected by this bug at all."
if [ $? -eq 0 ]; then
if [[ $autoAnswerDefault || ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
echo "A2SERVER: Downloading Farallon bridge patch..."
wget -O /tmp/FARALLON.PO "http://appleii.ivanx.com/a2server/files/FARALLON.B1.PO" &> /dev/null
if [[ -d $gsosDir/SYSTEM/SYSTEM.SETUP ]]; then

View File

@ -13,9 +13,9 @@ a2serverVersion="125"
function askYesNo()
# Ask a yes/no question of the user, with potential default
# stdin: Info text for the user
# arg1: Prompt text
# arg2: Default; 0 for yes, 1 for no, anything else for no default
# arg3: Info text for the user
# returns: 0 for yes, 1 for no
{
local default
@ -30,9 +30,11 @@ function askYesNo()
return $2
fi
echo
cat -
echo
if [ -n "$3" ]; then
echo
echo "$3"
echo
fi
while :; do
echo -n "$1 "
[ -n "$default" ] && echo -n "[$default] "
@ -149,19 +151,17 @@ fi
doSetup=1
if [[ ! -f /usr/local/etc/a2server-help.txt ]] || (( $a2server_update )); then
askYesNo "Ready to set up A2SERVER?" 0 <<EOT
Setting up A2SERVER will take up to 60 minutes, during which
you'll see a bunch of stuff spit out across the screen.
EOT
askYesNo "Ready to set up A2SERVER?" 0 \
"Setting up A2SERVER will take up to 60 minutes, during which
you'll see a bunch of stuff spit out across the screen."
doSetup=$(( 1 - $? ))
fi
if (( $doSetup )); then
askYesNo "Continue?" 0 <<EOT
a2server-setup modifies files and performs actions as the root user.
For details, visit http://appleii.ivanx.com/a2server.
EOT
askYesNo "Continue?" 0 \
"a2server-setup modifies files and performs actions as the root user.
For details, visit http://appleii.ivanx.com/a2server."
doSetup=$(( 1 - $? ))
if (( $doSetup )); then
@ -177,11 +177,10 @@ EOT
[[ $isRpi ]] && a2server="your Raspberry Pi" || a2server="A2SERVER"
if [[ ! $isApple2Pw && ! -f /usr/local/etc/A2SERVER-version ]]; then
askYesNo "Do you want to change the password for user \"$USER\" to \"apple2\" now?" 0 <<EOT
To ensure that all client computers are able to connect to
askYesNo "Do you want to change the password for user \"$USER\" to \"apple2\" now?" 0 \
"To ensure that all client computers are able to connect to
${a2server} using the same password, you are recommended
to change your user password to "apple2".
EOT
to change your user password to \"apple2\"."
if [ $? -eq 0 ]; then
echo "A2SERVER: changing password for user '$USER' to 'apple2'..."
echo "$USER:apple2" | sudo chpasswd
@ -254,10 +253,9 @@ EOT
echo "A2SERVER setup is complete! Go connect from your Apple II!"
echo
elif [[ -f /tmp/rpiUpdate ]]; then
askYesNo "Restart now?" 0 <<EOT
A2SERVER is now configured, but Apple II clients will not be able
to connect until you restart your Raspberry Pi.
EOT
askYesNo "Restart now?" 0 \
"A2SERVER is now configured, but Apple II clients will not be able
to connect until you restart your Raspberry Pi."
if [ $? -eq 0 ]; then
sudo shutdown -r now
echo
@ -284,9 +282,8 @@ EOT
fi
if [[ -f /tmp/singleUser ]]; then
askYesNo "Restart now?" 0 <<EOT
Your Raspberry Pi was started in single-user mode in order tofix a problem. You should restart to operate normally.
EOT
askYesNo "Restart now?" 0 \
"Your Raspberry Pi was started in single-user mode in order tofix a problem. You should restart to operate normally."
if [ $? -eq 0 ]; then
sudo shutdown -r now
echo