为ftpserver批量增加用户
时间:2007-11-14 来源:blueantelope
#!/bin/bash
##############################
# ftpmana.sh
# blueantleope
# blueantelope@
# 0.01
# 2007-10-18
##############################
#----------------------------
# Manage Ftp user
#----------------------------
#set -x
ftp_dir="/var/ftp/"
ftp_group="ftp";
addCount=$2;
initCount=1;
currentUser=`ls /var/ftp/|grep ^u0|wc -l`
dir_begin="u00"
if [ -z $1 ]; then
printf "Usage: ftpmana.sh add count1!\n"
exit 1;
else
if [ -z $2 ]; then
printf "Please input that your want to add user count!\n"
exit 1;
fi
until [ $initCount -gt $addCount ]
do
currentUser=`expr $currentUser + 1`
username=$dir_begin$currentUser
createDir=$ftp_dir$username
echo $createDir
mkdir $createDir
chmod 770 $createDir
mkdir $createDir/to_upload
mkdir $createDir/to_$username
chmod 770 $createDir/*
useradd -d $createDir -g ftp -s /bin/bash $username
chown $username:ftp $createDir
chown $username:ftp $createDir/*
initCount=`expr $initCount + 1`
done
fi
#set +x
##############################
# ftpmana.sh
# blueantleope
# blueantelope@
# 0.01
# 2007-10-18
##############################
#----------------------------
# Manage Ftp user
#----------------------------
#set -x
ftp_dir="/var/ftp/"
ftp_group="ftp";
addCount=$2;
initCount=1;
currentUser=`ls /var/ftp/|grep ^u0|wc -l`
dir_begin="u00"
if [ -z $1 ]; then
printf "Usage: ftpmana.sh add count1!\n"
exit 1;
else
if [ -z $2 ]; then
printf "Please input that your want to add user count!\n"
exit 1;
fi
until [ $initCount -gt $addCount ]
do
currentUser=`expr $currentUser + 1`
username=$dir_begin$currentUser
createDir=$ftp_dir$username
echo $createDir
mkdir $createDir
chmod 770 $createDir
mkdir $createDir/to_upload
mkdir $createDir/to_$username
chmod 770 $createDir/*
useradd -d $createDir -g ftp -s /bin/bash $username
chown $username:ftp $createDir
chown $username:ftp $createDir/*
initCount=`expr $initCount + 1`
done
fi
#set +x
相关阅读 更多 +