Axigen logo

Axigen logo

Wednesday, July 20, 2011

Axigen Adminstration Scripts

Dear Reader,

If your organization is using Axigen as the mail server, then the below mentioned scripts, those provided by Axigen and few of them customized by me and my friends would be useful for basic and advanced adminstration task of the mail server which is not an easy task from the front-end called webadmin

All the scripts uses the basic python CLI module available from Axigen website (Click Here)

NOTE: For any python scripts to be run, make sure that cli.py is included in the path

For any Axigen related python scripts that needs to be executed, make sure that the file – cli2.py must be there in the same path.

Bulk User Creation

#python create-account.py demo456 test.com pass123 "Demo Account" (single account)

The same can be run in bulk using the below mentioned script
Script name: create-accounts.sh (I would provide them only if requested)
Requires: Kindly populate a text file (say create.txt) as per the below requirements

<account> <domain>  <password> <Full name>
demo111 test.com      pass123 "Demo Account1"
demo222 test.com      pass123 "Demo Account2"
demo333 test.com      pass123 "Demo Account3"
demo444 test.com      pass123 "Demo Account4"
demo555 test.com      pass123 "Demo Account5"

How to run the script:
# sh create-accounts.sh
- - - - - - - - - - - - - - - - - - - - - - - -
 Enter Userlist file name: create.txt

This would start creating the id mentioned in the text file and the same can be verified by checking the CLI, LDAP logs

Script name: import-accounts.py
Requires: create a text file addusers.txt with below entries
email-address<TAB>password
..
..
[root@bn Axigen_Scripts]# cat import.txt
demo111@test.com      pass123
demo222@test.com      pass123
demo333@test.com      pass123
demo444@test.com      pass123
demo555@test.com      pass123

# python import-accounts.py import.txt
Account added: demo111@test.com
Account added: demo222@test.com
Account added: demo333@test.com
Account added: demo444@test.com
Account added: demo555@test.com


How to generate list of email-address and other attributes of an account for a domain or complete setup?

One may require a user-list of accounts currently configured for a domain or all the domains hosted on a setup. This can be achieved by the means of list-accounts.py script.

Script name: list-accounts.py

For all domain accounts
#python list-accounts.py file=all-user.txt
# cat all-user.txt
aab@test.com
aabl@test.com
ab@test.com
ahp@test.com
….
postmaster@lab.com
postmaster@shrik.in
postmaster@test.com

For specific domain
# python list-accounts.py file=all-cdi.txt domains=test.com
# cat all-cdi.txt
aab@test.com
aabl@test.com
ab@test.com
ahp@test.com
aja@test.com

For multiple domains
# python list-accounts.py file=all-multi.txt domains=test.com, lab.com

To generate the list of all the aliases configured on the domains
# python list-accounts.py file=all-alias.txt aliases=1
# cat all-alias.txt
aab@test.com  ['alias1']
aabl@test.com ['alias2']
ab@test.com   []
ahp@test.com  []
..
postmaster@lab.com      ['root']
postmaster@shrik.in     []
postmaster@test.com     []

To generate the list of all the aliases configured on specific domains
# python list-accounts.py file=cdi-alias.txt domains=test.com aliases=1
# cat cdi-alias.txt
aab@test.com  ['alias1']
aabl@test.com ['alias2']
ab@test.com   []
ahp@test.com  []

To generate the list of Firstname, Lastname configured on all the domains
# python list-accounts.py file=all-alias.txt names=1
# cat all-names.txt
aab@test.com  "aab"   "aab"
aabl@test.com "aabl"  "aabl"
ab@test.com   "ab"    "ab"
...
vcg@test.com  "vcg"   "vcg"
postmaster@lab.com      ""      "postmaster"
postmaster@shrik.in     ""      "postmaster"
postmaster@test.com     ""      ""

