Switch to Python for rainloop startup script and fix #93
parent
14687d09ba
commit
50f2ea66c8
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import jinja2
|
||||
import os
|
||||
import shutil
|
||||
|
||||
convert = lambda src, dst: open(dst, "w").write(jinja2.Template(open(src).read()).render(**os.environ))
|
||||
|
||||
# Actual startup script
|
||||
os.environ["FRONT_ADDRESS"] = os.environ.get("FRONT_ADDRESS", "front")
|
||||
os.environ["IMAP_ADDRESS"] = os.environ.get("IMAP_ADDRESS", "imap")
|
||||
|
||||
base = "/data/_data_/_default_/"
|
||||
shutil.rmtree(base + "domains/", ignore_errors=True)
|
||||
os.makedirs(base + "domains", exist_ok=True)
|
||||
os.makedirs(base + "configs", exist_ok=True)
|
||||
|
||||
convert("/default.ini", "/data/_data_/_default_/domains/default.ini")
|
||||
convert("/config.ini", "/data/_data_/_default_/configs/config.ini")
|
||||
|
||||
os.execv("/usr/local/bin/apache2-foreground", ["apache2-foreground"])
|
@ -1,20 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
template(){
|
||||
sed \
|
||||
-e "s/%FRONT_ADDRESS%/$FRONT_ADDRESS/g" \
|
||||
-e "s/%IMAP_ADDRESS%/$IMAP_ADDRESS/g"
|
||||
}
|
||||
|
||||
# There is no cleaner way to setup the default SMTP/IMAP server or to
|
||||
# override the configuration
|
||||
rm -f /data/_data_/_default_/domains/*
|
||||
mkdir -p /data/_data_/_default_/domains/ /data/_data_/_default_/configs/
|
||||
template </default.ini >/data/_data_/_default_/domains/default.ini
|
||||
template </config.ini >/data/_data_/_default_/configs/config.ini
|
||||
|
||||
# Fix some permissions
|
||||
chown -R www-data:www-data /data
|
||||
|
||||
# Run apache
|
||||
exec apache2-foreground
|
Loading…
Reference in New Issue