脚本一
#!/bin/bash
uid=20232
for user in `head -n1 /home/gaofengkun/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
useradd -u $uid -g develop -d /app/ftp/issue/merDealFiles/$user $user -s /sbin/nologin
echo "$user successfully!!!"
echo "$user" >> /etc/access/ftpusers
echo "$user" >> /etc/access/chroot_users
#echo linux | passwd --stdin $user
mkpasswd > /home/gaofengkun/userpasswd.txt
cat /home/gaofengkun/userpasswd.txt | while read passwd
do
echo "$passwd"|passwd --stdin $user
echo "$user:$passwd" >> /home/gaofengkun/userpasswd-F.txt
done
done
for user in `sed '1d' /home/gaofengkun/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
useradd -g develop -d /app/ftp/issue/merDealFiles/$user $user -s /sbin/nologin
echo "$user successfully!!!"
echo "$user" >> /etc/access/ftpusers
echo "$user" >> /etc/access/chroot_users
#echo linux | passwd --stdin $user
mkpasswd > /home/gaofengkun/userpasswd.txt
cat /home/gaofengkun/userpasswd.txt | while read passwd
do
echo "$passwd"|passwd --stdin $user
echo "$user:$passwd" >> /home/gaofengkun/userpasswd-F.txt
done
done
说明uid 中的id号可以自己定义,后续的用户id号会随着用户创建自动加1。
脚本二
#!/bin/bash
for user in `cat /home/gaofengkun/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/gaofengkun/uidlist.txt |while read uid
do
if cat /etc/passwd | awk -F : '{print $1}' | grep $user >/dev/null 2>&1
then
echo "User already exists"
else
useradd -u $uid -g develop -d /app/ftp/issue/merDealFiles/$user $user -s /sbin/nologin
fi
done
echo "$user successfully!!!"
echo "$user" >> /etc/access/ftpusers
echo "$user" >> /etc/access/chroot_users
#echo linux | passwd --stdin $user
mkpasswd > /home/gaofengkun/userpasswd.txt
cat /home/gaofengkun/userpasswd.txt | while read passwd
do
echo "$passwd"|passwd --stdin $user
echo "$user:$passwd" >> /home/gaofengkun/userpasswd-F.txt
done
done
注意:uidlist.txt中的uid与userlist.txt中的user需要一一对应。