#!/bin/bash
#create for create many users on 20160816 by babyplus
. /etc/init.d/functions
[ $UID -eq '0' ]||{
echo "use root run!"
exit 1
}
mkdir /test -p && touch /test/newuserpassword.txt
for n in `seq -w 2`
do
pass="`echo $RANDOM|md5sum |cut -c 3-8,10`"
[ `grep test${n} /etc/passwd|wc -l` -ge '1' ]&&echo "user test${n} is existed!" ||{
useradd test${n} -M &>/dev/null &&\
echo $pass |passwd --stdin test${n} &>/dev/null &&\
[ $? -eq 0 ]&&{
action "ok!" /bin/true
echo test${n}: $pass >>/test/newuserpassword.txt
}||{
action "false!" /bin/false
}
}
done
exit 0