2017-03-02 12:23:23 +02:00
#!/bin/bash
# Wait for MySQL to warm-up
2018-10-11 11:53:22 +02:00
while ! mysqladmin status --socket= /var/run/mysqld/mysqld.sock -u${ DBUSER } -p${ DBPASS } --silent; do
2018-01-08 20:56:44 +02:00
echo "Waiting for database to come up..."
sleep 2
done
2017-03-02 12:23:23 +02:00
2017-07-24 23:25:04 +02:00
# Wait until port becomes free and send sig
until ! nc -z sogo-mailcow 20000;
do
2018-07-11 22:08:02 +02:00
killall -TERM sogod
sleep 3
2017-07-24 23:25:04 +02:00
done
2018-11-16 23:48:28 +02:00
# Wait for updated schema
2019-08-10 15:59:28 +02:00
DBV_NOW = $( mysql --socket= /var/run/mysqld/mysqld.sock -u ${ DBUSER } -p${ DBPASS } ${ DBNAME } -e "SELECT version FROM versions WHERE application = 'db_schema';" -BN)
2018-11-16 23:48:28 +02:00
DBV_NEW = $( grep -oE '\$db_version = .*;' init_db.inc.php | sed 's/$db_version = //g;s/;//g' | cut -d \" -f2)
2020-01-22 11:15:40 +02:00
while [ [ " ${ DBV_NOW } " != " ${ DBV_NEW } " ] ] ; do
2018-11-16 23:48:28 +02:00
echo "Waiting for schema update..."
2019-08-10 15:59:28 +02:00
DBV_NOW = $( mysql --socket= /var/run/mysqld/mysqld.sock -u ${ DBUSER } -p${ DBPASS } ${ DBNAME } -e "SELECT version FROM versions WHERE application = 'db_schema';" -BN)
2018-11-16 23:48:28 +02:00
DBV_NEW = $( grep -oE '\$db_version = .*;' init_db.inc.php | sed 's/$db_version = //g;s/;//g' | cut -d \" -f2)
sleep 5
done
echo " DB schema is ${ DBV_NOW } "
2017-03-02 12:23:23 +02:00
# Recreate view
2020-01-29 11:33:42 +02:00
if [ [ " ${ MASTER } " = ~ ^( [ yY] [ eE] [ sS] | [ yY] ) +$ ] ] ; then
2020-02-05 11:59:32 +02:00
echo "We are master, preparing sogo_view..."
2020-01-29 11:33:42 +02:00
mysql --socket= /var/run/mysqld/mysqld.sock -u ${ DBUSER } -p${ DBPASS } ${ DBNAME } -e "DROP VIEW IF EXISTS sogo_view"
while [ [ ${ VIEW_OK } != 'OK' ] ] ; do
mysql --socket= /var/run/mysqld/mysqld.sock -u ${ DBUSER } -p${ DBPASS } ${ DBNAME } << EOF
2019-12-02 11:53:59 +02:00
CREATE VIEW sogo_view ( c_uid, domain, c_name, c_password, c_cn, mail, aliases, ad_aliases, ext_acl, kind, multiple_bookings) AS
SELECT
mailbox.username,
mailbox.domain,
mailbox.username,
2020-09-20 22:21:00 +02:00
IF( JSON_UNQUOTE( JSON_VALUE( attributes, '$.force_pw_update' ) ) = '0' , IF( JSON_UNQUOTE( JSON_VALUE( attributes, '$.sogo_access' ) ) = 1, password, '{SSHA256}A123A123A321A321A321B321B321B123B123B321B432F123E321123123321321' ) , '{SSHA256}A123A123A321A321A321B321B321B123B123B321B432F123E321123123321321' ) ,
2019-12-02 11:53:59 +02:00
mailbox.name,
mailbox.username,
2020-01-22 11:15:40 +02:00
IFNULL( GROUP_CONCAT( ga.aliases ORDER BY ga.aliases SEPARATOR ' ' ) , '' ) ,
2019-12-02 11:53:59 +02:00
IFNULL( gda.ad_alias, '' ) ,
IFNULL( external_acl.send_as_acl, '' ) ,
mailbox.kind,
mailbox.multiple_bookings
FROM
mailbox
LEFT OUTER JOIN
grouped_mail_aliases ga
ON ga.username REGEXP CONCAT( '(^|,)' , mailbox.username, '($|,)' )
LEFT OUTER JOIN
grouped_domain_alias_address gda
ON gda.username = mailbox.username
LEFT OUTER JOIN
grouped_sender_acl_external external_acl
ON external_acl.username = mailbox.username
WHERE
mailbox.active = '1'
GROUP BY
mailbox.username;
2017-03-02 12:23:23 +02:00
EOF
2020-01-29 11:33:42 +02:00
if [ [ ! -z $( mysql --socket= /var/run/mysqld/mysqld.sock -u ${ DBUSER } -p${ DBPASS } ${ DBNAME } -B -e "SELECT 'OK' FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'sogo_view'" ) ] ] ; then
VIEW_OK = OK
else
echo "Will retry to setup SOGo view in 3s..."
sleep 3
fi
done
else
while [ [ ${ VIEW_OK } != 'OK' ] ] ; do
if [ [ ! -z $( mysql --socket= /var/run/mysqld/mysqld.sock -u ${ DBUSER } -p${ DBPASS } ${ DBNAME } -B -e "SELECT 'OK' FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'sogo_view'" ) ] ] ; then
VIEW_OK = OK
else
echo "Waiting for SOGo view to be created by master..."
sleep 3
fi
done
fi
2017-03-02 12:23:23 +02:00
2018-07-12 14:04:31 +02:00
# Wait for static view table if missing after update and update content
2020-01-29 11:33:42 +02:00
if [ [ " ${ MASTER } " = ~ ^( [ yY] [ eE] [ sS] | [ yY] ) +$ ] ] ; then
2020-02-05 11:59:32 +02:00
echo "We are master, preparing _sogo_static_view..."
2020-01-29 11:33:42 +02:00
while [ [ ${ STATIC_VIEW_OK } != 'OK' ] ] ; do
if [ [ ! -z $( mysql --socket= /var/run/mysqld/mysqld.sock -u ${ DBUSER } -p${ DBPASS } ${ DBNAME } -B -e "SELECT 'OK' FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '_sogo_static_view'" ) ] ] ; then
STATIC_VIEW_OK = OK
echo "Updating _sogo_static_view content..."
2020-11-13 16:20:30 +02:00
# If changed, also update init_db.inc.php
2020-01-29 11:33:42 +02:00
mysql --socket= /var/run/mysqld/mysqld.sock -u ${ DBUSER } -p${ DBPASS } ${ DBNAME } -B -e "REPLACE INTO _sogo_static_view (c_uid, domain, c_name, c_password, c_cn, mail, aliases, ad_aliases, ext_acl, kind, multiple_bookings) SELECT c_uid, domain, c_name, c_password, c_cn, mail, aliases, ad_aliases, ext_acl, kind, multiple_bookings from sogo_view;"
mysql --socket= /var/run/mysqld/mysqld.sock -u ${ DBUSER } -p${ DBPASS } ${ DBNAME } -B -e "DELETE FROM _sogo_static_view WHERE c_uid NOT IN (SELECT username FROM mailbox WHERE active = '1')"
else
2020-02-05 11:59:32 +02:00
echo "Waiting for database initialization..."
2020-01-29 11:33:42 +02:00
sleep 3
fi
done
else
while [ [ ${ STATIC_VIEW_OK } != 'OK' ] ] ; do
if [ [ ! -z $( mysql --socket= /var/run/mysqld/mysqld.sock -u ${ DBUSER } -p${ DBPASS } ${ DBNAME } -B -e "SELECT 'OK' FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '_sogo_static_view'" ) ] ] ; then
STATIC_VIEW_OK = OK
else
echo "Waiting for database initialization by master..."
sleep 3
fi
done
fi
2018-07-12 14:04:31 +02:00
2018-07-11 22:08:02 +02:00
2020-02-05 11:59:32 +02:00
# Recreate password update trigger
if [ [ " ${ MASTER } " = ~ ^( [ yY] [ eE] [ sS] | [ yY] ) +$ ] ] ; then
echo "We are master, preparing update trigger..."
mysql --socket= /var/run/mysqld/mysqld.sock -u ${ DBUSER } -p${ DBPASS } ${ DBNAME } -e "DROP TRIGGER IF EXISTS sogo_update_password"
while [ [ ${ TRIGGER_OK } != 'OK' ] ] ; do
[Docker API] Use TLS encryption for communication with "on-the-fly" created key paris (non-exposed)
[Docker API] Create pipe to pass Rspamd UI worker password
[Dovecot] Pull Spamassassin ruleset to be read by Rspamd (MANY THANKS to Peer Heinlein!)
[Dovecot] Garbage collector for deleted maildirs (set keep time via MAILDIR_GC_TIME which defaults to 1440 minutes)
[Web] Flush memcached after mailbox item changes, fixes #1808
[Web] Fix duplicate IDs, fixes #1792
[Compose] Use SQL sockets
[PHP-FPM] Update APCu and Redis libs
[Dovecot] Encrypt maildir with global key pair in crypt-vol-1 (BACKUP!), also fixes #1791
[Web] Fix deletion of spam aliases
[Helper] Add "crypt" to backup script
[Helper] Override file for external SQL socket (not supported!)
[Compose] New images for Rspamd, PHP-FPM, SOGo, Dovecot, Docker API, Watchdog, ACME, Postfix
2018-09-29 22:01:23 +02:00
mysql --socket= /var/run/mysqld/mysqld.sock -u ${ DBUSER } -p${ DBPASS } ${ DBNAME } << EOF
2018-07-11 22:08:02 +02:00
DELIMITER -
CREATE TRIGGER sogo_update_password AFTER UPDATE ON _sogo_static_view
FOR EACH ROW
BEGIN
UPDATE mailbox SET password = NEW.c_password WHERE NEW.c_uid = username;
END;
-
DELIMITER ;
EOF
2020-02-05 11:59:32 +02:00
if [ [ ! -z $( mysql --socket= /var/run/mysqld/mysqld.sock -u ${ DBUSER } -p${ DBPASS } ${ DBNAME } -B -e "SELECT 'OK' FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME = 'sogo_update_password'" ) ] ] ; then
TRIGGER_OK = OK
else
echo "Will retry to setup SOGo password update trigger in 3s"
sleep 3
fi
done
fi
2018-07-11 22:08:02 +02:00
2019-02-26 10:02:35 +02:00
if [ [ " ${ ALLOW_ADMIN_EMAIL_LOGIN } " = ~ ^( [ yY] [ eE] [ sS] | [ yY] ) +$ ] ] ; then
TRUST_PROXY = "YES"
else
TRUST_PROXY = "NO"
fi
2019-02-26 21:44:53 +02:00
# cat /dev/urandom seems to hang here occasionally and is not recommended anyway, better use openssl
RAND_PASS = $( openssl rand -base64 16 | tr -dc _A-Z-a-z-0-9)
2019-02-26 10:02:35 +02:00
2017-03-02 12:23:23 +02:00
# Generate plist header with timezone data
2019-02-26 21:44:53 +02:00
mkdir -p /var/lib/sogo/GNUstep/Defaults/
2017-03-02 12:23:23 +02:00
cat <<EOF > /var/lib/sogo/GNUstep/Defaults/sogod.plist
<?xml version = "1.0" encoding = "UTF-8" ?>
<!DOCTYPE plist PUBLIC "-//GNUstep//DTD plist 0.9//EN" "http://www.gnustep.org/plist-0_9.xml" >
<plist version = "0.9" >
<dict>
<key>OCSAclURL</key>
[Docker API] Use TLS encryption for communication with "on-the-fly" created key paris (non-exposed)
[Docker API] Create pipe to pass Rspamd UI worker password
[Dovecot] Pull Spamassassin ruleset to be read by Rspamd (MANY THANKS to Peer Heinlein!)
[Dovecot] Garbage collector for deleted maildirs (set keep time via MAILDIR_GC_TIME which defaults to 1440 minutes)
[Web] Flush memcached after mailbox item changes, fixes #1808
[Web] Fix duplicate IDs, fixes #1792
[Compose] Use SQL sockets
[PHP-FPM] Update APCu and Redis libs
[Dovecot] Encrypt maildir with global key pair in crypt-vol-1 (BACKUP!), also fixes #1791
[Web] Fix deletion of spam aliases
[Helper] Add "crypt" to backup script
[Helper] Override file for external SQL socket (not supported!)
[Compose] New images for Rspamd, PHP-FPM, SOGo, Dovecot, Docker API, Watchdog, ACME, Postfix
2018-09-29 22:01:23 +02:00
<string>mysql://${ DBUSER } :${ DBPASS } @%2Fvar%2Frun%2Fmysqld%2Fmysqld.sock/${ DBNAME } /sogo_acl</string>
2019-02-25 01:00:32 +02:00
<key>SOGoIMAPServer</key>
2020-09-24 21:51:32 +02:00
<string>imap://${ IPV4_NETWORK } .250:143/?TLS= YES& amp; tlsVerifyMode = none</string>
2019-02-26 10:02:35 +02:00
<key>SOGoTrustProxyAuthentication</key>
<string>${ TRUST_PROXY } </string>
<key>SOGoEncryptionKey</key>
<string>${ RAND_PASS } </string>
2017-03-02 12:23:23 +02:00
<key>OCSCacheFolderURL</key>
[Docker API] Use TLS encryption for communication with "on-the-fly" created key paris (non-exposed)
[Docker API] Create pipe to pass Rspamd UI worker password
[Dovecot] Pull Spamassassin ruleset to be read by Rspamd (MANY THANKS to Peer Heinlein!)
[Dovecot] Garbage collector for deleted maildirs (set keep time via MAILDIR_GC_TIME which defaults to 1440 minutes)
[Web] Flush memcached after mailbox item changes, fixes #1808
[Web] Fix duplicate IDs, fixes #1792
[Compose] Use SQL sockets
[PHP-FPM] Update APCu and Redis libs
[Dovecot] Encrypt maildir with global key pair in crypt-vol-1 (BACKUP!), also fixes #1791
[Web] Fix deletion of spam aliases
[Helper] Add "crypt" to backup script
[Helper] Override file for external SQL socket (not supported!)
[Compose] New images for Rspamd, PHP-FPM, SOGo, Dovecot, Docker API, Watchdog, ACME, Postfix
2018-09-29 22:01:23 +02:00
<string>mysql://${ DBUSER } :${ DBPASS } @%2Fvar%2Frun%2Fmysqld%2Fmysqld.sock/${ DBNAME } /sogo_cache_folder</string>
2017-03-02 12:23:23 +02:00
<key>OCSEMailAlarmsFolderURL</key>
[Docker API] Use TLS encryption for communication with "on-the-fly" created key paris (non-exposed)
[Docker API] Create pipe to pass Rspamd UI worker password
[Dovecot] Pull Spamassassin ruleset to be read by Rspamd (MANY THANKS to Peer Heinlein!)
[Dovecot] Garbage collector for deleted maildirs (set keep time via MAILDIR_GC_TIME which defaults to 1440 minutes)
[Web] Flush memcached after mailbox item changes, fixes #1808
[Web] Fix duplicate IDs, fixes #1792
[Compose] Use SQL sockets
[PHP-FPM] Update APCu and Redis libs
[Dovecot] Encrypt maildir with global key pair in crypt-vol-1 (BACKUP!), also fixes #1791
[Web] Fix deletion of spam aliases
[Helper] Add "crypt" to backup script
[Helper] Override file for external SQL socket (not supported!)
[Compose] New images for Rspamd, PHP-FPM, SOGo, Dovecot, Docker API, Watchdog, ACME, Postfix
2018-09-29 22:01:23 +02:00
<string>mysql://${ DBUSER } :${ DBPASS } @%2Fvar%2Frun%2Fmysqld%2Fmysqld.sock/${ DBNAME } /sogo_alarms_folder</string>
2017-03-02 12:23:23 +02:00
<key>OCSFolderInfoURL</key>
[Docker API] Use TLS encryption for communication with "on-the-fly" created key paris (non-exposed)
[Docker API] Create pipe to pass Rspamd UI worker password
[Dovecot] Pull Spamassassin ruleset to be read by Rspamd (MANY THANKS to Peer Heinlein!)
[Dovecot] Garbage collector for deleted maildirs (set keep time via MAILDIR_GC_TIME which defaults to 1440 minutes)
[Web] Flush memcached after mailbox item changes, fixes #1808
[Web] Fix duplicate IDs, fixes #1792
[Compose] Use SQL sockets
[PHP-FPM] Update APCu and Redis libs
[Dovecot] Encrypt maildir with global key pair in crypt-vol-1 (BACKUP!), also fixes #1791
[Web] Fix deletion of spam aliases
[Helper] Add "crypt" to backup script
[Helper] Override file for external SQL socket (not supported!)
[Compose] New images for Rspamd, PHP-FPM, SOGo, Dovecot, Docker API, Watchdog, ACME, Postfix
2018-09-29 22:01:23 +02:00
<string>mysql://${ DBUSER } :${ DBPASS } @%2Fvar%2Frun%2Fmysqld%2Fmysqld.sock/${ DBNAME } /sogo_folder_info</string>
2017-03-02 12:23:23 +02:00
<key>OCSSessionsFolderURL</key>
[Docker API] Use TLS encryption for communication with "on-the-fly" created key paris (non-exposed)
[Docker API] Create pipe to pass Rspamd UI worker password
[Dovecot] Pull Spamassassin ruleset to be read by Rspamd (MANY THANKS to Peer Heinlein!)
[Dovecot] Garbage collector for deleted maildirs (set keep time via MAILDIR_GC_TIME which defaults to 1440 minutes)
[Web] Flush memcached after mailbox item changes, fixes #1808
[Web] Fix duplicate IDs, fixes #1792
[Compose] Use SQL sockets
[PHP-FPM] Update APCu and Redis libs
[Dovecot] Encrypt maildir with global key pair in crypt-vol-1 (BACKUP!), also fixes #1791
[Web] Fix deletion of spam aliases
[Helper] Add "crypt" to backup script
[Helper] Override file for external SQL socket (not supported!)
[Compose] New images for Rspamd, PHP-FPM, SOGo, Dovecot, Docker API, Watchdog, ACME, Postfix
2018-09-29 22:01:23 +02:00
<string>mysql://${ DBUSER } :${ DBPASS } @%2Fvar%2Frun%2Fmysqld%2Fmysqld.sock/${ DBNAME } /sogo_sessions_folder</string>
2017-03-02 12:23:23 +02:00
<key>OCSStoreURL</key>
[Docker API] Use TLS encryption for communication with "on-the-fly" created key paris (non-exposed)
[Docker API] Create pipe to pass Rspamd UI worker password
[Dovecot] Pull Spamassassin ruleset to be read by Rspamd (MANY THANKS to Peer Heinlein!)
[Dovecot] Garbage collector for deleted maildirs (set keep time via MAILDIR_GC_TIME which defaults to 1440 minutes)
[Web] Flush memcached after mailbox item changes, fixes #1808
[Web] Fix duplicate IDs, fixes #1792
[Compose] Use SQL sockets
[PHP-FPM] Update APCu and Redis libs
[Dovecot] Encrypt maildir with global key pair in crypt-vol-1 (BACKUP!), also fixes #1791
[Web] Fix deletion of spam aliases
[Helper] Add "crypt" to backup script
[Helper] Override file for external SQL socket (not supported!)
[Compose] New images for Rspamd, PHP-FPM, SOGo, Dovecot, Docker API, Watchdog, ACME, Postfix
2018-09-29 22:01:23 +02:00
<string>mysql://${ DBUSER } :${ DBPASS } @%2Fvar%2Frun%2Fmysqld%2Fmysqld.sock/${ DBNAME } /sogo_store</string>
2017-03-02 12:23:23 +02:00
<key>SOGoProfileURL</key>
[Docker API] Use TLS encryption for communication with "on-the-fly" created key paris (non-exposed)
[Docker API] Create pipe to pass Rspamd UI worker password
[Dovecot] Pull Spamassassin ruleset to be read by Rspamd (MANY THANKS to Peer Heinlein!)
[Dovecot] Garbage collector for deleted maildirs (set keep time via MAILDIR_GC_TIME which defaults to 1440 minutes)
[Web] Flush memcached after mailbox item changes, fixes #1808
[Web] Fix duplicate IDs, fixes #1792
[Compose] Use SQL sockets
[PHP-FPM] Update APCu and Redis libs
[Dovecot] Encrypt maildir with global key pair in crypt-vol-1 (BACKUP!), also fixes #1791
[Web] Fix deletion of spam aliases
[Helper] Add "crypt" to backup script
[Helper] Override file for external SQL socket (not supported!)
[Compose] New images for Rspamd, PHP-FPM, SOGo, Dovecot, Docker API, Watchdog, ACME, Postfix
2018-09-29 22:01:23 +02:00
<string>mysql://${ DBUSER } :${ DBPASS } @%2Fvar%2Frun%2Fmysqld%2Fmysqld.sock/${ DBNAME } /sogo_user_profile</string>
2017-03-02 12:23:23 +02:00
<key>SOGoTimeZone</key>
<string>${ TZ } </string>
<key>domains</key>
<dict>
EOF
# Generate multi-domain setup
2019-01-17 00:41:13 +02:00
while read -r line gal
2018-11-26 10:10:39 +02:00
do
echo " <key> ${ line } </key>
2017-03-02 12:23:23 +02:00
<dict>
<key>SOGoMailDomain</key>
<string>${ line } </string>
<key>SOGoUserSources</key>
<array>
<dict>
<key>MailFieldNames</key>
<array>
<string>aliases</string>
<string>ad_aliases</string>
2019-09-02 09:30:09 +02:00
<string>ext_acl</string>
2017-03-02 12:23:23 +02:00
</array>
<key>KindFieldName</key>
<string>kind</string>
2017-03-08 18:46:21 +02:00
<key>DomainFieldName</key>
<string>domain</string>
2017-03-02 12:23:23 +02:00
<key>MultipleBookingsFieldName</key>
<string>multiple_bookings</string>
2018-05-06 14:33:20 +02:00
<key>listRequiresDot</key>
<string>NO</string>
2017-03-02 12:23:23 +02:00
<key>canAuthenticate</key>
<string>YES</string>
<key>displayName</key>
2019-01-17 00:41:13 +02:00
<string>GAL ${ line } </string>
2017-03-02 12:23:23 +02:00
<key>id</key>
<string>${ line } </string>
<key>isAddressBook</key>
2019-01-17 00:41:13 +02:00
<string>${ gal } </string>
2017-03-02 12:23:23 +02:00
<key>type</key>
<string>sql</string>
<key>userPasswordAlgorithm</key>
2020-11-15 21:22:35 +02:00
<string>${ MAILCOW_PASS_SCHEME } </string>
2018-07-11 22:08:02 +02:00
<key>prependPasswordScheme</key>
<string>YES</string>
2017-03-02 12:23:23 +02:00
<key>viewURL</key>
[Docker API] Use TLS encryption for communication with "on-the-fly" created key paris (non-exposed)
[Docker API] Create pipe to pass Rspamd UI worker password
[Dovecot] Pull Spamassassin ruleset to be read by Rspamd (MANY THANKS to Peer Heinlein!)
[Dovecot] Garbage collector for deleted maildirs (set keep time via MAILDIR_GC_TIME which defaults to 1440 minutes)
[Web] Flush memcached after mailbox item changes, fixes #1808
[Web] Fix duplicate IDs, fixes #1792
[Compose] Use SQL sockets
[PHP-FPM] Update APCu and Redis libs
[Dovecot] Encrypt maildir with global key pair in crypt-vol-1 (BACKUP!), also fixes #1791
[Web] Fix deletion of spam aliases
[Helper] Add "crypt" to backup script
[Helper] Override file for external SQL socket (not supported!)
[Compose] New images for Rspamd, PHP-FPM, SOGo, Dovecot, Docker API, Watchdog, ACME, Postfix
2018-09-29 22:01:23 +02:00
<string>mysql://${ DBUSER } :${ DBPASS } @%2Fvar%2Frun%2Fmysqld%2Fmysqld.sock/${ DBNAME } /_sogo_static_view</string>
2018-11-26 10:10:39 +02:00
</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
echo " </array>
2017-03-02 12:23:23 +02:00
</dict>" >> /var/lib/sogo/GNUstep/Defaults/sogod.plist
2019-01-17 00:41:13 +02:00
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)
2017-03-02 12:23:23 +02:00
# Generate footer
echo ' </dict>
</dict>
</plist>' >> /var/lib/sogo/GNUstep/Defaults/sogod.plist
# Fix permissions
chown sogo:sogo -R /var/lib/sogo/
chmod 600 /var/lib/sogo/GNUstep/Defaults/sogod.plist
2018-11-18 14:31:09 +02:00
# Patch ACLs
2019-08-25 16:03:57 +02:00
#if [[ ${ACL_ANYONE} == 'allow' ]]; then
# #enable any or authenticated targets for ACL
# if patch -R -sfN --dry-run /usr/lib/GNUstep/SOGo/Templates/UIxAclEditor.wox < /acl.diff > /dev/null; then
# patch -R /usr/lib/GNUstep/SOGo/Templates/UIxAclEditor.wox < /acl.diff;
# fi
#else
# #disable any or authenticated targets for ACL
# if patch -sfN --dry-run /usr/lib/GNUstep/SOGo/Templates/UIxAclEditor.wox < /acl.diff > /dev/null; then
# patch /usr/lib/GNUstep/SOGo/Templates/UIxAclEditor.wox < /acl.diff;
# fi
#fi
2018-08-17 21:42:31 +02:00
2018-12-20 20:02:20 +02:00
# Copy logo, if any
2018-12-22 17:56:50 +02:00
[ [ -f /etc/sogo/sogo-full.svg ] ] && cp /etc/sogo/sogo-full.svg /usr/lib/GNUstep/SOGo/WebServerResources/img/sogo-full.svg
2018-12-20 20:02:20 +02:00
2019-03-29 08:46:28 +02:00
# Rsync web content
echo "Syncing web content with named volume"
rsync -a /usr/lib/GNUstep/SOGo/. /sogo_web/
2020-02-22 10:38:38 +02:00
# Chown backup path
chown -R sogo:sogo /sogo_backup
2017-07-24 23:25:04 +02:00
exec gosu sogo /usr/sbin/sogod