From 8de79895d02fff4ee770d85554fc9a606d2adc27 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 24 Jun 2020 15:29:58 +0200 Subject: [PATCH] entrypoint/: initialize /data refs #2 --- deps.Dockerfile | 4 +++- entrypoint/main.go | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/deps.Dockerfile b/deps.Dockerfile index b73af08..9ac0d57 100644 --- a/deps.Dockerfile +++ b/deps.Dockerfile @@ -27,6 +27,8 @@ EXPOSE 8080 RUN ["chmod", "o+x", "/var/log/apache2"] RUN ["chown", "www-data:www-data", "/var/run/apache2"] -RUN ["install", "-o", "www-data", "-g", "www-data", "-d", "/etc/icingaweb2"] +RUN ["ln", "-vs", "/data/etc/icingaweb2", "/etc/icingaweb2"] +RUN ["install", "-o", "www-data", "-g", "www-data", "-d", "/data"] +VOLUME ["/data"] ENTRYPOINT ["/entrypoint"] diff --git a/entrypoint/main.go b/entrypoint/main.go index f8da5a0..9d432cd 100644 --- a/entrypoint/main.go +++ b/entrypoint/main.go @@ -23,6 +23,15 @@ func entrypoint() error { return nil } + if os.Getpid() == 1 { + logf("info", "Initializing /data as we're the init process") + + logf("debug", `Creating "/data/etc/icingaweb2"`) + if errMA := os.MkdirAll("/data/etc/icingaweb2", 0750); errMA != nil { + return errMA + } + } + path := os.Args[1] if filepath.Base(path) == path { logf("info", "Looking up %#v in $PATH", path)