Added new scripts, the most important one being update-domain.sh to change your domain name
This commit is contained in:
parent
ff21a079c1
commit
638d76db6e
|
@ -1,4 +1,4 @@
|
|||
Administrative scripts for iRedMail, useful if you do not use iRedAdmin.
|
||||
Administrative scripts for iRedMail, useful if you do not use iRedAdmin, or you do not have iRedAdmin Pro.
|
||||
|
||||
Read the examples and usage in each script to understand the parameters to use. Each script will generate SQL for you to use. These scripts are for a iRedMail installation with an SQL back end, specifically PostgreSQL.
|
||||
|
||||
|
@ -8,7 +8,10 @@ There are scripts so far to do the following administrative functions:
|
|||
| ------------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| User accounts | | |
|
||||
| | create-new-user.sh | Creates a new user, with an optional feature of created users being a part of default aliases |
|
||||
| | create-new-user-bulk.sh | Creates new users from a CSV file, with an optional feature of created users being a part of default aliases | |
|
||||
| | create-new-user-bulk.sh | Creates new users from a CSV file, with an optional feature of created users being a part of default aliases |
|
||||
| | add-domain-admin.sh | Makes an existing user a domain admin |
|
||||
| | revoke-domain-admin.sh | Revokes a users domain administrator permission |
|
||||
| | remove-domain-admin.sh | Remove a users entry entirely from the domain_admins table |
|
||||
| | remove-user.sh | Delete a user |
|
||||
| | update-account-password.sh | Update a users password |
|
||||
| | disable-mail-forwarding.sh | De-activate a user account |
|
||||
|
@ -22,7 +25,8 @@ There are scripts so far to do the following administrative functions:
|
|||
| | disable-pop3-for-user.sh | Disables pop3 for a user account, prevents usage of this protocol |
|
||||
| | disable-pop3-for-domain.sh | Disables pop3 for all accounts on a given domain |
|
||||
| | disable-imap-for-user.sh | Disables IMAP for a user account, prevents usage of this protocol |
|
||||
| | increase-mailbox-quota.sh | Increases the mail box quota size for a given user |
|
||||
| | increase-mailbox-quota.sh | Increases the mail box quota size for a given user |
|
||||
| | increase-all-mailbox-quota.sh | Increases the mail box quota size for all users regardless of domain, or for a specific domain |
|
||||
| Aliases | | |
|
||||
| | create-alias.sh | Create an alias |
|
||||
| | add-user-to-alias.sh | Add a user to an alias. Multiple users can be added to the same alias, use the script as many times as necessary. |
|
||||
|
@ -34,14 +38,17 @@ There are scripts so far to do the following administrative functions:
|
|||
| Forwarding | | |
|
||||
| | list-forwarding.sh | List any configured forwards |
|
||||
| | remove-forwarding.sh | Deletes mail forwarding from a given address to another entered address |
|
||||
| | remove-whole-forward.sh | Removes the whole forwarding address and all forwards associated to it |
|
||||
| | add-mail-forward.sh | Forward mail from one user account to another |
|
||||
| | is-forward-to.sh | List if any addresses are set to forward to a given address |
|
||||
| | is-forward-from.sh | List if any addresses are set to forward fromm a given address |
|
||||
| | disable-mail-forwarding.sh | Disables mail forwarding from a given address to another entered address, but do not delete the configured forward |
|
||||
| Domain | | |
|
||||
| | add-domain.sh | Creates a new domain in the database, after which you can begin creating user accounts in the new domain |
|
||||
| | update-domain.sh | Change domain name of an existing domain and associated mail accounts |
|
||||
| | remove-domain.sh | Removes a domain from the database |
|
||||
| | update-domain-quota.sh | Updates the domain wide mailbox quota |
|
||||
| | update-domain-quota.sh | Updates the domain wide mailbox quota |
|
||||
| | update-all-domain-quota.sh | Updates all existing domains with a new default mailbox quota |
|
||||
| | enable-domain.sh | Enables a domain in the database, must exist already |
|
||||
| | disable-domain.sh | Disables a domain in the database |
|
||||
| Misc | | |
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Makes an existing user a domain admin in iRedMail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Note: Replace ALL with a specific domain name if you want the user to be restricted to administer only
|
||||
# a specific domain.
|
||||
#
|
||||
# sh new-domain-admin.sh user@example.com ALL
|
||||
#
|
||||
# This will print SQL commands on the console directly, you can redirect the
|
||||
# output to a file for further use like this:
|
||||
#
|
||||
# sh new-domain.sh example.com > output.sql
|
||||
#
|
||||
# Import output.sql into SQL database like below:
|
||||
#
|
||||
# mysql -uroot -p
|
||||
# mysql> USE vmail;
|
||||
# mysql> SOURCE /path/to/output.sql;
|
||||
#
|
||||
# psql -d vmail
|
||||
# sql> \i /path/to/output.sql;
|
||||
|
||||
# Read input
|
||||
username="$1"
|
||||
domain="$2"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 2 ]; then
|
||||
printf "Purpose: Makes an existing user a domain admin in iRedMail. \n"
|
||||
printf "Note: Replace ALL with a specific domain name if you want the user to be restricted to administer only a specific domain. \n"
|
||||
printf "Usage: sh new-domain-admin.sh user@example.com ALL \n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf "INSERT INTO domain_admins (username, domain, active) VALUES ('${username}', '${domain}', 1); \n"
|
|
@ -26,7 +26,7 @@
|
|||
# Read input
|
||||
domain="$1"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 1 ]; then
|
||||
printf "Purpose: Adds a new domain in iRedMail. \n"
|
||||
printf "Usage: sh new-domain.sh example.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
address="$1"
|
||||
forwardToEmail="$2"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 2 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 2 ]; then
|
||||
printf "Purpose: Creates a mail forwarding setup to direct email sent to user@example.com otherUser@example.com in iRedmail. \n"
|
||||
printf "Usage: sh add-mail-forward.sh user@example.com otherUser@example.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
aliasAccount="$1"
|
||||
sendToEmail="$2"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 2 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 2 ]; then
|
||||
printf "Purpose: Add a user to an alias in iRedmail. \n"
|
||||
printf "Usage: sh add-user-to-alias.sh alias@mydomain.com jeff@gmail.com \n"
|
||||
exit 0
|
||||
|
@ -36,4 +36,4 @@ fi
|
|||
aliasAccountDomain=$(echo $aliasAccount | cut -f 2 -d '@')
|
||||
sendToEmailDomain=$(echo $sendToEmail | cut -f 2 -d '@')
|
||||
|
||||
printf "INSERT INTO forwardings (address, forwarding, domain, dest_domain, is_list, active) VALUES ('${aliasAccount}', '${sendToEmail}', '${aliasAccountDomain}', '${sendToEmailDomain}', 1, 1); \n"
|
||||
printf "INSERT INTO forwardings (address, forwarding, domain, dest_domain, is_list, active) VALUES ('${aliasAccount}', '${sendToEmail}', '${aliasAccountDomain}', '${sendToEmailDomain}', 0, 1); \n"
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Changes an existing domain to a different one in iRedMail.
|
||||
# License: 2-clause BSD license
|
||||
# Note: Once the new domain is added to iRedMail in the database, you can they use create-new-user.sh or create-new-user-bulk.sh scripts to add user accounts.
|
||||
# The usage of this script is only necessary when adding NEW domains to iRedMail as during installation time your initial domain will be added.
|
||||
#
|
||||
# sh change-domain.sh old-domain.com new-domain.com
|
||||
#
|
||||
# This will print SQL commands on the console directly, you can redirect the
|
||||
# output to a file for further use like this:
|
||||
#
|
||||
# sh change-domain.sh old-domain.com new-domain.com > output.sql
|
||||
#
|
||||
# Import output.sql into SQL database like below:
|
||||
#
|
||||
# mysql -uroot -p
|
||||
# mysql> USE vmail;
|
||||
# mysql> SOURCE /path/to/output.sql;
|
||||
#
|
||||
# psql -d vmail
|
||||
# sql> \i /path/to/output.sql;
|
||||
|
||||
# Read input
|
||||
oldDomain="$1"
|
||||
oldDomain="$2"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 || [ $# -gt 2 ]; then
|
||||
printf "Purpose: Changes an existing domain to a different one in iRedMail. \n"
|
||||
printf "Usage: sh change-domain.sh old-domain.com new-domain.com \n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf "INSERT INTO domain VALUES domain = '$domain' AND active ='1';\n"
|
|
@ -35,7 +35,7 @@
|
|||
dlName="$1"
|
||||
policy="$2"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 2 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 2 ]; then
|
||||
printf "Purpose: Creates or updates an access policy for an alias to restrict which senders are allowed to send email to this mail alias, in iRedMail. \n"
|
||||
printf "Available access policies: \n"
|
||||
printf "public no restrictions \n"
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
dlName="$1"
|
||||
domainName="$2"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 2 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 2 ]; then
|
||||
printf "Purpose: Creates an alias in iRedmail, email sent to an alias goes to all addresses added onto the alias. \n"
|
||||
printf "Usage: sh create-alias.sh alias@mydomain.com mydomain.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
# Read input
|
||||
domain="$1"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 1 ]; then
|
||||
printf "Purpose: Disables a domain in iRedMail. \n"
|
||||
printf "Usage: sh disable-domain.sh example.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
# Read input
|
||||
username="$1"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 1 ]; then
|
||||
printf "Purpose: Disables enableimap,enableimapsecured,enableimaptls in the mailbox table for a given user to be 0 (disabled) in iRedmail so to disable IMAP. \n"
|
||||
printf "Usage: sh disable-imap-for-user.sh jeff@example.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
fromUser="$1"
|
||||
toUser="$2"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 2 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 2 ]; then
|
||||
printf "Purpose: Disable mail forwarding or from an alias, from a user account to another mail account in iRedmail. \n"
|
||||
printf "Usage: sh disable-mail-forwarding.sh fromUser@example.com toUser@example.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
# Read input
|
||||
domain="$1"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 1 ]; then
|
||||
printf "Purpose: Disables enablepop3,enablepop3secured,enablepop3tls in the mailbox table for a given domain to be 0 (disabled) in iRedmail so to disable pop3. \n"
|
||||
printf "Usage: sh disable-pop3-for-domain.sh example.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
# Read input
|
||||
username="$1"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 1 ]; then
|
||||
printf "Purpose: Disables enablepop3,enablepop3secured,enablepop3tls in the mailbox table for a given user to be 0 (disabled) in iRedmail so to disable pop3. \n"
|
||||
printf "Usage: sh disable-pop3-for-user.sh jeff@example.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
# Read input
|
||||
domain="$1"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 1 ]; then
|
||||
printf "Purpose: Re-enables a disabled domain in iRedMail. \n"
|
||||
printf "Usage: sh enable-domain.sh example.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
# Read input
|
||||
username="$1"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 1 ]; then
|
||||
printf "Purpose: Enables enableimap,enableimapsecured,enableimaptls in the mailbox table for a given user to be 1 (enabled) in iRedmail so to enable IMAP. \n"
|
||||
printf "Usage: sh enable-imap-for-user.sh jeff@example.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
fromUser="$1"
|
||||
toUser="$2"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 2 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 2 ]; then
|
||||
printf "Purpose: Re-enable mail forwarding or from an alias, from a user account to another mail account in iRedmail. \n"
|
||||
printf "Usage: sh enable-mail-forwarding.sh fromUser@example.com toUser@example.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
# Read input
|
||||
domain="$1"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 1 ]; then
|
||||
printf "Purpose: Enables enablepop3,enablepop3secured,enablepop3tls in the mailbox table for a given domain to be 1 (enabled) in iRedmail so to enable pop3. \n"
|
||||
printf "Usage: sh enable-pop3-for-domain.sh example.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
# Read input
|
||||
username="$1"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 1 ]; then
|
||||
printf "Purpose: Enables enablepop3,enablepop3secured,enablepop3tls in the mailbox table for a given user to be 1 (enabled) in iRedmail so to disable pop3. \n"
|
||||
printf "Usage: sh enable-pop3-for-user.sh jeff@example.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Increases the mail box quota size for all users regardless of domain, or for a specific domain, in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Note: Enter the size as mb. The default quota is 1024 mb. Replace the domain name with an asterisk (*) to update all current users with the new mailbox quota size.
|
||||
#
|
||||
# Example usage: sh increase-all-mailbox-quota.sh example.com 2048
|
||||
#
|
||||
# This will print SQL commands on the console directly, you can redirect the
|
||||
# output to a file for further use like this:
|
||||
#
|
||||
# sh increase-all-mailbox-quota.sh example.com 2048 > output.sql
|
||||
#
|
||||
# Import output.sql into SQL database like below:
|
||||
#
|
||||
# mysql -uroot -p
|
||||
# mysql> USE vmail;
|
||||
# mysql> SOURCE /path/to/output.sql;
|
||||
#
|
||||
# psql -d vmail
|
||||
# sql> \i /path/to/output.sql;
|
||||
|
||||
# Read input
|
||||
domain="$1"
|
||||
quota="$2"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 2 ]; then
|
||||
printf "Purpose: Increases the mail box quota size for all users regardless of domain, or for a specific domain, in iRedmail. \n"
|
||||
printf "Note: Replace the domain name with a quoted asterisk (*) to update all current users with the new mailbox quota size."
|
||||
printf "Usage: sh increase-all-mailbox-quota.sh example.com 2048 OR sh increase-all-mailbox-quota.sh \"*\" 2048 \n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$domain" != "*" ]; then
|
||||
printf "UPDATE mailbox SET quota = '${quota}' WHERE domain = '${domain}'; \n"
|
||||
else
|
||||
printf "UPDATE mailbox SET quota = '${quota}'; \n"
|
||||
fi
|
|
@ -27,7 +27,7 @@
|
|||
address="$1"
|
||||
quota="$2"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 2 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 2 ]; then
|
||||
printf "Purpose: Updates the allowed mailbox size (quota) for a user in iRedmail. \n"
|
||||
printf "Usage: sh increase-mailbox-quota.sh jeff@example.com 2048 \n"
|
||||
exit 0
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
# Read input
|
||||
address="$1"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 1 ]; then
|
||||
printf "Purpose: Determine if a given email address is an alias in iRedmail. \n"
|
||||
printf "Usage: sh is-address-an-alias.sh jeff@example.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
# Read input
|
||||
address="$1"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 1 ]; then
|
||||
printf "Purpose: Determine if a given email address has forwards set from itself to other email addreses in iRedmail. \n"
|
||||
printf "Usage: sh is-forward-from.sh jeff@example.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
# Read input
|
||||
address="$1"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 1 ]; then
|
||||
printf "Purpose: Determine if a given email address has forwards set from itself to other email addreses in iRedmail. \n"
|
||||
printf "Usage: sh is-forward-to.sh jeff@example.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
# psql -d vmail
|
||||
# sql> \i /path/to/output.sql;
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -gt 0 ]; then
|
||||
printf "Purpose: Lists active email accounts in iRedmail. \n"
|
||||
printf "Usage: sh list-active-accounts.sh \n"
|
||||
exit 0
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
# psql -d vmail
|
||||
# sql> \i /path/to/output.sql;
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -gt 0 ]; then
|
||||
printf "Purpose: Lists all email accounts in iRedmail from the mailbox table, does not include aliases. \n"
|
||||
printf "Usage: sh list-all-accounts.sh \n"
|
||||
exit 0
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
# psql -d vmail
|
||||
# sql> \i /path/to/output.sql;
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -gt 0 ]; then
|
||||
printf "Purpose: Lists all from the forwardings table that are not just regular accounts in iRedmail. \n"
|
||||
printf "Usage: sh list-all-but-regular-accounts.sh \n"
|
||||
exit 0
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
# psql -d vmail
|
||||
# sql> \i /path/to/output.sql;
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -gt 0 ]; then
|
||||
printf "Purpose: Lists all active email forwarding configurations in iRedmail. \n"
|
||||
printf "Usage: sh list-forwarding-active.sh \n"
|
||||
exit 0
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
# psql -d vmail
|
||||
# sql> \i /path/to/output.sql;
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -gt 0 ]; then
|
||||
printf "Purpose: Lists inactive email accounts in iRedmail. \n"
|
||||
printf "Usage: sh list-inactive-accounts.sh \n"
|
||||
exit 0
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
# psql -d vmail
|
||||
# sql> \i /path/to/output.sql;
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -gt 0 ]; then
|
||||
printf "Purpose: Lists mailboxes in vmail db in used_quota from largest to smallest in iRedmail. \n"
|
||||
printf "Usage: sh list-largest-to-smallest-mailbox.sh \n"
|
||||
exit 0
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
# psql -d vmail
|
||||
# sql> \i /path/to/output.sql;
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -gt 0 ]; then
|
||||
printf "Purpose: Lists top 10 mailboxes in vmail db in used_quota from largest to smallest in iRedmail. \n"
|
||||
printf "Usage: sh list-top-10-mailbox.sh \n"
|
||||
exit 0
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
# Read input
|
||||
aliasName="$1"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 1 ]; then
|
||||
printf "Purpose: Creates an alias address which can be used to send email to multiple users at once when they are added 'onto' the alias in iRedmail. \n"
|
||||
printf "Usage: \n"
|
||||
exit 0
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Remove a users entry entirely from the domain_admins table in iRedMail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# sh remove-domain-admin.sh user@example.com
|
||||
#
|
||||
# This will print SQL commands on the console directly, you can redirect the
|
||||
# output to a file for further use like this:
|
||||
#
|
||||
# sh remove-domain-admin.sh user@example.com > output.sql
|
||||
#
|
||||
# Import output.sql into SQL database like below:
|
||||
#
|
||||
# mysql -uroot -p
|
||||
# mysql> USE vmail;
|
||||
# mysql> SOURCE /path/to/output.sql;
|
||||
#
|
||||
# psql -d vmail
|
||||
# sql> \i /path/to/output.sql;
|
||||
|
||||
# Read input
|
||||
username="$1"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 1 ]; then
|
||||
printf "Purpose: Remove a users entry entirely from the domain_admins table in iRedMail. \n"
|
||||
printf "Usage: sh remove-domain-admin.sh user@example.com \n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf "DELETE from domain_admins WHERE username = '${username}'; \n"
|
|
@ -25,7 +25,7 @@
|
|||
# Read input
|
||||
domain="$1"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 1 ]; then
|
||||
printf "Purpose: Remove a domain from iRedMail. This does not remove associates mail accounts or mailboxes. \n"
|
||||
printf "Usage: sh remove-domain.sh example.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
address="$1"
|
||||
destinationAddress="$2"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 2 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 2 ]; then
|
||||
printf "Purpose: Remove mail forwarding for a user or remove a user from an alias in iRedmail. \n"
|
||||
printf "Usage: sh remove-forwarding.sh alias@mydomain.com jeff@gmail.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
# Read input
|
||||
address="$1"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 1 ]; then
|
||||
printf "Purpose: Removes a user account from the database in iRedmail, this does not delete the mailbox stored on the filesystem. \n"
|
||||
printf "Usage: sh remove-user.sh jeff@example.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Removes the whole forwarding address and all forwards associated to it in iRedMail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Example usage: sh remove-whole-forward.sh contact@mydomain.com
|
||||
#
|
||||
# This will print SQL commands on the console directly, you can redirect the
|
||||
# output to a file for further use like this:
|
||||
#
|
||||
# sh remove-whole-forward.sh contact@mydomain.com > output.sql
|
||||
#
|
||||
# Import output.sql into SQL database like below:
|
||||
#
|
||||
# mysql -uroot -p
|
||||
# mysql> USE vmail;
|
||||
# mysql> SOURCE /path/to/output.sql;
|
||||
#
|
||||
# psql -d vmail
|
||||
# sql> \i /path/to/output.sql;
|
||||
|
||||
# Read input
|
||||
address="$1"
|
||||
destinationAddress="$2"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 2 ]; then
|
||||
printf "Purpose: Removes the whole forwarding address and all forwards associated to it in iRedMail. \n"
|
||||
printf "Usage: sh remove-whole-forward.sh contact@mydomain.com \n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf "DELETE FROM forwardings WHERE address = '${address}'; \n"
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Revokes a users domain administrator permission in iRedMail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# sh revoke-domain-admin.sh user@example.com
|
||||
#
|
||||
# This will print SQL commands on the console directly, you can redirect the
|
||||
# output to a file for further use like this:
|
||||
#
|
||||
# sh revoke-domain-admin.sh user@example.com > output.sql
|
||||
#
|
||||
# Import output.sql into SQL database like below:
|
||||
#
|
||||
# mysql -uroot -p
|
||||
# mysql> USE vmail;
|
||||
# mysql> SOURCE /path/to/output.sql;
|
||||
#
|
||||
# psql -d vmail
|
||||
# sql> \i /path/to/output.sql;
|
||||
|
||||
# Read input
|
||||
username="$1"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 1 ] || [ $# -gt 1 ]; then
|
||||
printf "Purpose: Revokes a users domain administrator permission in iRedMail. \n"
|
||||
printf "Usage: sh revoke-domain-admin.sh user@example.com \n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf "UPDATE domain_admins SET active = '0' WHERE username = '$username';\n"
|
|
@ -24,7 +24,7 @@
|
|||
# Read input
|
||||
address="$1"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 1 ]; then
|
||||
printf "Purpose: Re-activate a user account iRedmail. \n"
|
||||
printf "Usage: sh set-account-active.sh jeff@example.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
# Read input
|
||||
address="$1"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 1 ]; then
|
||||
printf "Purpose: Deactivate a user account iRedmail. \n"
|
||||
printf "Usage: sh set-account-inactive.sh jeff@example.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
# Read input
|
||||
aliasName="$1"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 1 ]; then
|
||||
printf "Purpose: Re-activates, or turns back on, an alias in iRedmail. \n"
|
||||
printf "Usage: sh set-alias-active.sh alias@mydomain.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
# Read input
|
||||
aliasName="$1"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 1 ]; then
|
||||
printf "Purpose: Updates an alias to become inactive in iRedmail. \n"
|
||||
printf "Usage: sh set-alias-inactive.sh alias@mydomain.com \n"
|
||||
exit 0
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
address="$1"
|
||||
password="$2"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 2 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 2 ]; then
|
||||
printf "Purpose: Updates the password for a user account in iRedmail. \n"
|
||||
printf "Note: You can also use this script to change hashing algorithms. If you made an account with SHA512 but actually wanted bcrypt you can change that by updating the password."
|
||||
printf "Instructions:
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Updates the default quota for mailbox size for all domains, setting applies to all newly created mailboxes, in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Note: 2048 is the new domain quota for NEWLY created mailboxes.
|
||||
# sh update-all-quota.sh example.com 2048
|
||||
#
|
||||
# This will print SQL commands on the console directly, you can redirect the
|
||||
# output to a file for further use like this:
|
||||
#
|
||||
# sh update-all-domain-quota.sh 2048 > output.sql
|
||||
#
|
||||
# Import output.sql into SQL database like below:
|
||||
#
|
||||
# mysql -uroot -p
|
||||
# mysql> USE vmail;
|
||||
# mysql> SOURCE /path/to/output.sql;
|
||||
#
|
||||
# psql -d vmail
|
||||
# sql> \i /path/to/output.sql;
|
||||
|
||||
# Read input
|
||||
domain="$1"
|
||||
quota="$2"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 2 ]; then
|
||||
printf "Purpose: Updates the default quota for mailbox size for all domains, setting applies to all newly created mailboxes, in iRedmail. \n"
|
||||
printf "Usage: sh update-all-domain-quota.sh 2048 \n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf "UPDATE domain SET settings = 'default_user_quota:$quota;';\n"
|
|
@ -26,7 +26,7 @@
|
|||
domain="$1"
|
||||
quota="$2"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 2 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 2 ]; then
|
||||
printf "Purpose: Updates the default quota for mailbox size for a domain in iRedmail. \n"
|
||||
printf "Usage: sh update-domain-quota.sh example.com 2048 \n"
|
||||
exit 0
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Change domain name of an existing domain and associated mail accounts in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# WARNING: This changes ONLY the SQL side, the mail directory needs to be renamed as well as any existing maildir to reflect the new domain.
|
||||
#
|
||||
# sh update-domain.sh old-domain.com new-domain.com
|
||||
#
|
||||
# This will print SQL commands on the console directly, you can redirect the
|
||||
# output to a file for further use like this:
|
||||
#
|
||||
# sh update-domain.sh old-domain.com new-domain.com > output.sql
|
||||
#
|
||||
# Import output.sql into SQL database like below:
|
||||
#
|
||||
# mysql -uroot -p
|
||||
# mysql> USE vmail;
|
||||
# mysql> SOURCE /path/to/output.sql;
|
||||
#
|
||||
# psql -U vmailadmin -d vmail
|
||||
# sql> \i /path/to/output.sql;
|
||||
|
||||
# Read input
|
||||
current="$1"
|
||||
new="$2"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 2 ]; then
|
||||
printf "Purpose: Change domain name of an existing domain and associated mail accounts in iRedmail. \n"
|
||||
printf "WARNING: This changes ONLY the SQL side, the mail directory needs to be renamed as well as any existing maildir to reflect the new domain. \n"
|
||||
printf "Usage: sh update-domain.sh old-domain.com new-domain.com \n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# alias table
|
||||
printf "UPDATE alias SET domain = '$new' WHERE domain = '$current';\n"
|
||||
printf "UPDATE alias SET username = replace(username, '$current', '$new') WHERE address LIKE '$current'';\n"
|
||||
|
||||
# deleted_mailboxes table
|
||||
printf "UPDATE deleted_mailboxes SET maildir = regexp_replace(maildir, '\m$current\M', '$new', 'gi') WHERE domain LIKE '$current';\n"
|
||||
printf "UPDATE deleted_mailboxes SET username = regexp_replace(username, '\m$current\M', '$new', 'gi') WHERE domain LIKE '$current';\n"
|
||||
printf "UPDATE deleted_mailboxes SET domain = '$new' WHERE domain = '$current';\n"
|
||||
|
||||
# domain table
|
||||
printf "UPDATE domain SET domain = '$new' WHERE domain = '$current';\n"
|
||||
|
||||
# domain_admins table
|
||||
printf "UPDATE domain_admins SET username = regexp_replace(username, '\m$current\M', '$new', 'gi') WHERE username LIKE '%$current';\n"
|
||||
|
||||
# forwardings table
|
||||
printf "UPDATE forwardings SET address = regexp_replace(address, '\m$current\M', '$new', 'gi') WHERE domain LIKE '$current';\n"
|
||||
printf "UPDATE forwardings SET forwarding = regexp_replace(forwarding, '\m$current\M', '$new', 'gi') WHERE dest_domain LIKE '$current';\n"
|
||||
printf "UPDATE forwardings SET domain = '$new' WHERE domain = '$current';\n"
|
||||
printf "UPDATE forwardings SET dest_domain = '$new' WHERE dest_domain = '$current';\n"
|
||||
|
||||
# mailbox table
|
||||
printf "UPDATE mailbox SET maildir = regexp_replace(maildir, '\m$current\M', '$new', 'gi') WHERE domain LIKE '$current';\n"
|
||||
printf "UPDATE mailbox SET username = regexp_replace(username, '\m$current\M', '$new', 'gi') WHERE domain LIKE '$current';\n"
|
||||
printf "UPDATE mailbox SET domain = '$new' WHERE domain = '$current';\n"
|
||||
|
||||
# used_quota table
|
||||
printf "UPDATE used_quota SET username = regexp_replace(username, '\m$current\M', '$new', 'gi') WHERE domain LIKE '$current';\n"
|
||||
printf "UPDATE used_quota SET domain = '$new' WHERE domain = '$current';\n"
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
current="$1"
|
||||
new="$2"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 2 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 2 ]; then
|
||||
printf "Purpose: Updates the storagebasedirectory in iRedmail, this by default is /var/vmail. \n"
|
||||
printf "Usage: sh update-storagebasedirectory.sh /var/vmail /var/someNewLocation \n"
|
||||
exit 0
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
current="$1"
|
||||
new="$2"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 2 ]; then
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -ne 2 ]; then
|
||||
printf "Purpose: Updates the storagenode in iRedmail, this by default is vmail1. \n"
|
||||
printf "Usage: sh update-storagenode.sh vmail1 vmail2 \n"
|
||||
exit 0
|
||||
|
|
Loading…
Reference in New Issue