Skip to content

Instantly share code, notes, and snippets.

@Paul-Michaud
Last active June 30, 2016 10:07
Show Gist options
  • Save Paul-Michaud/78b2ed3d1e9d48da38a88241791894dc to your computer and use it in GitHub Desktop.
Save Paul-Michaud/78b2ed3d1e9d48da38a88241791894dc to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ "$#" -lt 2 ]; then
echo -e "Le script prend 2 arguments"
exit 1
fi
##Vérifier que l'user existe pas déjà et que les groupes existent
#http://superuser.com/questions/336275/find-out-if-user-name-exists
#http://stackoverflow.com/questions/29073210/how-to-check-if-a-group-exists-and-add-if-it-doesnt-in-linux-shell-script
useradd $1 -b /home/$2/ -g $2 -m
for data in "$@";do
if ( [ "$data" = "$1" ] || [ "$data" = "$2" ] );then #On fait rien car $1 est un user
:
else
#Script de conf
echo "/etc/environnement/$data.sh" >> /home/$2/$1/.bashrc
#Add user to group
usermod -a -G $data $1
fi
done
#bashrc
echo "umask 027" >> /home/$2/$1/.bashrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment