研究extmail批量添加/删除用户

环境:centos 5.5. 64    extman-1.1

利用extmail自带 perl脚本

先看看脚本的帮助说明

[root@smtp extsuite]# /usr/bin/perl /data/htdocs/extsuite/extman/tools/userctl.pl

usage: ./userctl.pl command [options] ...
 
Commands:

    add     -- add a user
    badd    -- batch add users
    del     -- delete a user
    bdel    -- batch delete users
    list    -- list all of users in a domain
    show    -- show profile of a user
    mod     -- modify user infomation
    help    -- display this help and exit

Options:

  -u, --username="[email protected]"            A username as email address
  -p, --password="******"                         User password
  -f, --file="/path/to/filename.csv"              A CSV file path, Just for batch add users, one user one line
                                                      username.tld password
  -d, --domain="domain.tld"                       A domain name
  -n, --name="name"                               common name
  -i, --uid="uid"                                 uid
  -Q, --question="what are you doing?"            Question?
  -A, --answer="play games"                       Answer
  -U, --uidnumber="1000"                          User ID number
  -G, --gidnumber="1000"                          Group ID number
  -e, --expire="2012-12-31"                       Expire date
  -q, --quota=100                                 Mail box quota
  -N, --ndquota=100                               Network disk quota
  -a, --active=1                                  Enable or disable (1 or 0)
  -S, --services="smtp,smtpd,pop3,webmail"        Enable services (smtp,smtpd,pop3,imap,webmail,netdisk,pwdchange)
  -su, --setuid="vuser"                           A system user to setuid if you want
  -sg, --setgid="vgroup"                          A system user to setgid if you want
  -H, --mailhost="mailhost"                       Mailhost is useful if you use ISP mode
  -no, --nomaildir=1                              Do you want create users maildir
  -D, --delmaildir=0                              Do you want keep users maildir
  -qq, --quiet                                    quiet mode, no any feedback
  -x, --xml                                       output XML format data

 

批量导入shell 脚本示例 (yum -y install pwgen ) 脚本附件中

#!/bin/bash
Domain='test.org'

Name='测试'


for i in {1..10};do
    echo "SerHR_`pwgen -sB 8 1`@$Domain"\ `pwgen -sB 8 1` >> /root/$Domain-email.csv
done

/usr/bin/perl /data/htdocs/extsuite/extman/tools/userctl.pl badd --file="/root/$Domain-email.csv" --name="$Name" --uidnumber="1000" --gidnumber="1000" --expire="0000-00-00" --quota=200 --ndquota=5 --active=1
 

批量删除刚才导入的用户

先处理 test.org-email.csv 文件

awk '{ print $1 }' test.org-email.csv > test.org-del-email.csv

/usr/bin/perl /data/htdocs/extsuite/extman/tools/userctl.pl bdel --file="/root/test.org-del-email.csv"

本文出自 “风中人生” 博客,谢绝转载!

你可能感兴趣的:(linux,职场,休闲,ExtMail,批量添加删除用户)