Created
February 18, 2021 17:59
-
-
Save blizzz/7e08cf06cf4f7921521b0d8a6ba11ae8 to your computer and use it in GitHub Desktop.
Batch create users in samba4
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 | |
if [ ! -f /dev/shm/first-names.txt ]; then | |
wget -q https://raw.githubusercontent.com/dominictarr/random-name/master/first-names.txt -O /dev/shm/first-names.txt | |
fi | |
if [ ! -f /dev/shm/last-names.txt ]; then | |
wget -q https://raw.githubusercontent.com/dominictarr/random-name/master/names.txt -O /dev/shm/last-names.txt | |
fi | |
IFS=$'\r\n' GLOBIGNORE='*' command eval 'FIRST_NAMES=($(cat /dev/shm/first-names.txt))' | |
IFS=$'\r\n' GLOBIGNORE='*' command eval 'LAST_NAMES=($(cat /dev/shm/last-names.txt))' | |
size_fn=${#FIRST_NAMES[@]} | |
size_ln=${#LAST_NAMES[@]} | |
for i in {1..3200} | |
do | |
R_FN=${FIRST_NAMES[$(($RANDOM % size_fn))]} | |
R_LN=${LAST_NAMES[$(($RANDOM % size_ln))]} | |
R_UID="Joker ${i}" | |
echo "${R_FN} ${R_LN}" | |
samba-tool user create \ | |
"${R_UID}" \ | |
"${R_UID}" \ | |
--surname="${R_LN}" \ | |
--given-name="${R_FN}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment