Updated a number of scripts, added help output with example and purpose, etc
This commit is contained in:
parent
3b99d88fec
commit
d43075468c
39
Scripts/add-mail-forward.sh
Normal file
39
Scripts/add-mail-forward.sh
Normal file
|
@ -0,0 +1,39 @@
|
|||
#!/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 with a mailbox 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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 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
|
||||
fi
|
||||
|
||||
addressDomain=$(echo $address | cut -f 2 -d '@')
|
||||
forwardToEmailDomain=$(echo $forwardToEmail | cut -f 2 -d '@')
|
||||
|
||||
printf "INSERT INTO forwardings (address, forwarding, domain, dest_domain, is_forwarding, active) VALUES ('${address}', '${forwardToEmail}', '${addressDomain}', '${forwardToEmailDomain}', 1, 1); \n"
|
39
Scripts/add-user-to-alias.sh
Normal file
39
Scripts/add-user-to-alias.sh
Normal file
|
@ -0,0 +1,39 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Add a user to an alias in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
# Reference: https://docs.iredmail.org/sql.create.mail.alias
|
||||
#
|
||||
# Note: The alias 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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 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
|
||||
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"
|
34
Scripts/create-alias.sh
Normal file
34
Scripts/create-alias.sh
Normal file
|
@ -0,0 +1,34 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Creates an alias in iRedmail, email sent to an alias goes to all addresses added onto the alias.
|
||||
# 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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 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
|
||||
fi
|
||||
|
||||
printf "INSERT INTO alias (address, domain, active) VALUES ('${dlName}', '${domainName}', 1); \n"
|
33
Scripts/disable-domain.sh
Normal file
33
Scripts/disable-domain.sh
Normal file
|
@ -0,0 +1,33 @@
|
|||
#!/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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
printf "Purpose: Disables a domain in iRedMail. \n"
|
||||
printf "Usage: sh disable-domain.sh example.com \n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf "UPDATE domain SET active = '0' WHERE domain = '$domain';\n"
|
35
Scripts/disable-imap-for-user.sh
Normal file
35
Scripts/disable-imap-for-user.sh
Normal file
|
@ -0,0 +1,35 @@
|
|||
#!/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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; 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
|
||||
fi
|
||||
|
||||
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"
|
34
Scripts/disable-mail-forwarding.sh
Normal file
34
Scripts/disable-mail-forwarding.sh
Normal file
|
@ -0,0 +1,34 @@
|
|||
#!/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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 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
|
||||
fi
|
||||
|
||||
printf "UPDATE forwardings SET active = '0' where address = '$fromUser' AND forwarding = '$toUser';\n"
|
35
Scripts/disable-pop3-for-user.sh
Normal file
35
Scripts/disable-pop3-for-user.sh
Normal file
|
@ -0,0 +1,35 @@
|
|||
#!/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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; 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
|
||||
fi
|
||||
|
||||
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"
|
33
Scripts/enable-domain.sh
Normal file
33
Scripts/enable-domain.sh
Normal file
|
@ -0,0 +1,33 @@
|
|||
#!/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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
printf "Purpose: Re-enables a disabled domain in iRedMail. \n"
|
||||
printf "Usage: sh enable-domain.sh example.com \n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf "UPDATE domain SET active = '1' WHERE domain = '$domain';\n"
|
35
Scripts/enable-imap-for-user.sh
Normal file
35
Scripts/enable-imap-for-user.sh
Normal file
|
@ -0,0 +1,35 @@
|
|||
#!/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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; 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
|
||||
fi
|
||||
|
||||
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"
|
34
Scripts/enable-mail-forwarding.sh
Normal file
34
Scripts/enable-mail-forwarding.sh
Normal file
|
@ -0,0 +1,34 @@
|
|||
#!/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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 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
|
||||
fi
|
||||
|
||||
printf "UPDATE forwardings SET active = '1' where address = '$fromUser' AND forwarding = '$toUser';\n"
|
35
Scripts/enable-pop3-for-user.sh
Normal file
35
Scripts/enable-pop3-for-user.sh
Normal file
|
@ -0,0 +1,35 @@
|
|||
#!/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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; 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
|
||||
fi
|
||||
|
||||
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"
|
36
Scripts/increase-mailbox-quota.sh
Normal file
36
Scripts/increase-mailbox-quota.sh
Normal file
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Updates the allowed mailbox size (quota) for a user in iRedmail.
|
||||
# License: 2-clause BSD license
|
||||
#
|
||||
# Note: Enter the size as mb. The default quota is 1024 mb.
|
||||
#
|
||||
# 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:
|
||||
#
|
||||
# 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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 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
|
||||
fi
|
||||
|
||||
printf "UPDATE mailbox SET quota = '${quota}' WHERE username = '${address}'; \n"
|
34
Scripts/is-address-an-alias.sh
Normal file
34
Scripts/is-address-an-alias.sh
Normal file
|
@ -0,0 +1,34 @@
|
|||
#!/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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; 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
|
||||
fi
|
||||
|
||||
printf "SELECT id,address,forwarding,domain FROM forwardings WHERE is_list = '1' AND address = '${address}'; \n"
|
33
Scripts/is-forward-from.sh
Normal file
33
Scripts/is-forward-from.sh
Normal file
|
@ -0,0 +1,33 @@
|
|||
#!/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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; 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
|
||||
fi
|
||||
|
||||
printf "SELECT id,address,forwarding,domain FROM forwardings WHERE is_forwarding = '1' AND address = '${address}'; \n"
|
34
Scripts/is-forward-to.sh
Normal file
34
Scripts/is-forward-to.sh
Normal file
|
@ -0,0 +1,34 @@
|
|||
#!/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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; 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
|
||||
fi
|
||||
|
||||
printf "SELECT id,address,forwarding,domain FROM forwardings WHERE is_forwarding = '1' AND forwarding = '${address}'; \n"
|
30
Scripts/list-active-accounts.sh
Normal file
30
Scripts/list-active-accounts.sh
Normal file
|
@ -0,0 +1,30 @@
|
|||
#!/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;
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ]; then
|
||||
printf "Purpose: Lists active email accounts in iRedmail. \n"
|
||||
printf "Usage: sh list-active-accounts.sh \n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf "select username FROM mailbox WHERE active = 1; \n"
|
30
Scripts/list-all-accounts.sh
Normal file
30
Scripts/list-all-accounts.sh
Normal file
|
@ -0,0 +1,30 @@
|
|||
#!/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;
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ]; 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
|
||||
fi
|
||||
|
||||
printf "select username FROM mailbox; \n"
|
30
Scripts/list-all-but-regular-accounts.sh
Normal file
30
Scripts/list-all-but-regular-accounts.sh
Normal file
|
@ -0,0 +1,30 @@
|
|||
#!/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.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-but-regular-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;
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ]; 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
|
||||
fi
|
||||
|
||||
printf "select id,address,forwarding,domain,active FROM forwardings WHERE address != forwarding; \n"
|
30
Scripts/list-forwarding.sh
Normal file
30
Scripts/list-forwarding.sh
Normal file
|
@ -0,0 +1,30 @@
|
|||
#!/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.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;
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ]; then
|
||||
printf "Purpose: Lists all active email forwarding configurations in iRedmail. \n"
|
||||
printf "Usage: sh list-forwarding-active.sh \n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf "select id,address,forwarding,domain,active FROM forwardings WHERE is_forwarding = 0; \n"
|
30
Scripts/list-inactive-accounts.sh
Normal file
30
Scripts/list-inactive-accounts.sh
Normal file
|
@ -0,0 +1,30 @@
|
|||
#!/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;
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ]; then
|
||||
printf "Purpose: Lists inactive email accounts in iRedmail. \n"
|
||||
printf "Usage: sh list-inactive-accounts.sh \n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf "select username FROM mailbox WHERE active = 0; \n"
|
30
Scripts/list-largest-to-smallest-mailbox.sh
Normal file
30
Scripts/list-largest-to-smallest-mailbox.sh
Normal file
|
@ -0,0 +1,30 @@
|
|||
#!/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;
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ]; 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
|
||||
fi
|
||||
|
||||
printf "select * FROM used_quota ORDER BY bytes DESC; \n"
|
30
Scripts/list-top-10-mailbox.sh
Normal file
30
Scripts/list-top-10-mailbox.sh
Normal file
|
@ -0,0 +1,30 @@
|
|||
#!/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;
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ]; 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
|
||||
fi
|
||||
|
||||
printf "select * FROM used_quota ORDER BY bytes DESC limit 10; \n"
|
33
Scripts/remove-alias.sh
Normal file
33
Scripts/remove-alias.sh
Normal file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# 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.
|
||||
# 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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; 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
|
||||
fi
|
||||
|
||||
printf "DELETE from alias WHERE address = '${aliasName}'; \n"
|
34
Scripts/remove-forwarding.sh
Normal file
34
Scripts/remove-forwarding.sh
Normal file
|
@ -0,0 +1,34 @@
|
|||
#!/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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 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
|
||||
fi
|
||||
|
||||
printf "DELETE FROM forwardings WHERE address = '${address}' AND forwarding = '${destinationAddress}'; \n"
|
34
Scripts/remove-user.sh
Normal file
34
Scripts/remove-user.sh
Normal file
|
@ -0,0 +1,34 @@
|
|||
#!/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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; 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
|
||||
fi
|
||||
|
||||
printf "DELETE from forwardings WHERE address = '${address}' AND forwarding = '${address}'; \n"
|
||||
printf "DELETE from mailbox WHERE username = '${address}'; \n"
|
33
Scripts/set-account-active.sh
Normal file
33
Scripts/set-account-active.sh
Normal file
|
@ -0,0 +1,33 @@
|
|||
#!/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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
printf "Purpose: Re-activate a user account iRedmail. \n"
|
||||
printf "Usage: sh set-account-active.sh jeff@example.com \n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf "UPDATE forwardings SET active = '1' WHERE address = '${address}' AND forwarding = '${address}'; \n"
|
33
Scripts/set-account-inactive.sh
Normal file
33
Scripts/set-account-inactive.sh
Normal file
|
@ -0,0 +1,33 @@
|
|||
#!/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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; then
|
||||
printf "Purpose: Deactivate a user account iRedmail. \n"
|
||||
printf "Usage: sh set-account-inactive.sh jeff@example.com \n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf "UPDATE forwardings SET active = '0' WHERE address = '${address}' AND forwarding = '${address}'; \n"
|
33
Scripts/set-alias-active.sh
Normal file
33
Scripts/set-alias-active.sh
Normal file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Re-activates, or turns back on, an alias 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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; 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
|
||||
fi
|
||||
|
||||
printf "UPDATE forwardings SET active = '1' WHERE address = '${aliasName}' AND forwarding != '${aliasName}'; \n"
|
33
Scripts/set-alias-inactive.sh
Normal file
33
Scripts/set-alias-inactive.sh
Normal file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Author: Daulton
|
||||
# Website: daulton.ca
|
||||
# Purpose: Updates an alias to become inactive 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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -eq 0 ]; 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
|
||||
fi
|
||||
|
||||
printf "UPDATE forwardings SET active = '0' WHERE address = '${aliasName}' AND forwarding != '${aliasName}'; \n"
|
49
Scripts/update-account-password.sh
Normal file
49
Scripts/update-account-password.sh
Normal file
|
@ -0,0 +1,49 @@
|
|||
#!/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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 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:
|
||||
1) First you must get the hashed password, use the following example. SSHA512 is recommended on Linux systems. BCRYPT is recommended on BSD systems.\n
|
||||
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. \n"
|
||||
|
||||
printf "Usage: sh update-account-password.sh jeff@example.com {SSHA512}ZJrxEEz44aTyd/srPRU3RH4zThW4PHFIDSGYyADEE/D3QUyrgWmiKHyajWN2SQA4+VAk6X5ePaqwbMQqqICj3BCnhYgc/SDc \n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf "UPDATE mailbox SET password = '$password' where username = '$address';\n"
|
35
Scripts/update-domain-quota.sh
Normal file
35
Scripts/update-domain-quota.sh
Normal file
|
@ -0,0 +1,35 @@
|
|||
#!/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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 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
|
||||
fi
|
||||
|
||||
printf "UPDATE domain SET settings = 'default_user_quota:$quota;' WHERE domain = '$domain';\n"
|
37
Scripts/update-storagebasedirectory.sh
Normal file
37
Scripts/update-storagebasedirectory.sh
Normal file
|
@ -0,0 +1,37 @@
|
|||
#!/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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 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
|
||||
fi
|
||||
|
||||
printf "UPDATE mailbox SET storagebasedirectory = '$new' WHERE storagebasedirectory = '$current';\n"
|
37
Scripts/update-storagenode.sh
Normal file
37
Scripts/update-storagenode.sh
Normal file
|
@ -0,0 +1,37 @@
|
|||
#!/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"
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--h" ] || [ "$1" == "/h" ] || [ $# -lt 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
|
||||
fi
|
||||
|
||||
printf "UPDATE mailbox SET storagenode = '$new' WHERE storagenode = '$current';\n"
|
Loading…
Reference in a new issue