Skip to content

Commit

Permalink
[SOGo] use bash script for ldap plist template
Browse files Browse the repository at this point in the history
  • Loading branch information
FreddleSpl0it committed Feb 20, 2024
1 parent b3e26e1 commit 132e37b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ data/conf/rspamd/local.d/*
data/conf/rspamd/override.d/*
data/conf/sogo/custom-theme.js
data/conf/sogo/plist_ldap
data/conf/sogo/plist_ldap.sh
data/conf/sogo/sieve.creds
data/conf/sogo/sogo-full.svg
data/gitea/
Expand Down
2 changes: 1 addition & 1 deletion data/Dockerfiles/sogo/bootstrap-sogo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ while read -r line gal
</dict>" >> /var/lib/sogo/GNUstep/Defaults/sogod.plist
# Generate alternative LDAP authentication dict, when SQL authentication fails
# This will nevertheless read attributes from LDAP
line=${line} envsubst < /etc/sogo/plist_ldap >> /var/lib/sogo/GNUstep/Defaults/sogod.plist
/etc/sogo/plist_ldap.sh ${line} ${gal} >> /var/lib/sogo/GNUstep/Defaults/sogod.plist
echo " </array>
</dict>" >> /var/lib/sogo/GNUstep/Defaults/sogod.plist
done < <(mysql --socket=/var/run/mysqld/mysqld.sock -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "SELECT domain, CASE gal WHEN '1' THEN 'YES' ELSE 'NO' END AS gal FROM domain;" -B -N)
Expand Down
62 changes: 34 additions & 28 deletions data/conf/sogo/plist_ldap → data/conf/sogo/plist_ldap.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
<!--
<example>
<key>canAuthenticate</key>
<string>YES</string>
<key>id</key>
<string>${line}_ldap</string>
<key>isAddressBook</key>
<string>NO</string>
<key>IDFieldName</key>
<string>mail</string>
<key>UIDFieldName</key>
<string>uid</string>
<key>bindFields</key>
<array>
<string>mail</string>
</array>
<key>type</key>
<string>ldap</string>
<key>bindDN</key>
<string>cn=admin,dc=example,dc=local</string>
<key>bindPassword</key>
<string>password</string>
<key>baseDN</key>
<string>ou=People,dc=example,dc=local</string>
<key>hostname</key>
<string>ldap://1.2.3.4:389</string>
</example>
-->
#!/bin/bash

domain="$1"
gal_status="$2"

echo '
<!--
<example>
<key>canAuthenticate</key>
<string>YES</string>
<key>id</key>
<string>'"${domain}_ldap"'</string>
<key>isAddressBook</key>
<string>'"${gal_status}"'</string>
<key>IDFieldName</key>
<string>mail</string>
<key>UIDFieldName</key>
<string>uid</string>
<key>bindFields</key>
<array>
<string>mail</string>
</array>
<key>type</key>
<string>ldap</string>
<key>bindDN</key>
<string>cn=admin,dc=example,dc=local</string>
<key>bindPassword</key>
<string>password</string>
<key>baseDN</key>
<string>ou=People,dc=example,dc=local</string>
<key>hostname</key>
<string>ldap://1.2.3.4:389</string>
</example>
-->'
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ services:
- phpfpm

sogo-mailcow:
image: mailcow/sogo:nightly-20240208
image: mailcow/sogo:nightly-20240220
environment:
- DBNAME=${DBNAME}
- DBUSER=${DBUSER}
Expand Down

0 comments on commit 132e37b

Please sign in to comment.