diff --git a/mybashrc b/mybashrc index f508a52..d4e1456 100644 --- a/mybashrc +++ b/mybashrc @@ -472,13 +472,17 @@ _FTP_ADD() { if [ "$#" = "0" ] || [ "$#" = "1" ]; then echo "Usage : ftpadd " else + if ! command_exists pwgen; then + apt_install pwgen + fi ftpaccountpass=$(_PWGEN) - echo "user : $1" - echo "password : $ftpaccountpass" if [ -d /var/www/"$2"/htdocs ]; then $NEED_SUDO useradd -d /var/www/"$2"/htdocs -M -s /bin/false -G www-data "$1" echo "$1:$ftpaccountpass" | $NEED_SUDO chpasswd -m chmod -R g+rw /var/www/"$2"/htdocs + echo -e "\n\n [/var/www/$2/htdocs]" | tee -a "$HOME/.ftpaccounts" + echo -e "user : $1" | tee -a "$HOME/.ftpaccounts" + echo "password : $ftpaccountpass" | tee -a "$HOME/.ftpaccounts" else echo "site directory doesn't exist" fi