To generate the list of Firstname, Lastname configured on specific domain
# python list-accounts.py file=cdi-alias.txt domains=test.com names=1
# cat names-cdi.txt
aab@test.com  "aab"   "aab"
aabl@test.com "aabl"  "aabl"
ab@test.com   "ab"    "ab"
ahp@test.com  "ahp"   "ahp"
aja@test.com  "aja"   "aja"
aji@test.com  "aji"   "aji"
asp@test.com  "asp"   "asp"
bj@test.com   "bj"    "bj"
demo111@test.com      ""      "demo111"
demo222@test.com      ""      "demo222"

To generate other useful information about the account like
Creation Date, Modification Date, POP3 Last Login Date, IMAP Last Login Date, WebMail Last Login Date, Associated LDAP ID, Configuration Status, Mbox Storage Status

To generate a Creation Date for all accounts of test.com domain
# python list-accounts.py file=creation-cdi.txt domains=test.com registry=1 cd=1
# cat creation-cdi.txt
aab@test.com
        Creation Date: Thu, 23 Jun 2011 14:27:09 +0530
aabl@test.com
        Creation Date: Thu, 23 Jun 2011 14:27:09 +0530
ab@test.com
        Creation Date: Thu, 23 Jun 2011 14:27:09 +0530
ahp@test.com
        Creation Date: Thu, 23 Jun 2011 14:27:09 +0530
aja@test.com
        Creation Date: Thu, 23 Jun 2011 14:27:09 +0530
aji@test.com
        Creation Date: Thu, 23 Jun 2011 14:27:09 +0530
….


To generate a Mailbox storage status for all accounts of test.com domain
# python list-accounts.py file=mbox-cdi.txt domains=test.com registry=1 mss=1
# cat mbox-cdi.txt
aab@test.com
        Mbox Storage Status: Ok
aabl@test.com
        Mbox Storage Status: Ok
ab@test.com
        Mbox Storage Status: Ok
ahp@test.com
        Mbox Storage Status: Ok
aja@test.com
        Mbox Storage Status: Ok
aji@test.com
        Mbox Storage Status: Ok
….

To generate a LDAP association information for all accounts of test.com domain
# python list-accounts.py file=ldap-cdi.txt domains=test.com registry=1 ali=1
# cat ldap-cdi.txt
aab@test.com
        Associated LDAP ID: 895a48d4-9985-44aa-975b-3904409b9b77
aabl@test.com
        Associated LDAP ID: 6a8eeb68-12e3-4ef4-98fa-53f119145fa6
ab@test.com
        Associated LDAP ID: 1bc82bed-02ba-47e1-8a86-a69f520a573a
ahp@test.com
        Associated LDAP ID: 40479038-bb49-47b0-abac-313ee6aad877
aja@test.com
        Associated LDAP ID: eeadcc36-aed5-4bb8-901d-8c6670697c5b

How to generate list of last login details of an account for a domain or complete setup?

One may require a details about the last-login information about user-list of accounts currently configured for a domain or all the domains hosted on a setup. This can be achieved by the means of last-login.py script.
Script name: list-accounts.py

To generate the Last-login details about the accounts configured on single or all domains

# python last-login.py log=all-login.txt

******** Script started at: Tue Jun 28 18:18:40 2011 ***********
** Last login date before: Wed Jun 29 18:18:40 2011 (0 days)
** CLI Host/Port: 127.0.0.1:7000
** Action to matched accounts: list
** Domains to search in: all domains
-----------------------------------------------
>> aab@test.com - Last login: Thu Jun 23 14:27:09 2011
>> aabl@test.com - Last login: Thu Jun 23 14:27:09 2011
>> ab@test.com - Last login: Thu Jun 23 14:27:09 2011
>> ahp@test.com - Last login: Thu Jun 23 14:27:09 2011
>> aja@test.com - Last login: Thu Jun 23 14:27:09 2011
>> aji@test.com - Last login: Thu Jun 23 14:27:09 2011
….
>> postmaster@lab.com - Last login: Fri Jun 10 14:46:14 2011
>> postmaster@shrik.in - Last login: Mon Jun 13 11:55:24 2011
>> postmaster@test.com - Last login: Tue Jun 14 10:15:59 2011

