Skip to content

Commit

Permalink
feat: Enhance configuration expansion to support local overrides for …
Browse files Browse the repository at this point in the history
…SOGo and cron configurations
  • Loading branch information
stephdl committed Nov 8, 2024
1 parent 3953bd6 commit da0ac89
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions imageroot/bin/expand-configuration
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'],
Expand Down Expand Up @@ -58,8 +62,11 @@ properties = {
"trashfolder": os.environ['TRASHFOLDER'],
"wowatchdogrequesttimeout": os.environ['WOWATCHDOGREQUESTTIMEOUT']
}

template = jenv.get_template('sogo.conf')
# test if sogo.con.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)
Expand All @@ -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)
Expand All @@ -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)

0 comments on commit da0ac89

Please sign in to comment.