Switch to Python for rainloop startup script and fix #93

master
Pierre Jaury 7 years ago
parent 14687d09ba
commit 50f2ea66c8

@ -1,7 +1,7 @@
FROM php:5-apache FROM php:5-apache
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
unzip unzip python3 python3-jinja2
ENV RAINLOOP_URL https://github.com/RainLoop/rainloop-webmail/releases/download/v1.12.0/rainloop-community-1.12.0.zip ENV RAINLOOP_URL https://github.com/RainLoop/rainloop-webmail/releases/download/v1.12.0/rainloop-community-1.12.0.zip
@ -22,6 +22,6 @@ COPY php.ini /usr/local/etc/php/conf.d/rainloop.ini
COPY config.ini /config.ini COPY config.ini /config.ini
COPY default.ini /default.ini COPY default.ini /default.ini
COPY start.sh /start.sh COPY start.py /start.py
CMD ["/start.sh"] CMD /start.py

@ -1,13 +1,13 @@
imap_host = "%FRONT_ADDRESS%" imap_host = "{{ FRONT_ADDRESS }}"
imap_port = 10143 imap_port = 10143
imap_secure = "None" imap_secure = "None"
imap_short_login = Off imap_short_login = Off
sieve_use = On sieve_use = On
sieve_allow_raw = Off sieve_allow_raw = Off
sieve_host = "%IMAP_ADDRESS%" sieve_host = "{{ IMAP_ADDRESS }}"
sieve_port = 4190 sieve_port = 4190
sieve_secure = "None" sieve_secure = "None"
smtp_host = "%FRONT_ADDRESS%" smtp_host = "{{ FRONT_ADDRESS }}"
smtp_port = 10025 smtp_port = 10025
smtp_secure = "None" smtp_secure = "None"
smtp_short_login = Off smtp_short_login = Off

@ -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…
Cancel
Save