To generate the Last-login details about the accounts configured on single or all domains
# python last-login.py log=cdi-login.txt domain=test.com

******** Script started at: Tue Jun 28 18:23:23 2011 ***********
** Last login date before: Wed Jun 29 18:23:23 2011 (0 days)
** CLI Host/Port: 127.0.0.1:7000
** Action to matched accounts: list
** Domains to search in: test.com
-----------------------------------------------
>> aab@test.com - Last login: Thu Jun 23 14:27:09 2011
>> aabl@test.com - Last login: Thu Jun 23 14:27:09 2011
>> ab@test.com - Last login: Thu Jun 23 14:27:09 2011
>> ahp@test.com - Last login: Thu Jun 23 14:27:09 2011
>> aja@test.com - Last login: Thu Jun 23 14:27:09 2011
>> aji@test.com - Last login: Thu Jun 23 14:27:09 2011
>> asp@test.com - Last login: Thu Jun 23 14:27:10 2011
….


How to update the user-account information in bulk?
The user-account information is Passwords, Quotas, Limits, Filters, WebmailData etc
Let say you need to update the same password for a list of accounts, the same can be achieved by the means of below script

#python set-bulk-accounts.py file=myaccounts.txt :passwd=P@ssw0rd
[root@bn Axigen_Scripts]# python set-bulk-accounts.py file=myaccounts.txt :passwd=P@ssw0rd
Enter CLI Admin password:
Ok: test.com->demo111->->passwd: P@ssw0rd
Ok: test.com->demo222->->passwd: P@ssw0rd
Ok: test.com->demo333->->passwd: P@ssw0rd
Ok: test.com->demo444->->passwd: P@ssw0rd
Ok: test.com->demo555->->passwd: P@ssw0rd

Let say you need to update the Organization for all accounts for domain – test.com
# python set-bulk-accounts.py file=myaccounts.txt contactInfo:company=CDI-COMPANY
Enter CLI Admin password:
Ok: test.com->demo111->contactInfo->company: CDI-COMPANY
Ok: test.com->demo222->contactInfo->company: CDI-COMPANY
Ok: test.com->demo333->contactInfo->company: CDI-COMPANY
Ok: test.com->demo444->contactInfo->company: CDI-COMPANY
Ok: test.com->demo555->contactInfo->company: CDI-COMPANY

Let say you need to change the quota for limited accounts to 100 MB
# python set-bulk-accounts.py file=myaccounts.txt quotas:totalMessageSize=102400
Enter CLI Admin password:
Ok: test.com->demo111->quotas->totalMessageSize: 102400
Ok: test.com->demo222->quotas->totalMessageSize: 102400
Ok: test.com->demo333->quotas->totalMessageSize: 102400
Ok: test.com->demo444->quotas->totalMessageSize: 102400
Ok: test.com->demo555->quotas->totalMessageSize: 102400

How to create group from CLI?

Creating a group from webadmin is simple, and addition of ids to the same becomes tedious is the count is more , let say in 100. Since Axigen do not have a capability to import from a file, it has provided a much simpler way of doing it by the means of CLI script, add-group-addresses.py

Let say you need to have a group – accounts created in domain test.com compromising of 15 id. You can achieve the same by following the below mentioned approach.

Script name: add-group-addresses.py

Create a text file for the email-address to be added in group. Say the file is accounts.txt

