Course Management Scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
547 B

#!/bin/bash
# Should expect a CSV of users in the format firstname,lastname,email,username
# (the email is ignored)
# Example usage: ./make_users.sh < students.csv
INIT_PASSWD="cspassword"
IFS=","
while read FNAME LNAME EMAIL UNAME REST; do
if ! getent passwd $UNAME > /dev/null; then
echo "$UNAME:$INIT_PASSWD:::$FNAME $LNAME:/home/students/$UNAME:/bin/bash" | newusers
chown -R $USER:$USER /home/students/$UNAME
chmod o-rwx /home/students/$UNAME
chgrp admin /home/students/$UNAME
passwd -e $UNAME
echo "Created $UNAME"
fi
done