Skip to content

Instantly share code, notes, and snippets.

@edersohe
Last active February 20, 2020 06:19
Show Gist options
  • Save edersohe/d52b3994d77810d6f653dcd87c7bf5f1 to your computer and use it in GitHub Desktop.
Save edersohe/d52b3994d77810d6f653dcd87c7bf5f1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%&?+*-_=:;.<>!?
#USER=id,name,department,folio,username,password,expiration
USERS='1000,User Demo 1,Department 1,#202020,user1,ekSRl1D3?8$:,2022-09-09\n1002,User Demo 2,Department 2,#32432,user2,ev5*&#A$@kLs,2021-02-19\n'
create_users () {
while IFS=',' read -r id name area folio username password expiration
do
grep "^${username}:" /etc/passwd || useradd ${username}
usermod -c "${id} - ${name} / ${area} / ${folio} / ${expiration}" ${username}
echo -e "${password}\n${password}" | passwd ${username}
chage -d 0 -m 0 -M 90 -W 10 -I -1 -E ${expiration} ${username}
done <<<"$(echo -e "${1}")"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment