Fixed username and password when generic images are created

This commit is contained in:
Bob Mottram 2015-11-29 13:20:26 +00:00
parent 39e2d67984
commit 653d6f2dec
2 changed files with 16 additions and 7 deletions

View File

@ -34,7 +34,7 @@ NO_OF_ARGS=$#
PROJECT_NAME='freedombone'
# username created by default within a debian image
DEFAULT_IMAGE_USERNAME='fbone'
GENERIC_IMAGE_USERNAME='fbone'
export TEXTDOMAIN=${PROJECT_NAME}-config
export TEXTDOMAINDIR="/usr/share/locale"
@ -653,7 +653,7 @@ function interactive_configuration {
fi
fi
if [ -d /home/$DEFAULT_IMAGE_USERNAME ]; then
if [ -d /home/$GENERIC_IMAGE_USERNAME ]; then
# when installing from an image which comes with a known default user account
selected_username=
while [ ! $selected_username ]
@ -673,9 +673,9 @@ function interactive_configuration {
if [[ $possible_username != *' '* && $possible_username != *'/'* && $possible_username != *'\'* && $possible_username != *'*'* ]]; then
if [ $possible_username ]; then
if [ ${#possible_username} -gt 1 ]; then
if [[ $possible_username != $DEFAULT_IMAGE_USERNAME ]]; then
if [[ $possible_username != $GENERIC_IMAGE_USERNAME ]]; then
MY_USERNAME=$(cat $data)
usermod -l $MY_USERNAME $DEFAULT_IMAGE_USERNAME
usermod -l $MY_USERNAME $GENERIC_IMAGE_USERNAME
usermod -d /home/$MY_USERNAME -m $MY_USERNAME
break
fi

View File

@ -33,6 +33,10 @@ PROJECT_NAME='freedombone'
export TEXTDOMAIN=${PROJECT_NAME}-image
export TEXTDOMAINDIR="/usr/share/locale"
# fixed username and password when the --generic option is used
GENERIC_IMAGE_USERNAME='fbone'
GENERIC_IMAGE_PASSWORD='freedombone'
IMAGE_TYPE='beaglebone'
CURR_DIR=$(pwd)
CURR_USER=$(echo $USER)
@ -156,6 +160,11 @@ if [[ $INTERACTIVE == "yes" || $INTERACTIVE == "y" || $INTERACTIVE == "Yes" ]];
fi
fi
if [[ $GENERIC_IMAGE == "yes" ]]; then
USERNAME=$GENERIC_IMAGE_USERNAME
PASSWORD=$GENERIC_IMAGE_PASSWORD
fi
if [ ! $PASSWORD ]; then
# generate a random password
PASSWORD="$(openssl rand -base64 10 | cut -c1-8)"