File tree Expand file tree Collapse file tree
src/modules/admin-toolkit Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313######### User Required Section ###########################
1414#
1515# Adding another user requires at least a username.
16+ # If the user already exists, it will not be recreated,
17+ # but the password and ssh keys will be changed.
1618# A home folder will be created.
1719# The default profile will be set to bash.
1820# Default password is raspberry. PLEASE CHANGE THIS.
1921# User will be added to the sudo and adm group.
2022#
23+ # If the user specified is not pi, pi's password will be
24+ # set to a randomly generated string.
25+ #
2126###########################################################
2227
2328# add user name, If left "default", no user will be added.
Original file line number Diff line number Diff line change @@ -18,22 +18,26 @@ install_cleanup_trap
1818if [ " $ADMIN_TOOLKIT_NAME " != " default" ]
1919then
2020
21- # add user
21+ # add user if it doesn't already exist
2222 if [ " $ADMIN_TOOLKIT_FULLNAME " != " default" ]
2323 then
2424 echo " Adding user $ADMIN_TOOLKIT_NAME with GECOS fields"
25- useradd -m -s $( which bash) -G sudo,adm " ${ADMIN_TOOLKIT_NAME} " -c " ${ADMIN_TOOLKIT_FULLNAME} "
25+ id " ${ADMIN_TOOLKIT_NAME} " || useradd -m -s $( which bash) -G sudo,adm " ${ADMIN_TOOLKIT_NAME} " -c " ${ADMIN_TOOLKIT_FULLNAME} "
2626 else
2727 echo " Adding user $ADMIN_TOOLKIT_NAME "
28- useradd -m -s $( which bash) -G sudo,adm " ${ADMIN_TOOLKIT_NAME} "
28+ id " ${ADMIN_TOOLKIT_NAME} " || useradd -m -s $( which bash) -G sudo,adm " ${ADMIN_TOOLKIT_NAME} "
2929 fi
3030
3131 # check for override password
3232 if [ " $ADMIN_TOOLKIT_PASSWORD " != " default" ]
3333 then
3434 echo " ${ADMIN_TOOLKIT_NAME} :${ADMIN_TOOLKIT_PASSWORD} " | chpasswd
35- RANDOM_PW=$( date +%s | sha256sum | base64 | head -c 32)
36- echo " pi:${RANDOM_PW} " | chpasswd
35+ # if creating a user other than 'pi', set pi's password to a random string
36+ if [ " ${ADMIN_TOOLKIT_NAME} " != " pi" ]
37+ then
38+ RANDOM_PW=$( date +%s | sha256sum | base64 | head -c 32)
39+ echo " pi:${RANDOM_PW} " | chpasswd
40+ fi
3741 else
3842 echo " ${ADMIN_TOOLKIT_NAME} :raspberry" | chpasswd
3943 fi
You can’t perform that action at this time.
0 commit comments