first commit
This commit is contained in:
commit
93f42b9759
46
README
Normal file
46
README
Normal file
|
@ -0,0 +1,46 @@
|
|||
|
||||
Administrative scripts for iRedMail, useful if you do not use iRedAdmin.
|
||||
|
||||
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.
|
||||
|
||||
There are scripts so far to do the following administrative functions:
|
||||
|
||||
|
||||
| Category | Script | What it does |
|
||||
| --- | --- | --- |
|
||||
| User accounts | | |
|
||||
| | remove-user.sh | Delete a user |
|
||||
| | update-account-password.sh | Update a users password |
|
||||
| | disable-mail-forwarding.sh | De-activate a user account |
|
||||
| | disable-mail-forwarding.sh | Re-activate a user account |
|
||||
| | list-active-accounts.sh | List active user accounts |
|
||||
| | list-inactive-accounts.sh | List inactive user accounts |
|
||||
| | list-all-but-regular-accounts.sh | Lists all from the forwardings table that are not just regular accounts |
|
||||
| | enable-pop3-for-user.sh | Enables pop3 for a user account, enables usage of this protocol |
|
||||
| | enable-imap-for-user.sh | Enables IMAP for a user account, enables usage of this protocol |
|
||||
| | disable-pop3-for-user.sh | Disables pop3 for a user account, prevents usage of this protocol |
|
||||
| | disable-imap-for-user.sh | Disables IMAP for a user account, prevents usage of this protocol |
|
||||
| | is-address-an-alias.sh | Check if a given email address is an alias |
|
||||
| | increase-mailbox-quota.sh | Increases the mail box quota size for a given user |
|
||||
| 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. |
|
||||
| | remove-alias.sh | Remove a given alias |
|
||||
| | set-alias-active.sh | Set an alias as active |
|
||||
| | set-alias-inactive.sh | Set an alias as inactive |
|
||||
| Forwarding | | |
|
||||
| | list-forwarding.sh | List any configured forwards |
|
||||
| | remove-forwarding.sh | Deletes mail forwarding from a given address to another entered address |
|
||||
| | 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 |
|
||||
| Misc | | |
|
||||
| | list-top-10-mailbox.sh | List the top 10 mailboxes by size |
|
||||
| | list-largest-to-smallest-mailbox.sh | List mailbox size from largest to smallest |
|
||||
| | update-storagenode.sh | Mail is located at /var/vmail/vmail1 by default, this script helps change the database value of 'vmail1' to a new value |
|
||||
| | update-storagebasedirectory.sh | The base directory for mail is located at /var/vmail by default, this script helps change the database value of '/var/vmail' to a new value |
|
||||
| | update-domain-quota.sh | Updates the domain wide mailbox quota |
|
||||
| | enable-domain.sh | Enables a domain in the database, must exist already |
|
||||
| | disable-domain.sh | Disables a domain in the database |
|
||||
|
40
add-mail-forward.sh
Normal file
40
add-mail-forward.sh
Normal file
|
@ -0,0 +1,40 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Creates a mail forwarding setup to direct email sent to user@example.com otherUser@example.com in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
# Reference: https://docs.iredmail.org/sql.user.mail.forwarding.html
|
||||
# Note: Be careful if a user is set to forward to itself (same configuration as normal user) as it will save a copy of all email still and if left unchecked the space used by mail could add up.
|
||||
#
|
||||
# Example usage: sh add-mail-forward.sh user@example.com otherUser@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 add-mail-forward.sh user@example.com otherUser@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
|
||||
address="$1"
|
||||
forwardToEmail="$2"
|
||||
|
||||
addressDomain=$(echo $address | cut -f 2 -d '@')
|
||||
forwardToEmailDomain=$(echo $forwardToEmail | cut -f 2 -d '@')
|
||||
|
||||
cat <<EOF
|
||||
INSERT INTO forwardings (address, forwarding,
|
||||
domain, dest_domain,
|
||||
is_forwarding, active)
|
||||
VALUES ('${address}', '${forwardToEmail}',
|
||||
'${addressDomain}', '${forwardToEmailDomain}',
|
||||
1, 1);
|
||||
EOF
|
41
add-user-to-alias.sh
Normal file
41
add-user-to-alias.sh
Normal file
|
@ -0,0 +1,41 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Add a user to an alias, otherwise known as a distribution list, in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
# Reference: https://docs.iredmail.org/sql.create.mail.alias
|
||||
#
|
||||
# Note: The distribution list needs to exist first before you can add users to it.
|
||||
# Example usage: sh add-user-to-alias.sh alias@mydomain.com jeff@gmail.com
|
||||
#
|
||||
# This will print SQL commands on the console directly, you can redirect the
|
||||
# output to a file for further use like this:
|
||||
#
|
||||
# sh add-user-to-alias.sh alias@mydomain.com jeff@gmail.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
|
||||
aliasAccount="$1"
|
||||
sendToEmail="$2"
|
||||
|
||||
aliasAccountDomain=$(echo $aliasAccount | cut -f 2 -d '@')
|
||||
sendToEmailDomain=$(echo $sendToEmail | cut -f 2 -d '@')
|
||||
|
||||
cat <<EOF
|
||||
INSERT INTO forwardings (address, forwarding,
|
||||
domain, dest_domain,
|
||||
is_list, active)
|
||||
VALUES ('${aliasAccount}', '${sendToEmail}',
|
||||
'${aliasAccountDomain}', '${sendToEmailDomain}',
|
||||
1, 1);
|
||||
|
||||
EOF
|
32
create-alias.sh
Normal file
32
create-alias.sh
Normal file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Creates an alias account, otherwise known as a Distribution List, in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Example usage: sh create-alias.sh alias@mydomain.com 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 create-alias.sh alias@mydomain.com 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
|
||||
dlName="$1"
|
||||
domainName="$2"
|
||||
|
||||
cat <<EOF
|
||||
INSERT INTO alias (address, domain, active)
|
||||
VALUES ('${dlName}', '${domainName}', 1);
|
||||
|
||||
EOF
|
27
disable-domain.sh
Normal file
27
disable-domain.sh
Normal file
|
@ -0,0 +1,27 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Disables a domain in iRedMail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# sh disable-domain.sh 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 disable-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
|
||||
domain="$1"
|
||||
|
||||
printf "UPDATE domain SET active = '0' WHERE domain = '$domain';\n"
|
29
disable-imap-for-user.sh
Normal file
29
disable-imap-for-user.sh
Normal file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Disables enableimap,enableimapsecured,enableimaptls in the mailbox table for a given user to be 0 (disabled) in iRedmail so to disable IMAP.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# sh disable-imap-for-user.sh jeff@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 disable-imap-for-user.sh jeff@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"
|
||||
|
||||
printf "UPDATE mailbox SET enableimap = '0' WHERE username = '$username';\n"
|
||||
printf "UPDATE mailbox SET enableimapsecured = '0' WHERE username = '$username';\n"
|
||||
printf "UPDATE mailbox SET enableimaptls = '0' WHERE username = '$username';\n"
|
28
disable-mail-forwarding.sh
Normal file
28
disable-mail-forwarding.sh
Normal file
|
@ -0,0 +1,28 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Disable mail forwarding or from an alias, from a user account to another mail account in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# sh disable-mail-forwarding.sh fromUser@example.com toUser@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 disable-mail-forwarding.sh fromUser@example.com toUser@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
|
||||
fromUser="$1"
|
||||
toUser="$2"
|
||||
|
||||
printf "UPDATE forwardings SET active = '0' where address = '$fromUser' AND forwarding = '$toUser';\n"
|
29
disable-pop3-for-user.sh
Normal file
29
disable-pop3-for-user.sh
Normal file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Disables enablepop3,enablepop3secured,enablepop3tls in the mailbox table for a given user to be 0 (disabled) in iRedmail so to disable pop3.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# sh disable-pop3-for-user.sh jeff@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 disable-pop3-for-user.sh jeff@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"
|
||||
|
||||
printf "UPDATE mailbox SET enablepop3 = '0' WHERE username = '$username';\n"
|
||||
printf "UPDATE mailbox SET enablepop3secured = '0' WHERE username = '$username';\n"
|
||||
printf "UPDATE mailbox SET enablepop3tls = '0' WHERE username = '$username';\n"
|
27
enable-domain.sh
Normal file
27
enable-domain.sh
Normal file
|
@ -0,0 +1,27 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Re-enables a disabled domain in iRedMail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# sh enable-domain.sh 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 enable-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
|
||||
domain="$1"
|
||||
|
||||
printf "UPDATE domain SET active = '1' WHERE domain = '$domain';\n"
|
29
enable-imap-for-user.sh
Normal file
29
enable-imap-for-user.sh
Normal file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Enables enableimap,enableimapsecured,enableimaptls in the mailbox table for a given user to be 1 (enabled) in iRedmail so to enable IMAP.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# sh enable-imap-for-user.sh jeff@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 enable-imap-for-user.sh jeff@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"
|
||||
|
||||
printf "UPDATE mailbox SET enableimap = '1' WHERE username = '$username';\n"
|
||||
printf "UPDATE mailbox SET enableimapsecured = '1' WHERE username = '$username';\n"
|
||||
printf "UPDATE mailbox SET enableimaptls = '1' WHERE username = '$username';\n"
|
28
enable-mail-forwarding.sh
Normal file
28
enable-mail-forwarding.sh
Normal file
|
@ -0,0 +1,28 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Re-enable mail forwarding or from an alias, from a user account to another mail account in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# sh enable-mail-forwarding.sh fromUser@example.com toUser@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 enable-mail-forwarding.sh fromUser@example.com toUser@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
|
||||
fromUser="$1"
|
||||
toUser="$2"
|
||||
|
||||
printf "UPDATE forwardings SET active = '1' where address = '$fromUser' AND forwarding = '$toUser';\n"
|
29
enable-pop3-for-user.sh
Normal file
29
enable-pop3-for-user.sh
Normal file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Enables enablepop3,enablepop3secured,enablepop3tls in the mailbox table for a given user to be 1 (enabled) in iRedmail so to disable pop3.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# sh enable-pop3-for-user.sh jeff@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 enable-pop3-for-user.sh jeff@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"
|
||||
|
||||
printf "UPDATE mailbox SET enablepop3 = '1' WHERE username = '$username';\n"
|
||||
printf "UPDATE mailbox SET enablepop3secured = '1' WHERE username = '$username';\n"
|
||||
printf "UPDATE mailbox SET enablepop3tls = '1' WHERE username = '$username';\n"
|
31
increase-mailbox-quota.sh
Normal file
31
increase-mailbox-quota.sh
Normal file
|
@ -0,0 +1,31 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Updates the allowed mailbox size (quota) for a user in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Example usage: sh increase-mailbox-quota.sh jeff@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:
|
||||
#
|
||||
# Note: Enter the size as mb. The default quota is 1024 mb.
|
||||
# sh increase-mailbox-quota.sh jeff@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
|
||||
address="$1"
|
||||
quota="$2"
|
||||
|
||||
cat <<EOF
|
||||
UPDATE mailbox SET quota = '${quota}' WHERE username = '${address}';
|
||||
EOF
|
30
is-address-an-alias.sh
Normal file
30
is-address-an-alias.sh
Normal file
|
@ -0,0 +1,30 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Determine if a given email address is an alias in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
# Reference: https://docs.iredmail.org/sql.create.mail.alias
|
||||
#
|
||||
# sh is-address-an-alias.sh jeff@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 is-address-an-alias.sh jeff@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
|
||||
address="$1"
|
||||
|
||||
cat <<EOF
|
||||
SELECT id,address,forwarding,domain FROM forwardings WHERE is_list = '1' AND address = '${address}';
|
||||
EOF
|
29
is-forward-from.sh
Normal file
29
is-forward-from.sh
Normal file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Determine if a given email address has forwards set from itself to other email addreses in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# sh is-forward-from.sh jeff@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 is-forward-from.sh jeff@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
|
||||
address="$1"
|
||||
|
||||
cat <<EOF
|
||||
SELECT id,address,forwarding,domain FROM forwardings WHERE is_forwarding = '1' AND address = '${address}';
|
||||
EOF
|
30
is-forward-to.sh
Normal file
30
is-forward-to.sh
Normal file
|
@ -0,0 +1,30 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Determine if a given email address has forwards set from itself to other email addreses in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
# Note: If you see an address to itself in the forwarding column this is normal and is required for a regular account and mailbox to function.
|
||||
#
|
||||
# sh is-forward-to.sh jeff@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 is-forward-to.sh jeff@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
|
||||
address="$1"
|
||||
|
||||
cat <<EOF
|
||||
SELECT id,address,forwarding,domain FROM forwardings WHERE is_forwarding = '1' AND forwarding = '${address}';
|
||||
EOF
|
26
list-active-accounts.sh
Normal file
26
list-active-accounts.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Lists active email accounts in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Example usage: sh list-active-accounts.sh
|
||||
#
|
||||
# This will print SQL commands on the console directly, you can redirect the
|
||||
# output to a file for further use like this:
|
||||
#
|
||||
# sh list-active-accounts.sh > 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;
|
||||
|
||||
cat <<EOF
|
||||
select username FROM mailbox WHERE active = 1;
|
||||
EOF
|
26
list-all-accounts.sh
Normal file
26
list-all-accounts.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Lists all email accounts in iRedmail from the mailbox table, does not include aliases.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Example usage: sh list-all-accounts.sh
|
||||
#
|
||||
# This will print SQL commands on the console directly, you can redirect the
|
||||
# output to a file for further use like this:
|
||||
#
|
||||
# sh list-all-accounts.sh > 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;
|
||||
|
||||
cat <<EOF
|
||||
select username FROM mailbox;
|
||||
EOF
|
26
list-all-but-regular-accounts.sh
Normal file
26
list-all-but-regular-accounts.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Lists all from the forwardings table that are not just regular accounts in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Example usage: sh list-all-but-regular-accounts
|
||||
#
|
||||
# This will print SQL commands on the console directly, you can redirect the
|
||||
# output to a file for further use like this:
|
||||
#
|
||||
# sh list-all-but-regular-accounts > 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;
|
||||
|
||||
cat <<EOF
|
||||
select id,address,forwarding,domain,active FROM forwardings WHERE address != forwarding;
|
||||
EOF
|
26
list-forwarding.sh
Normal file
26
list-forwarding.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Lists all active email forwarding configurations in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Example usage: sh list-forwarding-active.sh
|
||||
#
|
||||
# This will print SQL commands on the console directly, you can redirect the
|
||||
# output to a file for further use like this:
|
||||
#
|
||||
# sh list-forwarding-active > 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;
|
||||
|
||||
cat <<EOF
|
||||
select id,address,forwarding,domain,active FROM forwardings WHERE is_forwarding = 0;
|
||||
EOF
|
26
list-inactive-accounts.sh
Normal file
26
list-inactive-accounts.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Lists inactive email accounts in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Example usage: sh list-inactive-accounts.sh
|
||||
#
|
||||
# This will print SQL commands on the console directly, you can redirect the
|
||||
# output to a file for further use like this:
|
||||
#
|
||||
# sh list-inactive-accounts.sh > 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;
|
||||
|
||||
cat <<EOF
|
||||
select username FROM mailbox WHERE active = 0;
|
||||
EOF
|
26
list-largest-to-smallest-mailbox.sh
Normal file
26
list-largest-to-smallest-mailbox.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Lists mailboxes in vmail db in used_quota from largest to smallest in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Example usage: sh list-largest-to-smallest-mailbox.sh
|
||||
#
|
||||
# This will print SQL commands on the console directly, you can redirect the
|
||||
# output to a file for further use like this:
|
||||
#
|
||||
# sh list-largest-to-smallest-mailbox.sh > 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;
|
||||
|
||||
cat <<EOF
|
||||
select * FROM used_quota ORDER BY bytes DESC;
|
||||
EOF
|
26
list-top-10-mailbox.sh
Normal file
26
list-top-10-mailbox.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Lists top 10 mailboxes in vmail db in used_quota from largest to smallest in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Example usage: sh list-top-10-mailbox.sh
|
||||
#
|
||||
# This will print SQL commands on the console directly, you can redirect the
|
||||
# output to a file for further use like this:
|
||||
#
|
||||
# sh list-top-10-mailbox.sh > 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;
|
||||
|
||||
cat <<EOF
|
||||
select * FROM used_quota ORDER BY bytes DESC limit 10;
|
||||
EOF
|
29
remove-alias.sh
Normal file
29
remove-alias.sh
Normal file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Creates an alias account, otherwise known as a Distribution List, in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Example usage: sh create-dl.sh alias@mydomain.com 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 create-dl.sh alias@mydomain.com 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
|
||||
aliasName="$1"
|
||||
|
||||
cat <<EOF
|
||||
DELETE from alias WHERE address = '${aliasName}';
|
||||
EOF
|
32
remove-forwarding.sh
Normal file
32
remove-forwarding.sh
Normal file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Remove mail forwarding for a user or remove a user from an alias in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Example usage: sh remove-forwarding.sh alias@mydomain.com jeff@gmail.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-forwarding.sh alias@mydomain.com jeff@gmail.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"
|
||||
|
||||
cat <<EOF
|
||||
DELETE FROM forwardings
|
||||
WHERE address = '${address}'
|
||||
AND forwarding = '${destinationAddress}';
|
||||
EOF
|
30
remove-user.sh
Normal file
30
remove-user.sh
Normal file
|
@ -0,0 +1,30 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Removes a user account from the database in iRedmail, this does not delete the mailbox stored on the filesystem.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Example usage: sh remove-user.sh jeff@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 sh remove-user.sh jeff@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
|
||||
address="$1"
|
||||
|
||||
cat <<EOF
|
||||
DELETE from forwardings WHERE address = '${address}' AND forwarding = '${address}';
|
||||
DELETE from mailbox WHERE username = '${address}';
|
||||
EOF
|
29
set-account-active.sh
Normal file
29
set-account-active.sh
Normal file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Re-activate a user account iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Example usage: sh set-account-active.sh jeff@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 sh set-account-active.sh jeff@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
|
||||
address="$1"
|
||||
|
||||
cat <<EOF
|
||||
UPDATE forwardings SET active = '1' WHERE address = '${address}' AND forwarding = '${address}';
|
||||
EOF
|
29
set-account-inactive.sh
Normal file
29
set-account-inactive.sh
Normal file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Deactivate a user account iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Example usage: sh set-account-inactive.sh jeff@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 sh set-account-inactive.sh jeff@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
|
||||
address="$1"
|
||||
|
||||
cat <<EOF
|
||||
UPDATE forwardings SET active = '0' WHERE address = '${address}' AND forwarding = '${address}';
|
||||
EOF
|
29
set-alias-active.sh
Normal file
29
set-alias-active.sh
Normal file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Updates an alias to become active, otherwise known as a Distribution List, in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Example usage: sh set-alias-active.sh alias@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 set-alias-active.sh alias@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
|
||||
aliasName="$1"
|
||||
|
||||
cat <<EOF
|
||||
UPDATE forwardings SET active = '1' WHERE address = '${aliasName}' AND forwarding != '${aliasName}';
|
||||
EOF
|
29
set-alias-inactive.sh
Normal file
29
set-alias-inactive.sh
Normal file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Updates an alias to become inactive, otherwise known as a Distribution List, in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Example usage: sh set-alias-inactive.sh alias@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 set-alias-inactive.sh alias@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
|
||||
aliasName="$1"
|
||||
|
||||
cat <<EOF
|
||||
UPDATE forwardings SET active = '0' WHERE address = '${aliasName}' AND forwarding != '${aliasName}';
|
||||
EOF
|
34
update-account-password.sh
Normal file
34
update-account-password.sh
Normal file
|
@ -0,0 +1,34 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Updates the password for a user account in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 1) First you must get the hashed password, use the following example. SSHA512 is recommended on Linux systems. BCRYPT is recommended on BSD systems.
|
||||
# SHA512: doveadm pw -s 'ssha512' -p '123456'
|
||||
# bcrypt: doveadm pw -s 'blf-crypt' -p '123456'
|
||||
# 2) Next use the hash with this script to get the SQL required to update the specified user account. Note for bcrypt passwords surround the password with an apostrophe on each side.
|
||||
# sh update-account-password.sh jeff@example.com {SSHA512}ZJrxEEz44aTyd/srPRU3RH4zThW4PHFIDSGYyADEE/D3QUyrgWmiKHyajWN2SQA4+VAk6X5ePaqwbMQqqICj3BCnhYgc/SDc
|
||||
#
|
||||
# This will print SQL commands on the console directly, you can redirect the
|
||||
# output to a file for further use like this:
|
||||
#
|
||||
# sh update-account-password.sh jeff@example.com {SSHA512}ZJrxEEz44aTyd/srPRU3RH4zThW4PHFIDSGYyADEE/D3QUyrgWmiKHyajWN2SQA4+VAk6X5ePaqwbMQqqICj3BCnhYgc/SDc > 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"
|
||||
password="$2"
|
||||
|
||||
printf "UPDATE mailbox SET password = '$password' where username = '$address';\n"
|
29
update-domain-quota.sh
Normal file
29
update-domain-quota.sh
Normal file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Updates the default quota for mailbox size for a domain in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Note: example.com is the name of your domain and 2048 is the new domain quota for NEWLY created mailboxes.
|
||||
# sh update-domain-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-domain-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"
|
||||
|
||||
printf "UPDATE domain SET settings = 'default_user_quota:$quota;' WHERE domain = '$domain';\n"
|
31
update-storagebasedirectory.sh
Normal file
31
update-storagebasedirectory.sh
Normal file
|
@ -0,0 +1,31 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Updates the storagebasedirectory in iRedmail, this by default is /var/vmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Note: /var/vmail is the default value and should NOT be changed without good reason.
|
||||
# Note #2: The files and folders on the file system will not be moved to the new location without you doing so.
|
||||
#
|
||||
# sh update-storagebasedirectory.sh /var/vmail /var/someNewLocation
|
||||
#
|
||||
# This will print SQL commands on the console directly, you can redirect the
|
||||
# output to a file for further use like this:
|
||||
#
|
||||
# sh update-storagebasedirectory.sh /var/vmail /var/someNewLocation > 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
|
||||
current="$1"
|
||||
new="$2"
|
||||
|
||||
printf "UPDATE mailbox SET storagebasedirectory = '$new' WHERE storagebasedirectory = '$current';\n"
|
31
update-storagenode.sh
Normal file
31
update-storagenode.sh
Normal file
|
@ -0,0 +1,31 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Updates the storagenode in iRedmail, this by default is vmail1.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Note: vmail1 is the default value and should NOT be changed without good reason.
|
||||
# Note #2: The files and folders on the file system will not be moved to the new location without you doing so.
|
||||
#
|
||||
# sh update-storagenode.sh vmail1 vmail2
|
||||
#
|
||||
# This will print SQL commands on the console directly, you can redirect the
|
||||
# output to a file for further use like this:
|
||||
#
|
||||
# sh update-storagenode.sh vmail1 vmail2 > 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
|
||||
current="$1"
|
||||
new="$2"
|
||||
|
||||
printf "UPDATE mailbox SET storagenode = '$new' WHERE storagenode = '$current';\n"
|
Loading…
Reference in a new issue