This repository was archived by the owner on Nov 8, 2021. It is now read-only.
  
  
  
  
    
    
    
      
    
  
  
    
File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 4444#  Possibility to provide custom useradd arguments
4545:  ${USERADD_ARGS:= " --create-home --shell /bin/bash"  
4646
47+ function  log()  {
48+     /usr/bin/logger -i -p auth.info -t aws-ec2-ssh " $@ " 
49+ }
50+ 
4751function  setup_aws_credentials()  {
4852    local  stscredentials
4953    if  [[ !  -z  " ${ASSUMEROLE} " 
@@ -142,9 +146,11 @@ function create_or_update_local_user() {
142146        localusergroups=" ${LOCAL_GROUPS} ,${LOCAL_MARKER_GROUP} " 
143147    fi 
144148
145-     id " ${username} " > /dev/null 2>&1  \
146-         ||  ${USERADD_PROGRAM}  ${USERADD_ARGS}  " ${username} " 
147-         &&  /bin/chown -R " ${username} :${username} " " $( eval echo  ~ $username ) " 
149+     if  !  id " ${username} " > /dev/null 2>&1 ;  then 
150+         ${USERADD_PROGRAM}  ${USERADD_ARGS}  " ${username} " 
151+         /bin/chown -R " ${username} :${username} " " $( eval echo  ~ $username ) " 
152+         log " Created new user ${username} " 
153+     fi 
148154    /usr/sbin/usermod -a -G " ${localusergroups} " " ${username} " 
149155
150156    #  Should we add this user to sudo ?
@@ -172,6 +178,7 @@ function delete_local_user() {
172178    sleep 1
173179    #  Remove account now that all processes for the user are gone
174180    /usr/sbin/userdel -f -r " ${1} " 
181+     log " Deleted user ${1} " 
175182}
176183
177184function  clean_iam_username()  {
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments