mirror of
https://github.com/RasppleII/a2server.git
synced 2025-02-28 17:29:38 +00:00
Finished porting yes/no questions to askYesNo
Didn't touch the Samba workgroup question for now since it's the only question that asks anything else. Maybe when this stuff gets refactored to remove duplication.
This commit is contained in:
parent
2918a24b45
commit
b3189fe14d
@ -4,16 +4,52 @@
|
||||
# Set up A2SERVER to support Samba (Windows File Sharing)
|
||||
# this script can also be used if new shares are introduced
|
||||
|
||||
function askYesNo()
|
||||
# Ask a yes/no question of the user, with potential default
|
||||
# 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
|
||||
|
||||
case "$2" in
|
||||
0) default="y" ;;
|
||||
1) default="n" ;;
|
||||
*) default="" ;;
|
||||
esac
|
||||
|
||||
if [ -n "$autoAnswerDefault" -a -n "$default" ]; then
|
||||
return $2
|
||||
fi
|
||||
|
||||
if [ -n "$3" ]; then
|
||||
echo
|
||||
echo "$3"
|
||||
echo
|
||||
fi
|
||||
while :; do
|
||||
echo -n "$1 "
|
||||
[ -n "$default" ] && echo -n "[$default] "
|
||||
read
|
||||
case "$REPLY" in
|
||||
[Yy]*) return 0 ;;
|
||||
[Nn]*) return 1 ;;
|
||||
"") [ -n "$default" ] && return $2 ;;
|
||||
*) echo "Please answer yes or no." ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
[[ -f /tmp/a2server-autoAnswerDefault ]] && autoAnswerDefault=1 || autoAnswerDefault=
|
||||
|
||||
if [[ ! $autoAnswerDefault || -f /tmp/a2server-setupWindowsSharing ]]; then
|
||||
|
||||
if [[ ! $autoAnswerDefault ]]; then
|
||||
echo
|
||||
echo -n "Should Windows computers be able to connect to A2SERVER? "
|
||||
read
|
||||
askYesNo "Should Windows computers be able to connect to A2SERVER?" 0
|
||||
fi
|
||||
if [[ $autoAnswerDefault || ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
|
||||
if [ $? -eq 0 ]; then
|
||||
|
||||
echo "A2SERVER: Setting up Windows file sharing..."
|
||||
sudo true
|
||||
|
@ -5,6 +5,43 @@
|
||||
|
||||
# This script helps when running on the Linux console within the VM.
|
||||
|
||||
function askYesNo()
|
||||
# Ask a yes/no question of the user, with potential default
|
||||
# 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
|
||||
|
||||
case "$2" in
|
||||
0) default="y" ;;
|
||||
1) default="n" ;;
|
||||
*) default="" ;;
|
||||
esac
|
||||
|
||||
if [ -n "$autoAnswerDefault" -a -n "$default" ]; then
|
||||
return $2
|
||||
fi
|
||||
|
||||
if [ -n "$3" ]; then
|
||||
echo
|
||||
echo "$3"
|
||||
echo
|
||||
fi
|
||||
while :; do
|
||||
echo -n "$1 "
|
||||
[ -n "$default" ] && echo -n "[$default] "
|
||||
read
|
||||
case "$REPLY" in
|
||||
[Yy]*) return 0 ;;
|
||||
[Nn]*) return 1 ;;
|
||||
"") [ -n "$default" ] && return $2 ;;
|
||||
*) echo "Please answer yes or no." ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
echo
|
||||
|
||||
userPw=$(sudo grep "^$USER" /etc/shadow | cut -f 2 -d ':')
|
||||
@ -42,19 +79,16 @@ if [[ $(lsb_release -d 2> /dev/null | grep Ubuntu) ]]; then
|
||||
|
||||
echo "A2SERVER: Ubuntu console has already been optimized."
|
||||
else
|
||||
echo "Ubuntu console optimization for use in a virtual machine will:"
|
||||
echo "- show the default username/password on the login screen"
|
||||
echo "- remove the documentation URL and system statistics shown after login"
|
||||
echo "- ensure the screen clears before showing the login prompt"
|
||||
echo "- prevent the screen from dimming after 10 minutes (once logged in)"
|
||||
echo "- eliminate a harmless but annoying startup error about piix_smbus"
|
||||
echo "- fix an Ubuntu 10.04 issue with slow scrolling"
|
||||
echo
|
||||
if [[ ! $autoAnswerDefault ]]; then
|
||||
echo -n "Do you want to optimize the Ubuntu console? "
|
||||
read
|
||||
fi
|
||||
if [[ $autoAnswerDefault || ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
|
||||
askYesNo "Do you want to optimize the Ubuntu console?" 0 \
|
||||
"Ubuntu console optimization for use in a virtual machine will:
|
||||
- show the default username/password on the login screen
|
||||
- remove the documentation URL and system statistics shown after login
|
||||
- ensure the screen clears before showing the login prompt
|
||||
- prevent the screen from dimming after 10 minutes (once logged in)
|
||||
- eliminate a harmless but annoying startup error about piix_smbus
|
||||
- fix an Ubuntu 10.04 issue with slow scrolling"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
|
||||
echo "A2SERVER: Optimizing console..."
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user