Script to Add FTP user

This scipt i used ato the do the following
 
1. if the domain is present  then continue to 1.1  else the domin does not exist  
1.1. if  the FTP user is present then continutue to 1.1.1
1.1.1 if the directory exist ...execute command to add ftpuse to that particular dir
 
 
 
#!/bin/bash -x

#format
#script domain.com username foldername password sizeinMB

echo -e  "Chking if domin name exist "
if [ -d /websites/"$1" ]; then
echo -e "the domin exist"
echo -e "chking to see if user exist"
     if [ "`cat /usr/local/pureftpd/etc/pureftpd.passwd  | sed 's/:/ /g' |awk '{print $1}' |sed -n "/${2}/P"`" != "$2"  ]; then

echo -e "chking to see if dir exist"
          if [ -d /websites/"$1"/"$3"  ]; then
echo -e "the dir $3 exist"
      echo -e "adding ftp user"
(echo $4; echo $4 ) | /usr/local/pureftpd/bin/pure-pw useradd "$2" -f /usr/local/pureftpd/etc/pureftpd.passwd  -u "$2" -d /websites/"$1"/"$3"  -m

      else
echo -e "the dir $3 does not exist"
           fi
    else
echo -e  "the user is all read present"
fi
else
echo -e "the domin does not exist"
fi



--

No comments:

Other Articles

Enter your email address: