script to add additional FTP user to a domain

This script does the following
 
ths scritp will only add additional FTP user to a domain
 
#!/bin/bash

#format
#script domain.com username foldername password sizeinMB

domain_system_user=`cat /etc/passwd | sed 's/:/ /g' |awk '{print $1  $5 }' |sed 's/\// /g' |awk '{print $3" "  }' |sed -n "/${1}/P" |sed 's/\./ /g' |awk '{print $1}' `

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  $5 }' |sed 's/\// /g' |awk '{print $3" " $1 }' |sed -n "/${1} ${2}/P"`" != "$1 $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 "$domain_system_user" -d /websites/"$1"/"$3"  -m

      else
echo -e "the dir $3 does not exist ===> the ftp user is not created"
           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: