diff --git a/lib/functions.sh b/lib/functions.sh index 548b6ec..43f123a 100644 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -12,6 +12,10 @@ fail() { # docker network rm fstack &> /dev/null exit 2; } +run_command() { + $1 &> /dev/null + [[ $? -ne 0 ]] && echo "* FAILED - Couldn't run \"$1\"" >&2 +} failcheck() { echo -ne "\n\nFAILED - $1\n\n" exit 2; diff --git a/lib/mail.sh b/lib/mail.sh index d711170..edde9d0 100644 --- a/lib/mail.sh +++ b/lib/mail.sh @@ -5,7 +5,7 @@ PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin config_mail() { - echo -ne "\n* Configuring /federated/apps/mail container.." + echo -ne "* Configuring mail container.." if [ ! -d "/federated/apps/mail" ]; then mkdir -p /federated/apps/mail/data/root/certs &> /dev/null @@ -85,13 +85,13 @@ LDAP_SERVER_HOST=ldap://ldap.$DOMAIN LDAP_SEARCH_BASE=ou=people,dc=federatedcomputer,dc=cloud LDAP_BIND_DN=cn=admin,dc=federatedcomputer,dc=cloud LDAP_BIND_PW=$LDAP_SECRET -LDAP_QUERY_FILTER_USER="(&(mail=%s)(mailEnabled=TRUE))" -LDAP_QUERY_FILTER_GROUP="(&(mailGroupMember=%s)(mailEnabled=TRUE))" -LDAP_QUERY_FILTER_ALIAS="(&(mailAlias=%s)(mailEnabled=TRUE))" -LDAP_QUERY_FILTER_DOMAIN="(|(mail=*@%s)(mailAlias=*@%s))" +LDAP_QUERY_FILTER_USER=(&(mail=%s)(mailEnabled=TRUE)) +LDAP_QUERY_FILTER_GROUP=(&(mailGroupMember=%s)(mailEnabled=TRUE)) +LDAP_QUERY_FILTER_ALIAS=(&(mailAlias=%s)(mailEnabled=TRUE)) +LDAP_QUERY_FILTER_DOMAIN=(|(mail=*@%s)(mailAlias=*@%s)) # DOVECOT -DOVECOT_PASS_FILTER="(&(objectClass=inetOrgPerson)(mail=%u))" -DOVECOT_USER_FILTER="(&(objectClass=inetOrgPerson)(mail=%u))" +DOVECOT_PASS_FILTER=(&(objectClass=inetOrgPerson)(mail=%u)) +DOVECOT_USER_FILTER=(&(objectClass=inetOrgPerson)(mail=%u)) DOVECOT_USER_ATTRS=homeDirectory=home,=uid=5000,=gid=5000 # SASLAUTHD ENABLE_SASLAUTHD=1 @@ -100,7 +100,7 @@ SASLAUTHD_LDAP_SERVER=ldap://ldap.$DOMAIN SASLAUTHD_LDAP_BIND_DN=cn=admin,dc=federatedcomputer,dc=cloud SASLAUTHD_LDAP_PASSWORD=$LDAP_SECRET SASLAUTHD_LDAP_SEARCH_BASE=ou=people,dc=federatedcomputer,dc=cloud -SASLAUTHD_LDAP_FILTER="(&(objectClass=inetOrgPerson)(mail=%U@%r))" +SASLAUTHD_LDAP_FILTER=(&(objectClass=inetOrgPerson)(mail=%U@%r)) POSTMASTER_ADDRESS=postmaster@localhost.localdomain POSTFIX_MESSAGE_SIZE_LIMIT=100000000 ENABLE_MANAGESIEVE=1 @@ -269,18 +269,17 @@ bantime = 180d port = smtp,pop3,pop3s,imap,imaps,submission,submissions,sieve EOF - echo -ne "done." + echo -ne "done.\n" } start_mail() { # Start service with command to make sure it's up before proceeding start_service "mail" "nc -z 192.168.0.16 25 &> /dev/null" "25" # Generate the DKIM DNS key and setup - docker exec mail setup config dkim - docker exec mail setup config dkim keysize 2048 domain $DOMAIN &> /dev/null - [ $? -ne 0 ] && fail "Couldn't generate DKIM record" + run_command "docker exec mail setup config dkim" + run_command "docker exec mail setup config dkim keysize 2048 domain $DOMAIN" - docker exec mail bash -c "setup config dkim domain '$DOMAIN'" + docker exec mail bash -c "setup config dkim domain '$DOMAIN' &> /dev/null" [ $? -ne 0 ] && fail "Couldn't setup DKIM domain" # Insert the DKIM DNS TXT entry into /federated/apps/pdns container @@ -294,15 +293,13 @@ start_mail() { [ $? -ne 0 ] && fail "Couldn't insert DMARC record into /federated/apps/pdns container" # Stop and Start mail to reload DKIM - /federated/bin/stop mail &> /dev/null - /federated/bin/start mail &> /dev/null + run_command "/federated/bin/stop mail" + run_command "/federated/bin/start mail" - echo -ne "done." + echo -ne "done.\n" } uninstall_mail() { echo -ne "* Uninstalling mail container.." - spin & - SPINPID=$! # First stop the service cd /federated/apps/mail && docker-compose -f docker-compose.yml -p mail down &> /dev/null @@ -317,6 +314,5 @@ uninstall_mail() { docker exec pdns pdnsutil delete-rrset $DOMAIN mail._domainkey TXT docker exec pdns pdnsutil delete-rrset $DOMAIN _dmarc TXT - kill -9 $SPINPID &> /dev/null echo -ne "done.\n" }