# cat accounts.txt
aab@test.com
aabl@test.com
ab@test.com
ahp@test.com
aja@test.com
aji@test.com
asp@test.com
bj@test.com
demo111@test.com
demo222@test.com
demo333@test.com
demo444@test.com
….
# python add-group-addresses.py file=accounts.txt group=accounts@test.com
Group `accounts` does not exist in domain `test.com`. Trying to create...
Successfully created group `accounts` in domain `test.com`.
>> Address `aab@test.com` successfully added
>> Address `aabl@test.com` successfully added
>> Address `ab@test.com` successfully added
>> Address `ahp@test.com` successfully added
>> Address `aja@test.com` successfully added
>> Address `aji@test.com` successfully added
>> Address `asp@test.com` successfully added
>> Address `bj@test.com` successfully added
>> Address `demo111@test.com` successfully added
>> Address `demo222@test.com` successfully added
>> Address `demo333@test.com` successfully added
>> Address `demo444@test.com` successfully added
…..

You will notice that since accounts@test.com doesn’t exist, Axigen would create it for you.

Say you need to update the same group with an additional 5 members; you would need to run the same script, just populate the accounts.txt with the new member

# python add-group-addresses.py file=accounts.txt group=accounts@test.com
>> Address `ssr@test.com` successfully added
>> Address `sst@test.com` successfully added
>> Address `tam@test.com` successfully added
>> Address `tpn@test.com` successfully added
>> Address `vbp@test.com` successfully added
>> Address `vcg@test.com` successfully added

How to generate group-members report for domains

Path: /root/GROUP_REPORT/
Script name: bn5-list-group-mem.sh
# sh bn5-list-group-mem.sh   Domain-name  Output-file-name.txt
eg: # sh  bn5-list-group-mem.sh     almt-group-report.csv     almtlegal.com


How to update user account specific details like First Name, Last Name, Company, Mobile nos etc?

Let say, you have populated the accounts in Axigen, Now the customer has provided the details about the end-user, First name, Last name, Company name etc

This can be achieved, by either editing the account details from webadmin and updating the same, if the count is  less, say 10-15, but let say, you have 100 accounts then the above approach would become tedious. For this Axigen has provided a script which we have customized to update only specific fields

For adding/updating the customized fields, we have created a spreadsheet bulk_contact_import_template.xls

In the spreadsheet enter the details as show below


Save the file as .csv

Next open the save filed – cdi-import.csv in wordpad

Remove the header of the file




# cat cdi-import.txt
aab,test.com,aab,,,,,,9912345699,,,,,,,,,CDI ORGANISATION,,,,,,,,,,,,,,,,,
aabl,test.com,aabl,,,,,,9912345700,,,,,,,,,CDI ORGANISATION,,,,,,,,,,,,,,,,,
ab,test.com,ab,,,,,,9912345701,,,,,,,,,CDI ORGANISATION,,,,,,,,,,,,,,,,,
ahp,test.com,ahp,,,,,,9912345702,,,,,,,,,CDI ORGANISATION,,,,,,,,,,,,,,,,,
aja,test.com,aja,,,,,,9912345703,,,,,,,,,CDI ORGANISATION,,,,,,,,,,,,,,,,,
aji,test.com,aji,,,,,,9912345704,,,,,,,,,CDI ORGANISATION,,,,,,,,,,,,,,,,,
asp,test.com,asp,,,,,,9912345705,,,,,,,,,CDI ORGANISATION,,,,,,,,,,,,,,,,,
bj,test.com,bj,,,,,,9912345706,,,,,,,,,CDI ORGANISATION,,,,,,,,,,,,,,,,,

# python set-bulk-accounts-contactinfo.py file=cdi-import.txt domain=test.com
acctFile::: cdi-import.txt
Domain: test.com
Enter CLI Admin password:
aab "test.com" "CDI ORGANISATION"
aabl "test.com" "CDI ORGANISATION"
ab "test.com" "CDI ORGANISATION"
ahp "test.com" "CDI ORGANISATION"
aja "test.com" "CDI ORGANISATION"
aji "test.com" "CDI ORGANISATION"
asp "test.com" "CDI ORGANISATION"
bj "test.com" "CDI ORGANISATION"

The same can be verified by checking from web-admin for any one particular account.
 
How to add new message store to the domain storage

# pwd
/var/opt/axigen/domains/test.com
[root@bn test.com]# ll
total 676
-rw-r----- 1 axigen axigen 659456 Jun 29 11:51 00.hsf
-rw-r----- 1 axigen axigen    127 Jun 14 12:24 hsf.dat
-rw-r----- 1 axigen axigen  65544 Jun 29 11:51 log.hst
drwxr-x--- 2 axigen axigen   4096 Jun 10 11:38 messages
drwxr-x--- 2 axigen axigen   4096 Jun 10 11:12 objects

Click on Add Location button,

Enter the below value “/var/opt/axigen/domains/test.com/messages1”, recheck the path again.
(Make sure that the path exists and has the permissions axigen:axigen for the path)

Click on Save Configuration

The same can be verified by checking the path again

# pwd
/var/opt/axigen/domains/test.com
[root@bn test.com]# ll
total 680
-rw-r----- 1 axigen axigen 659456 Jun 29 11:51 00.hsf
-rw-r----- 1 axigen axigen    156 Jun 29 12:41 hsf.dat
-rw-r----- 1 axigen axigen  65544 Jun 29 11:51 log.hst
drwxr-x--- 2 axigen axigen   4096 Jun 10 11:38 messages
drwxr-x--- 2 axigen axigen   4096 Jun 29 12:41 messages1
drwxr-x--- 2 axigen axigen   4096 Jun 10 11:12 objects


[root@bn2 ~]# telnet localhost 7000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Welcome to AXIGEN's Command Line Interface
You must login first. For a list of available commands, type HELP
<login> user admin
<password> fragile
<#> edit domain name vgmail.in
+OK: command successful
<domain-edit#> ADD MessagesLocation file:///var/opt/bn2data6/domains/vgmail.in/messages2/?maxFileSize=262144&maxFiles=128
+OK: command successful
<domain-edit#> commit
committing changes and switching back to previous context.
This operation might take some time. Please wait....
+OK: command successful
<#> exit

NOTE: Make sure that the above path : /var/opt/bn2data6/domains/vgmail.in exists and have the permission axigen:axigen, if not then kindly create the same and provide the same permission


8 comments:

  1. I have been trying to find the correct syntax to add a mailing list (mlist-add-addresses.py) contacted support several times and came up with the conclusion that they do not know the script syntax. I know how to log in using the CLI but when it gets to entering the command I get an error. If doing this is possible, please provide me with the correct command syntax and I can go from there. Thanks

    ReplyDelete
  2. Hi Anirudha Patil,

    need Script name: create-accounts.sh (I would provide them only if requested)
    thanks for your support

    ReplyDelete
  3. Hi Anirudha Patil,

    May I have a copy of your create-accounts.sh

    Thank you in advance.

    ReplyDelete
  4. Is there a way to find the admin user who has changed the password of the particular account? Another question, Can we find the information about an account which has been already deleted from the system/server?

    ReplyDelete
  5. Hi, Please can you give me the script: create-accounts.sh. I tried using the import-accounts.py script with the txt file created but I get the error:

    [root@kabs01 axigen]# python import-accounts.py userlist1.txt
    Enter CLI Admin password:
    !! Domain does not exist for: beta@kabs01.mrscllc.net
    !! Domain does not exist for: beta@kabs02.mrscllc.net
    !! Domain does not exist for: beta@kabs03.mrscllc.net
    [root@kabs01 axigen]#

    But the all the domains listed in the txt file do exist on our axigen server...

    ReplyDelete
    Replies
    1. Sorry, i have lost track of the myfile as laptop crashed and im not able to recover the files

      Delete
  6. hi.. .can i request bn5-list-group-mem.sh script ?

    ReplyDelete
  7. can request create-accounts.sh scipt?

    ReplyDelete