Parcourir la source

Add new user to sudoers and remove generic image user from sudoers

Bob Mottram il y a 9 ans
Parent
révision
a58766dc10
1 fichiers modifiés avec 10 ajouts et 2 suppressions
  1. 10
    2
      src/freedombone-config

+ 10
- 2
src/freedombone-config Voir le fichier

@@ -691,8 +691,16 @@ function interactive_configuration {
691 691
                                if [[ $possible_username != $GENERIC_IMAGE_USERNAME ]]; then
692 692
                                    MY_USERNAME=$(cat $data)
693 693
                                    useradd -m -s /bin/bash $MY_USERNAME
694
-                                   echo "${MY_USERNAME}:$(printf `cat $IMAGE_PASSWORD_FILE`)" | chpasswd
695
-                                   break
694
+                                   if [ -d /home/$MY_USERNAME ]; then
695
+                                       echo "${MY_USERNAME}:$(printf `cat $IMAGE_PASSWORD_FILE`)" | chpasswd
696
+                                       # Add the user as a sudoer - they will be the new admin user
697
+                                       if ! grep -q "$MY_USERNAME  ALL=(ALL) ALL" /etc/sudoers; then
698
+                                           echo "$MY_USERNAME  ALL=(ALL) ALL" >> /etc/sudoers
699
+                                           # remove the generic image admin user from sudoers
700
+                                           sed -i "s|${GENERIC_IMAGE_USERNAME}.*||g" /etc/sudoers
701
+                                       fi
702
+                                       break
703
+                                   fi
696 704
                                fi
697 705
                            fi
698 706
                        fi