一个用于添加和删除pure-ftpd用户的小脚本,只是为了减轻工作,并没什么技术含量。

用法:

#添加用户:
./pure-ftpd_ftpuser.sh create username userdirectory
#删除用户:
./pure-ftpd_ftpuser.sh drop username

下面是脚本源代码:

#!/bin/bash
# This script is used to add or delete users for pure-ftpd.
# ./pure-ftpd_ftpuser.sh (create|drop)
# By Chen Zhidong
# http://sillydong.com

PURE="/usr/local/pureftpd/"

if [ $# -lt 1 ]; then
    echo "Syntax: ./pure-ftpd_ftpuser.sh (create|drop)"
    exit
fi

if [ $1 == "create" ]; then
    if [ $# -lt 2 ]; then
        echo "create username,userpath"
        exit
    fi
  cd $PURE
    echo "create user username:$2 directory:$3"
  #pay attention to the user here, change it according to your system
  $PURE/bin/pure-pw useradd $2 -u www -d $3
  $PURE/bin/pure-pw mkdb pureftpd.pdb -f $PURE/etc/pureftpd.passwd
  $PURE/bin/pure-pw show $2
fi

if [ $1 == "drop" ]; then
    if [ $# -lt 1 ]; then
        echo "drop username"
        exit
    fi
  $PURE/bin/pure-pw userdel $2
  $PURE/bin/pure-pw mkdb pureftpd.pdb -f $PURE/etc/pureftpd.passwd
  $PURE/bin/pure-pw list | awk '{print $1}'
fi