diff --git a/README.md b/README.md index 3864470..f22c7c6 100644 --- a/README.md +++ b/README.md @@ -90,9 +90,32 @@ SOGo must be tuned https://sogo.nu/files/docs/SOGoInstallationGuide.html#_micros Keep in mind to set one worker per active user for the activesync connection. The SXVMEMLIMIT https://sogo.nu/files/docs/SOGoInstallationGuide.html#_general_preferences could be be adjusted also, between 25MB to 45 MB per active user with the activesync service. +## Custom configuration files + +You can modify the configuration by adding new files to the folder `/home/sogo1/.config/state/templates`, if the files are present they are used instead of the default one and they are included in the backup of the module + +- sogo configuration: `templates/sogo.conf.local` +- apache configuration: `templates/SOGo.conf.local` +- cron configuration: `templates/cron.conf.local` + +``` +runagent -m sogo1 +# copy the relevant files (copy and edit only the file you need) +cp ../templates/sogo.conf templates/sogo.conf.local +cp ../templates/SOGo.conf templates/SOGo.conf.local +cp ../templates/cron.conf templates/cron.conf.local +# edit the files +vim template/sogo.conf.local +vim templates/SOGo.conf.local +vim templates/cron.conf.local +# restart the service +systemctl restart --user sogo +``` + + ## Backup database -You can enable a databse backup for each users of their addressbooks and their calendars, older entries more than 31 days are removed. The syntax is cron based, in the example it will be triggered each day at 00h30. the backup is disabled by default +You can enable a database backup for each users of their addressbooks and their calendars, older entries more than 31 days are removed. The syntax is cron based, in the example it will be triggered each day at 00h30. the backup is disabled by default ``` - BACKUPTIME=#30 0 diff --git a/imageroot/bin/expand-configuration b/imageroot/bin/expand-configuration index 902b393..b6dae6e 100755 --- a/imageroot/bin/expand-configuration +++ b/imageroot/bin/expand-configuration @@ -13,7 +13,7 @@ import socket from jinja2 import Environment, FileSystemLoader, select_autoescape -files =["config/sogo.conf","config/SOGo.conf"] +files =["config/sogo.conf","config/SOGo.conf","config/cron-sogo"] for f in files: try: os.remove(f) @@ -25,7 +25,11 @@ jenv = Environment( autoescape=select_autoescape(), keep_trailing_newline=True, ) - +jenv_custom = Environment( + loader=FileSystemLoader(os.getenv("AGENT_INSTALL_DIR")+"/state/templates"), + autoescape=select_autoescape(), + keep_trailing_newline=True, +) properties = { "admin_users" : os.environ['ADMIN_USERS'].lower(), "ldap_schema" : os.environ['SOGO_LDAP_SCHEMA'], @@ -58,8 +62,11 @@ properties = { "trashfolder": os.environ['TRASHFOLDER'], "wowatchdogrequesttimeout": os.environ['WOWATCHDOGREQUESTTIMEOUT'] } - -template = jenv.get_template('sogo.conf') +# test if sogo.conf.local exists +if os.path.exists("templates/sogo.conf.local"): + template = jenv_custom.get_template('sogo.conf.local') +else: + template = jenv.get_template('sogo.conf') output = template.render(properties) with open("config/sogo.conf","w") as f: f.write(output) @@ -70,8 +77,11 @@ properties = { "active_sync": True if os.environ['ACTIVESYNC'] == 'True' else False, "dav": True if os.environ['DAV'] == 'True' else False } - -template = jenv.get_template('SOGo.conf') +# test if SOGo.conf.local exists +if os.path.exists("templates/SOGo.conf.local"): + template = jenv_custom.get_template('SOGo.conf.local') +else: + template = jenv.get_template('SOGo.conf') output = template.render(properties) with open("config/SOGo.conf","w") as f: f.write(output) @@ -81,8 +91,11 @@ properties = { "backuptime": os.environ['BACKUPTIME'], "sessionduration": os.environ['SESSIONDURATION'] } - -template = jenv.get_template('cron.conf') +# test if cron.conf.local exists +if os.path.exists("templates/cron.conf.local"): + template = jenv_custom.get_template('cron.conf.local') +else: + template = jenv.get_template('cron.conf') output = template.render(properties) with open("config/cron-sogo","w") as f: f.write(output) diff --git a/imageroot/etc/state-include.conf b/imageroot/etc/state-include.conf index 8a491af..ad2e064 100644 --- a/imageroot/etc/state-include.conf +++ b/imageroot/etc/state-include.conf @@ -5,3 +5,4 @@ # state/sogo.sql state/backups +state/templates diff --git a/imageroot/systemd/user/sogo-app.service b/imageroot/systemd/user/sogo-app.service index 9f9557d..1ff6859 100644 --- a/imageroot/systemd/user/sogo-app.service +++ b/imageroot/systemd/user/sogo-app.service @@ -16,7 +16,7 @@ EnvironmentFile=-%S/state/discovery_ldap.env WorkingDirectory=%S/state Restart=always TimeoutStopSec=70 -ExecStartPre=/usr/bin/bash -c "/bin/mkdir -p {config,backups}" +ExecStartPre=/usr/bin/bash -c "/bin/mkdir -p {config,backups,templates}" ExecStartPre=/bin/rm -f %t/sogo-app.pid %t/sogo-app.ctr-id ExecStartPre=/usr/local/bin/runagent discover-service ExecStartPre=/usr/local/bin/runagent discover-ldap