《lnmp一键安装包》之前添加虚拟主机账号是保存在数据库,因此必须安装php和数据库才能正常使用,现更改为PureDB方式(不依赖php和MySQL),将用户信息保存在本地(非数据库)。但是这种方式管理ftp虚拟账号需要手工敲命令,于是写这个脚本来可视化的管理账号。
创新互联服务项目包括甘井子网站建设、甘井子网站制作、甘井子网页制作以及甘井子网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,甘井子网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到甘井子省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!功能如下(pureftpd_vhost.sh):
1.创建账号 2.更改目录 3.更改密码 4.删除账号 5.列出所有账号 6.显示某个账号详细信息 q. 退出如下图:
代码如下:
#!/bin/bash # Author: yeho <lj2007331 AT gmail.com> # Blog: http://blog.linuxeye.com # Check if user is root [ $(id -u) != "0" ] && { echo -e "�33[31mError: You must be root to run this script�33[0m"; exit 1; } export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin clear printf " ####################################################################### # LNMP/LAMP/LANMP for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ # # FTP virtual user account management # # For more information please visit http://blog.linuxeye.com/31.html # ####################################################################### " . ./options.conf [ ! -d "$pureftpd_install_dir" ] && { echo -e "�33[31mThe ftp server does not exist! �33[0m"; exit 1; } FTP_conf=$pureftpd_install_dir/etc/pure-ftpd.conf FTP_tmp_passfile=$pureftpd_install_dir/etc/pureftpd_psss.tmp Puredbfile=$pureftpd_install_dir/etc/pureftpd.pdb Passwdfile=$pureftpd_install_dir/etc/pureftpd.passwd FTP_bin=$pureftpd_install_dir/bin/pure-pw [ -z "`grep ^PureDB $FTP_conf`" ] && { echo -e "�33[31mpure-ftpd is not own password database�33[0m" ; exit 1; } USER() { while : do echo read -p "Please input a username: " User if [ -z "$User" ]; then echo -e "�33[31musername can\'t be NULL! �33[0m" else break fi done } PASSWORD() { while : do echo read -p "Please input the password: " Password [ -n "`echo $Password | grep \'[+|&]\'`" ] && { echo -e "�33[31minput error,not contain a plus sign (+) and &�33[0m"; continue; } if (( ${#Password} >= 5 ));then echo -e "${Password}n$Password" > $FTP_tmp_passfile break else echo -e "�33[31mFtp password least 5 characters! �33[0m" fi done } DIRECTORY() { while : do echo read -p "Please input the directory(Default directory: $home_dir): " Directory if [ -z "$Directory" ]; then Directory="$home_dir" fi if [ ! -d "$Directory" ];then echo -e "�33[31mThe directory does not exist�33[0m" else break fi done } while : do echo echo -e "What Are You Doing? t�33[32m1�33[0m. UserAdd t�33[32m2�33[0m. UserMod t�33[32m3�33[0m. UserPasswd t�33[32m4�33[0m. UserDel t�33[32m5�33[0m. ListAllUser t�33[32m6�33[0m. ShowUser t�33[32mq�33[0m. Exit" read -p "Please input the correct option: " Number if [ "$Number" != \'1\' -a "$Number" != \'2\' -a "$Number" != \'3\' -a "$Number" != \'4\' -a "$Number" != \'5\' -a "$Number" != \'6\' -a "$Number" != \'q\' ];then echo -e "�33[31minput error! Please only input 1 ~ 8 and q�33[0m" else case "$Number" in 1) USER [ -e "$Passwdfile" ] && [ -n "`grep ^${User}: $Passwdfile`" ] && { echo -e "�33[31m[$User] is already existed! �33[0m"; continue; } PASSWORD;DIRECTORY $FTP_bin useradd $User -f $Passwdfile -u $run_user -g $run_user -d $Directory -m < $FTP_tmp_passfile $FTP_bin -f $Passwdfile -F $Puredbfile > /dev/null 2>&1 echo "#####################################" echo echo "[$User] create successful! " echo echo "You user name is : $User" echo "You Password is : $Password" echo "You directory is : $Directory" echo ;; 2) USER;DIRECTORY $FTP_bin usermod $User -f $Passwdfile -d $Directory -m $FTP_bin -f $Passwdfile -F $Puredbfile > /dev/null 2>&1 echo "#####################################" echo echo "[$User] modify a successful! " echo echo "You user name is : $User" echo "You new directory is : $Directory" echo ;; 3) USER [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo -e "�33[31m[$User] is not existed! �33[0m"; continue; } PASSWORD $FTP_bin passwd $User -f $Passwdfile -m < $FTP_tmp_passfile $FTP_bin -f $Passwdfile -F $Puredbfile > /dev/null 2>&1 echo "#####################################" echo echo "[$User] Password changed successfully! " echo echo "You user name is : $User" echo "You new password is : $Password" echo ;; 4) if [ ! -e "$Passwdfile" ];then echo -e "�33[31mUser is not existed�33[0m" else $FTP_bin list fi USER [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo -e "�33[31m[$User] is not existed! �33[0m"; continue; } $FTP_bin userdel $User -f $Passwdfile -m $FTP_bin -f $Passwdfile -F $Puredbfile > /dev/null 2>&1 echo echo "[$User] have been deleted! " ;; 5) if [ ! -e "$Passwdfile" ];then echo -e "�33[31mUser is not existed�33[0m" else $FTP_bin list fi ;; 6) USER [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo -e "�33[31m[$User] is not existed! �33[0m"; continue; } $FTP_bin show $User ;; 9) exit ;; q) exit ;; esac fi done
当前标题:Pure-FTPd虚拟用户管理脚本(PureDB)
标题链接:/article22/cjspcc.html
成都网站建设公司_创新互联,为您提供ChatGPT、关键词优化、网站维护、网站导航、App开发、定制网站
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联