diff --git a/Dockerfile b/Dockerfile index 703a791bdcf4435088c1c5b69b3feb95a3c4e430..17f625040fb08f5aa5cda4c209a4e5aed580769f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,7 @@ RUN go build -o smtpd smtpd.go # Stage 2: build the final container FROM registry.git.autistici.org/ai3/docker/apache2-base:master +COPY start.sh /start.sh COPY build.sh /tmp/build.sh COPY conf/ /etc/ COPY --from=build /go/src/smtpd /usr/bin/smtpd diff --git a/build.sh b/build.sh index 43574ea5830d5662f1d7c0ff72def6a2979f79d7..f3ebbbd7ae7189e3854d95dbec45f2d62cc17eb2 100755 --- a/build.sh +++ b/build.sh @@ -35,6 +35,14 @@ a2enconf -q serve-cgi-bin # Create mountpoint dirs. mkdir -p /var/lib/lurker +# Lurker installs some package files in mountpoint directories, +# so the original files would disappear "below" the mount. To +# prevent this, we copy the files to a well-known location +# beforehand, and set up links at run-time. +mkdir -p /var/lib/lurker-www +mv /etc/lurker/ui /var/lib/lurker-www/ui +mv /var/lib/lurker/www/index.html /var/lib/lurker-www/index.html + # Clear the existing default config # (this will be mounted externally). rm -fr /etc/lurker/* diff --git a/conf/chaperone.d/start.conf b/conf/chaperone.d/start.conf new file mode 100644 index 0000000000000000000000000000000000000000..22550abae56b25aa95f7d2a675a87769ad359cc9 --- /dev/null +++ b/conf/chaperone.d/start.conf @@ -0,0 +1,7 @@ +lurker_setup.service: { + type: oneshot, + stdout: inherit, + service_groups: INIT, + process_timeout: 60, + command: "/start.sh", +} diff --git a/start.sh b/start.sh new file mode 100755 index 0000000000000000000000000000000000000000..8a01ede77d05697c01116022077a6ac8801371ff --- /dev/null +++ b/start.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +www_dir=/var/lib/lurker/www +static_dir=/var/lib/lurker-www + +echo "Fixing symlinks..." >&2 + +if [ ! -e ${www_dir}/imgs ]; then + ln -sf /usr/share/lurker/www/imgs ${www_dir}/imgs +fi +if [ ! -e ${www_dir}/index.html ]; then + ln -sf ${static_dir}/index.html ${www_dir}/index.html +fi +if [ ! -e ${www_dir}/ui ]; then + ln -sf ${static_dir}/ui ${www_dir}/ui +fi +if [ ! -e ${www_dir}/lurker.docroot ]; then + touch ${www_dir}/lurker.docroot +fi + +exit 0