diff --git a/src/create_users_from_user_pwd_list.sh b/src/create_users_from_user_pwd_list.sh new file mode 100755 index 0000000000000000000000000000000000000000..ea6559b120f4de9c47ec73f4fecd21cb4d8edfc8 --- /dev/null +++ b/src/create_users_from_user_pwd_list.sh @@ -0,0 +1,29 @@ +#! /usr/bin/bash + +# USAGE +# upload create_users_from_user_pwd_list.sh and user_pwd_list.tsv +# bash create_users_from_user_pwd_list.sh user_pwd_list.tsv + +USER_PASSWORD_FILENAME=$@ +while IFS=$'\t' read -r GROUPE NAME SURNAME MAIL LOGIN_CBP PASSWD_CBP LABO R_USERNAME R_PASSWD ; do + if [[ $MAIL =~ "@" ]] + then + echo "==========================================" + echo user: $NAME $SURNAME $MAIL $LABO group:$GROUPE + if ! [[ $GROUPE =~ "L" ]] + then + echo computer_login: $LOGIN_CBP + echo computer_passwd: $PASSWD_CBP + else + echo computer_login: "TP" + echo computer_passwd: + fi + echo r_login: $R_USERNAME + echo r_passwd: $R_PASSWD + + adduser ${R_USERNAME} --gecos 'First Last,RoomNumber,WorkPhone,HomePhone' --disabled-password --force-badname > /dev/null + echo "${R_USERNAME}:${R_PASSWD}" | chpasswd > /dev/null + fi +done < $USER_PASSWORD_FILENAME + +echo "==========================================" \ No newline at end of file