Testing SSO fix for mail.sh clean up

This commit is contained in:
root 2024-11-06 15:43:03 +00:00
parent ba9477e7f5
commit 866e1875cf
2 changed files with 19 additions and 19 deletions

View File

@ -12,6 +12,10 @@ fail() {
# docker network rm fstack &> /dev/null # docker network rm fstack &> /dev/null
exit 2; exit 2;
} }
run_command() {
$1 &> /dev/null
[[ $? -ne 0 ]] && echo "* FAILED - Couldn't run \"$1\"" >&2
}
failcheck() { failcheck() {
echo -ne "\n\nFAILED - $1\n\n" echo -ne "\n\nFAILED - $1\n\n"
exit 2; exit 2;

View File

@ -5,7 +5,7 @@
PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
config_mail() { config_mail() {
echo -ne "\n* Configuring /federated/apps/mail container.." echo -ne "* Configuring mail container.."
if [ ! -d "/federated/apps/mail" ]; then if [ ! -d "/federated/apps/mail" ]; then
mkdir -p /federated/apps/mail/data/root/certs &> /dev/null 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_SEARCH_BASE=ou=people,dc=federatedcomputer,dc=cloud
LDAP_BIND_DN=cn=admin,dc=federatedcomputer,dc=cloud LDAP_BIND_DN=cn=admin,dc=federatedcomputer,dc=cloud
LDAP_BIND_PW=$LDAP_SECRET LDAP_BIND_PW=$LDAP_SECRET
LDAP_QUERY_FILTER_USER="(&(mail=%s)(mailEnabled=TRUE))" LDAP_QUERY_FILTER_USER=(&(mail=%s)(mailEnabled=TRUE))
LDAP_QUERY_FILTER_GROUP="(&(mailGroupMember=%s)(mailEnabled=TRUE))" LDAP_QUERY_FILTER_GROUP=(&(mailGroupMember=%s)(mailEnabled=TRUE))
LDAP_QUERY_FILTER_ALIAS="(&(mailAlias=%s)(mailEnabled=TRUE))" LDAP_QUERY_FILTER_ALIAS=(&(mailAlias=%s)(mailEnabled=TRUE))
LDAP_QUERY_FILTER_DOMAIN="(|(mail=*@%s)(mailAlias=*@%s))" LDAP_QUERY_FILTER_DOMAIN=(|(mail=*@%s)(mailAlias=*@%s))
# DOVECOT # DOVECOT
DOVECOT_PASS_FILTER="(&(objectClass=inetOrgPerson)(mail=%u))" DOVECOT_PASS_FILTER=(&(objectClass=inetOrgPerson)(mail=%u))
DOVECOT_USER_FILTER="(&(objectClass=inetOrgPerson)(mail=%u))" DOVECOT_USER_FILTER=(&(objectClass=inetOrgPerson)(mail=%u))
DOVECOT_USER_ATTRS=homeDirectory=home,=uid=5000,=gid=5000 DOVECOT_USER_ATTRS=homeDirectory=home,=uid=5000,=gid=5000
# SASLAUTHD # SASLAUTHD
ENABLE_SASLAUTHD=1 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_BIND_DN=cn=admin,dc=federatedcomputer,dc=cloud
SASLAUTHD_LDAP_PASSWORD=$LDAP_SECRET SASLAUTHD_LDAP_PASSWORD=$LDAP_SECRET
SASLAUTHD_LDAP_SEARCH_BASE=ou=people,dc=federatedcomputer,dc=cloud 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 POSTMASTER_ADDRESS=postmaster@localhost.localdomain
POSTFIX_MESSAGE_SIZE_LIMIT=100000000 POSTFIX_MESSAGE_SIZE_LIMIT=100000000
ENABLE_MANAGESIEVE=1 ENABLE_MANAGESIEVE=1
@ -269,18 +269,17 @@ bantime = 180d
port = smtp,pop3,pop3s,imap,imaps,submission,submissions,sieve port = smtp,pop3,pop3s,imap,imaps,submission,submissions,sieve
EOF EOF
echo -ne "done." echo -ne "done.\n"
} }
start_mail() { start_mail() {
# Start service with command to make sure it's up before proceeding # 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" start_service "mail" "nc -z 192.168.0.16 25 &> /dev/null" "25"
# Generate the DKIM DNS key and setup # Generate the DKIM DNS key and setup
docker exec mail setup config dkim run_command "docker exec mail setup config dkim"
docker exec mail setup config dkim keysize 2048 domain $DOMAIN &> /dev/null run_command "docker exec mail setup config dkim keysize 2048 domain $DOMAIN"
[ $? -ne 0 ] && fail "Couldn't generate DKIM record"
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" [ $? -ne 0 ] && fail "Couldn't setup DKIM domain"
# Insert the DKIM DNS TXT entry into /federated/apps/pdns container # 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" [ $? -ne 0 ] && fail "Couldn't insert DMARC record into /federated/apps/pdns container"
# Stop and Start mail to reload DKIM # Stop and Start mail to reload DKIM
/federated/bin/stop mail &> /dev/null run_command "/federated/bin/stop mail"
/federated/bin/start mail &> /dev/null run_command "/federated/bin/start mail"
echo -ne "done." echo -ne "done.\n"
} }
uninstall_mail() { uninstall_mail() {
echo -ne "* Uninstalling mail container.." echo -ne "* Uninstalling mail container.."
spin &
SPINPID=$!
# First stop the service # First stop the service
cd /federated/apps/mail && docker-compose -f docker-compose.yml -p mail down &> /dev/null 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 mail._domainkey TXT
docker exec pdns pdnsutil delete-rrset $DOMAIN _dmarc TXT docker exec pdns pdnsutil delete-rrset $DOMAIN _dmarc TXT
kill -9 $SPINPID &> /dev/null
echo -ne "done.\n" echo -ne "done.\n"
} }