Selected username

This commit is contained in:
Bob Mottram 2016-02-02 14:01:27 +00:00
parent b1178c2bc8
commit f81489bd74
1 changed files with 12 additions and 7 deletions

View File

@ -110,6 +110,7 @@ DH_KEYLENGTH=
MINIMAL_INSTALL="yes" MINIMAL_INSTALL="yes"
DEFAULT_LANGUAGE='en_GB.UTF-8' DEFAULT_LANGUAGE='en_GB.UTF-8'
ONION_ONLY="no" ONION_ONLY="no"
SELECTED_USERNAME=
# Mirrors settings # Mirrors settings
FRIENDS_MIRRORS_SERVER= FRIENDS_MIRRORS_SERVER=
@ -810,21 +811,21 @@ function interactive_configuration {
exit 62753 exit 62753
fi fi
# when installing from an image which comes with a known default user account # when installing from an image which comes with a known default user account
selected_username= SELECTED_USERNAME=
while [ ! $selected_username ] while [ ! $SELECTED_USERNAME ]
do do
if [ ! $selected_username ]; then if [ ! $SELECTED_USERNAME ]; then
selected_username=$(grep 'MY_USERNAME' temp.cfg | awk -F '=' '{print $2}') SELECTED_USERNAME=$(grep 'MY_USERNAME' temp.cfg | awk -F '=' '{print $2}')
fi fi
data=$(tempfile 2>/dev/null) data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15 trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone Configuration" \ dialog --backtitle $"Freedombone Configuration" \
--title $"Username" \ --title $"Username" \
--inputbox $"Set your username for the system\n\nYour username should not contain any spaces" 12 60 "$selected_username" 2> $data --inputbox $"Set your username for the system\n\nYour username should not contain any spaces" 12 60 "$SELECTED_USERNAME" 2> $data
sel=$? sel=$?
case $sel in case $sel in
0) possible_username=$(cat $data) 0) possible_username=$(cat $data)
selected_username= SELECTED_USERNAME=
if [[ $possible_username != *' '* && $possible_username != *'/'* && $possible_username != *'\'* && $possible_username != *'*'* ]]; then if [[ $possible_username != *' '* && $possible_username != *'/'* && $possible_username != *'\'* && $possible_username != *'*'* ]]; then
if [ $possible_username ]; then if [ $possible_username ]; then
if [ ${#possible_username} -gt 1 ]; then if [ ${#possible_username} -gt 1 ]; then
@ -861,7 +862,11 @@ function interactive_configuration {
MY_USERNAME=$DEFAULT_DOMAIN_NAME MY_USERNAME=$DEFAULT_DOMAIN_NAME
else else
select_user select_user
MY_USERNAME=$SELECTED_USERNAME if [ ! $SELECTED_USERNAME ]; then
echo $'No username selected'
exit 72589
fi
MY_USERNAME="$SELECTED_USERNAME"
fi fi
fi fi
fi fi