#!/bin/bash
for user in `cat /home/opt/userlist.txt`
do
mkdir -p /app/ftp/issue/merDealFiles/$user/dealFiles
mkdir -p /app/ftp/issue/merDealFiles/$user/dealFiles/applyArea
mkdir -p /app/ftp/issue/merDealFiles/$user/dealFiles/resultArea
mkdir -p /app/ftp/issue/merDealFiles/$user/dealFiles/checkFiles
chmod 770 /app/ftp/issue/merDealFiles/$user/dealFiles/applyArea
cat /home/opt/uidlist.txt |while read uid
do
useradd -u $uid -g develop -d /app/ftp/issue/merDealFiles/$user $user -s /sbin/nologin
done
echo "$user successfully!!!"
echo "$user" >> /etc/access/ftpusers
echo "$user" >> /etc/access/chroot_users
#echo linux | passwd --stdin $user
mkpasswd > /home/opt/userpasswd.txt
cat /home/opt/userpasswd.txt | while read passwd
do
echo "$passwd"|passwd --stdin $user
echo "$passwd" >> /home/opt/userpasswd-F.txt
done
done
uidlist.txt格式
1122
1223
userlist.txt格式
test
test1
但感觉脚本还是有些小的问题,但对于目前暂时满足生产需求,该脚本可以根据已经规定的用户名和uid进行批量创建,并且可以将随机密码最终写到userpasswd-F.txt中。