Add new user to sudoers and remove generic image user from sudoers
This commit is contained in:
parent
a860fb6129
commit
a58766dc10
|
@ -691,12 +691,20 @@ function interactive_configuration {
|
|||
if [[ $possible_username != $GENERIC_IMAGE_USERNAME ]]; then
|
||||
MY_USERNAME=$(cat $data)
|
||||
useradd -m -s /bin/bash $MY_USERNAME
|
||||
if [ -d /home/$MY_USERNAME ]; then
|
||||
echo "${MY_USERNAME}:$(printf `cat $IMAGE_PASSWORD_FILE`)" | chpasswd
|
||||
# Add the user as a sudoer - they will be the new admin user
|
||||
if ! grep -q "$MY_USERNAME ALL=(ALL) ALL" /etc/sudoers; then
|
||||
echo "$MY_USERNAME ALL=(ALL) ALL" >> /etc/sudoers
|
||||
# remove the generic image admin user from sudoers
|
||||
sed -i "s|${GENERIC_IMAGE_USERNAME}.*||g" /etc/sudoers
|
||||
fi
|
||||
break
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
1) exit 1;;
|
||||
255) exit 1;;
|
||||
|
|
Loading…
Reference in New Issue