和上一个自动添加脚本一致
#!/bin/bash
time=`date +%Y%m%d%k%M`
bakfile="user_logn.bak$time"
cp /etc/vsftpd/user_login /etc/vsftpd/vsftpd_bak/$bakfile
echo -n "Enter you want add ftp user‘s name:"
read name
if [ "$name" = "" ]; then
echo "The name can‘t be null"
exit 1
else
grep $name /etc/vsftpd/user_login > /dev/null
if [ $? -eq 0 ]; then
echo "The user is exist"
exit 1
else
echo $name >> /etc/vsftpd/user_login
if [ $? -eq 0 ]; then
echo "Add user successful!~"
echo -n "Enter you want add ftp user‘s password:"
read password
if [ "$password" = "" ]; then
echo "The password can‘t be null"
sed -i ‘$d‘ /etc/vsftpd/user_login
exit 1
else
echo $password >> /etc/vsftpd/user_login
if [ $? -eq 0 ]; then
echo "Add password successful!~"
db_load -T -t hash -f /etc/vsftpd/user_login /etc/vsftpd/user_login.db
mkdir /home/vsftp/$name
chown ftp_vuser:ftp_vuser /home/vsftp/$name
echo "you input name is $name"
echo "password is $password"
echo "Please Mind it!"
else
echo "password is failed,Please check your input"
fi
fi
else
echo "Add is failed, Please check the user_login file"
fi
fi
fi