Linux vsftp vuer虛擬使用者的建立批次指令碼

mengbing1990發表於2022-09-14

#!/bin/sh
#Edit by mengbing
#DATE:20220914
#Usage:sh adduser_vuser.sh
echo -n "Enter the accout's  number -> "
read number
expr $number + 10 > /dev/null 2>&1
status=$?

while  [ "$status"  !=  "0" ]
do
  echo -n " You must input a number: "
  read number
  expr $number + 10 > /dev/null 2>&1
  status=$?
done

counter=0
while [ $counter -lt $number ]
do
  serial=`expr $counter + 1`
  echo -n  " Enter the $serial  account name ->  "
  read NAME
  echo -n  " Enter the $serial  account passwd ->  "
  read PASSWD
  echo -n  " Retype  Enter the $serial  account passwd ->  "
  read PASSWD2
 if [ $PASSWD = $PASSWD2 ]; then
  echo $NAME >> /etc/vsftpd/ftpvuser
  echo $PASSWD >> /etc/vsftpd/ftpvuser
  db_load -T -t hash -f /etc/vsftpd/ftpvuser /etc/vsftpd/ftpvuser.db
  cp /etc/vsftpd/vuser_dir/4MCT  /etc/vsftpd/vuser_dir/$NAME
  echo "Congratulation,The account $NAME is created success."
  echo "Congratulation,The account $NAME is created success.The information is below.
USER:$NAME
PASSWORD:$PASSWD
Please Remember it.THX" |mail -s "DFS NEW ACCOUNT" mengbing@xx.com
 else
  echo "Sorry, passwords do not match. The account $NAME is not created."
  exit
 fi
  counter=`expr $counter + 1`
done

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29551564/viewspace-2914683/,如需轉載,請註明出處,否則將追究法律責任。

相關文章