Last active
September 28, 2015 10:18
-
-
Save metalrufflez/1424081 to your computer and use it in GitHub Desktop.
Create a file to use with the zmcreateusers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# zmparseusers | |
# Create a formatted list to be used with zmcreateusers | |
# AUTHOR: Caio Correa | |
# Provided a file with a list of names like | |
# | |
# John Doe | |
# Lucy Doe | |
# Martin Dovahkiin | |
# | |
# This script outputs a list like this | |
# | |
# jdoe:John Doe:John:Doe:DJohn26002:john.doe | |
# ldoe:Lucy Doe:Lucy:Doe:DLucy17732:lucy.doe | |
# mdovahkiin:Martin Dovahkiin:Martin:Dovahkiin:DMartin3382:martin.dovahkiin | |
# | |
if [ $# -ne 1 ]; then | |
echo "Usage: $0 <file>" | |
exit 1 | |
fi | |
file=$1 | |
while read line; do | |
displayname=$line | |
surname="${displayname##* }" | |
givenname="${displayname%% *}" | |
username="$(echo ${givenname:0:1}$surname | tr [ãõáéíóúêôç] [aoaeioueoc] | tr '[:upper:]' '[:lower:]')" | |
passwd="$(echo ${surname:0:1}$givenname$RANDOM | tr [ãõáéíóúêôç] [aoaeioueoc])" | |
alias="$(echo $givenname.$surname | tr [ãõáéíóúêôç] [aoaeioueoc] | tr '[:upper:]' '[:lower:]')" | |
echo $username:$displayname:$givenname:$surname:$passwd:$alias | |
done < $file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment