From 653d6f2dece775f5d5f3de4b4335ce63e92be329 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 29 Nov 2015 13:20:26 +0000 Subject: [PATCH] Fixed username and password when generic images are created --- src/freedombone-config | 14 +++++++------- src/freedombone-image | 9 +++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/freedombone-config b/src/freedombone-config index 4607ed06..82bfd1fe 100755 --- a/src/freedombone-config +++ b/src/freedombone-config @@ -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" @@ -475,9 +475,9 @@ function interactive_gpg { esac case $(cat $data) in 1) if [ -d /home/$MY_USERNAME/.gnupg ]; then - rm -rf /home/$MY_USERNAME/.gnupg - fi - break;; + rm -rf /home/$MY_USERNAME/.gnupg + fi + break;; 2) interactive_gpg_from_usb break;; 3) interactive_gpg_from_remote @@ -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 diff --git a/src/freedombone-image b/src/freedombone-image index a154a3f1..96137a28 100755 --- a/src/freedombone-image +++ b/src/freedombone-image @@ -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)"