mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
Adjust coding style in "bin" scripts (#279)
The main shell script (start-mailserver.sh) uses two spaces for indentation. All other shell scripts should use this coding style.
This commit is contained in:
parent
46278ec890
commit
76d2c779df
|
@ -3,27 +3,26 @@
|
||||||
DATABASE=/tmp/docker-mailserver/postfix-accounts.cf
|
DATABASE=/tmp/docker-mailserver/postfix-accounts.cf
|
||||||
|
|
||||||
function usage {
|
function usage {
|
||||||
echo 'Usage: addmailuser <user@domain.tld> [password]'
|
echo 'Usage: addmailuser <user@domain.tld> [password]'
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ ! -z "$1" ]; then
|
if [ ! -z "$1" ]; then
|
||||||
USER=$1
|
USER=$1
|
||||||
if [ -e "$DATABASE" ] && [ ! -z "$(grep $USER -i $DATABASE)" ]; then
|
if [ -e "$DATABASE" ] && [ ! -z "$(grep $USER -i $DATABASE)" ]; then
|
||||||
echo "User already exists"
|
echo "User already exists"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
|
||||||
if [ ! -z "$2" ]; then
|
|
||||||
PASS="$2"
|
|
||||||
else
|
|
||||||
read -s -p "Enter Password: " PASS
|
|
||||||
if [ -z "$PASS" ]; then
|
|
||||||
echo "Password can't be empty"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
fi
|
if [ ! -z "$2" ]; then
|
||||||
ENTRY=$(echo "$USER|$(doveadm pw -s SHA512-CRYPT -u "$USER" -p "$PASS")")
|
PASS="$2"
|
||||||
echo "$ENTRY" >> $DATABASE
|
else
|
||||||
|
read -s -p "Enter Password: " PASS
|
||||||
|
if [ -z "$PASS" ]; then
|
||||||
|
echo "Password can't be empty"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
ENTRY=$(echo "$USER|$(doveadm pw -s SHA512-CRYPT -u "$USER" -p "$PASS")")
|
||||||
|
echo "$ENTRY" >> $DATABASE
|
||||||
else
|
else
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -3,16 +3,19 @@
|
||||||
DATABASE=/tmp/docker-mailserver/postfix-accounts.cf
|
DATABASE=/tmp/docker-mailserver/postfix-accounts.cf
|
||||||
|
|
||||||
function usage {
|
function usage {
|
||||||
echo "Usage: delmailuser <user@domain.tld>"
|
echo "Usage: delmailuser <user@domain.tld>"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ ! -z "$1" ]; then
|
if [ ! -z "$1" ]; then
|
||||||
USER=$1
|
USER=$1
|
||||||
if [ -f "$DATABASE" ]; then
|
|
||||||
ENTRIES=$(grep "$USER" -vi $DATABASE)
|
ENTRIES=$(grep "$USER" -vi $DATABASE)
|
||||||
echo "$ENTRIES" > $DATABASE
|
echo "$ENTRIES" > $DATABASE
|
||||||
fi
|
USER=$1
|
||||||
|
if [ -f "$DATABASE" ]; then
|
||||||
|
ENTRIES=$(grep "$USER" -vi $DATABASE)
|
||||||
|
echo "$ENTRIES" > $DATABASE
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -4,28 +4,28 @@ touch /tmp/vhost.tmp
|
||||||
|
|
||||||
# Getting domains from mail accounts
|
# Getting domains from mail accounts
|
||||||
if [ -f /tmp/docker-mailserver/postfix-accounts.cf ]; then
|
if [ -f /tmp/docker-mailserver/postfix-accounts.cf ]; then
|
||||||
while IFS=$'|' read login pass
|
while IFS=$'|' read login pass
|
||||||
do
|
do
|
||||||
domain=$(echo ${login} | cut -d @ -f2)
|
domain=$(echo ${login} | cut -d @ -f2)
|
||||||
echo ${domain} >> /tmp/vhost.tmp
|
echo ${domain} >> /tmp/vhost.tmp
|
||||||
done < /tmp/docker-mailserver/postfix-accounts.cf
|
done < /tmp/docker-mailserver/postfix-accounts.cf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Getting domains from mail aliases
|
# Getting domains from mail aliases
|
||||||
if [ -f /tmp/docker-mailserver/postfix-virtual.cf ]; then
|
if [ -f /tmp/docker-mailserver/postfix-virtual.cf ]; then
|
||||||
while read from to
|
while read from to
|
||||||
do
|
do
|
||||||
# Setting variables for better readability
|
# Setting variables for better readability
|
||||||
uname=$(echo ${from} | cut -d @ -f1)
|
uname=$(echo ${from} | cut -d @ -f1)
|
||||||
domain=$(echo ${from} | cut -d @ -f2)
|
domain=$(echo ${from} | cut -d @ -f2)
|
||||||
# if they are equal it means the line looks like: "user1 other@domain.tld"
|
# if they are equal it means the line looks like: "user1 other@domain.tld"
|
||||||
test "$uname" != "$domain" && echo ${domain} >> /tmp/vhost.tmp
|
test "$uname" != "$domain" && echo ${domain} >> /tmp/vhost.tmp
|
||||||
done < /tmp/docker-mailserver/postfix-virtual.cf
|
done < /tmp/docker-mailserver/postfix-virtual.cf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Keeping unique entries
|
# Keeping unique entries
|
||||||
if [ -f /tmp/vhost.tmp ]; then
|
if [ -f /tmp/vhost.tmp ]; then
|
||||||
cat /tmp/vhost.tmp | sort | uniq > /tmp/vhost && rm /tmp/vhost.tmp
|
cat /tmp/vhost.tmp | sort | uniq > /tmp/vhost && rm /tmp/vhost.tmp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Exit if no entries found
|
# Exit if no entries found
|
||||||
|
@ -35,39 +35,39 @@ if [ ! -f /tmp/vhost ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
grep -vE '^(\s*$|#)' /tmp/vhost | while read domainname; do
|
grep -vE '^(\s*$|#)' /tmp/vhost | while read domainname; do
|
||||||
mkdir -p /tmp/docker-mailserver/opendkim/keys/$domainname
|
mkdir -p /tmp/docker-mailserver/opendkim/keys/$domainname
|
||||||
|
|
||||||
if [ ! -f "/tmp/docker-mailserver/opendkim/keys/$domainname/mail.private" ]; then
|
if [ ! -f "/tmp/docker-mailserver/opendkim/keys/$domainname/mail.private" ]; then
|
||||||
echo "Creating DKIM private key /tmp/docker-mailserver/opendkim/keys/$domainname/mail.private"
|
echo "Creating DKIM private key /tmp/docker-mailserver/opendkim/keys/$domainname/mail.private"
|
||||||
opendkim-genkey --subdomains --domain=$domainname --selector=mail -D /tmp/docker-mailserver/opendkim/keys/$domainname
|
opendkim-genkey --subdomains --domain=$domainname --selector=mail -D /tmp/docker-mailserver/opendkim/keys/$domainname
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Write to KeyTable if necessary
|
# Write to KeyTable if necessary
|
||||||
keytableentry="mail._domainkey.$domainname $domainname:mail:/etc/opendkim/keys/$domainname/mail.private"
|
keytableentry="mail._domainkey.$domainname $domainname:mail:/etc/opendkim/keys/$domainname/mail.private"
|
||||||
if [ ! -f "/tmp/docker-mailserver/opendkim/KeyTable" ]; then
|
if [ ! -f "/tmp/docker-mailserver/opendkim/KeyTable" ]; then
|
||||||
echo "Creating DKIM KeyTable"
|
echo "Creating DKIM KeyTable"
|
||||||
echo $keytableentry > /tmp/docker-mailserver/opendkim/KeyTable
|
echo $keytableentry > /tmp/docker-mailserver/opendkim/KeyTable
|
||||||
else
|
else
|
||||||
if ! grep -q "$keytableentry" "/tmp/docker-mailserver/opendkim/KeyTable" ; then
|
if ! grep -q "$keytableentry" "/tmp/docker-mailserver/opendkim/KeyTable" ; then
|
||||||
echo $keytableentry >> /tmp/docker-mailserver/opendkim/KeyTable
|
echo $keytableentry >> /tmp/docker-mailserver/opendkim/KeyTable
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Write to SigningTable if necessary
|
# Write to SigningTable if necessary
|
||||||
signingtableentry="*@$domainname mail._domainkey.$domainname"
|
signingtableentry="*@$domainname mail._domainkey.$domainname"
|
||||||
if [ ! -f "/tmp/docker-mailserver/opendkim/SigningTable" ]; then
|
if [ ! -f "/tmp/docker-mailserver/opendkim/SigningTable" ]; then
|
||||||
echo "Creating DKIM SigningTable"
|
echo "Creating DKIM SigningTable"
|
||||||
echo "*@$domainname mail._domainkey.$domainname" > /tmp/docker-mailserver/opendkim/SigningTable
|
echo "*@$domainname mail._domainkey.$domainname" > /tmp/docker-mailserver/opendkim/SigningTable
|
||||||
else
|
else
|
||||||
if ! grep -q "$signingtableentry" "/tmp/docker-mailserver/opendkim/SigningTable" ; then
|
if ! grep -q "$signingtableentry" "/tmp/docker-mailserver/opendkim/SigningTable" ; then
|
||||||
echo $signingtableentry >> /tmp/docker-mailserver/opendkim/SigningTable
|
echo $signingtableentry >> /tmp/docker-mailserver/opendkim/SigningTable
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Creates TrustedHosts if missing
|
# Creates TrustedHosts if missing
|
||||||
if [ -d "/tmp/docker-mailserver/opendkim" ] && [ ! -f "/tmp/docker-mailserver/opendkim/TrustedHosts" ]; then
|
if [ -d "/tmp/docker-mailserver/opendkim" ] && [ ! -f "/tmp/docker-mailserver/opendkim/TrustedHosts" ]; then
|
||||||
echo "Creating DKIM TrustedHosts";
|
echo "Creating DKIM TrustedHosts";
|
||||||
echo "127.0.0.1" > /tmp/docker-mailserver/opendkim/TrustedHosts
|
echo "127.0.0.1" > /tmp/docker-mailserver/opendkim/TrustedHosts
|
||||||
echo "localhost" >> /tmp/docker-mailserver/opendkim/TrustedHosts
|
echo "localhost" >> /tmp/docker-mailserver/opendkim/TrustedHosts
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue