#!/bin/sh
####create user by Dan Chen 2018-8-18##########
[ -f /etc/init.d/functions ] && source /etc/init.d/functions
[ $UID -ne 0 ] && {
action "current user is not root,permision deny!" /bin/false
exit 1
}
P=/oldboy/passlist.txt
$P
for Name in oldboy{01..10}
do
CheckUser=$(id $Name|wc -l)
CheckUser=$(grep -w "$Name" /etc/passwd|wc -l)
if [ $CheckUser -eq 1 ];then
action "$Name already exist!" /bin/false
continue
fi
useradd $Name &&\
PASS=$(echo $RANDOM|md5sum|cut -c 1-8)
echo "$PASS"|passwd --stdin $Name &>/dev/null
echo -e "$Name:$PASS"|tee -a $P|chpasswd
R=$?
if [ $R -eq 0 ];then
action "Useradd $Name is successful!" /bin/true
fi
echo -e "$Name\t$PASS" >>$P
done
原文地址:http://blog.51cto.com/9447803/2161414
时间: 2024-10-25 06:05:55