summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMike Delago <32778141+michaeldelago@users.noreply.github.com>2024-05-18 13:12:22 -0400
committerGitHub <noreply@github.com>2024-05-18 19:12:22 +0200
commit45145fed48b56859def41d327b64307580d2d126 (patch)
tree2c51726b293dacdf56c8d3efc86ed9426d03f64a /apps
parentdd0e6262d1d396a19e4945155c9fe1247f69dcd4 (diff)
fix(Docker): Check write access for config dir (#18238)
Diffstat (limited to 'apps')
-rw-r--r--apps/docker/entrypoint.sh38
1 files changed, 35 insertions, 3 deletions
diff --git a/apps/docker/entrypoint.sh b/apps/docker/entrypoint.sh
index 5cd7fc28dc..ad08fb77e4 100644
--- a/apps/docker/entrypoint.sh
+++ b/apps/docker/entrypoint.sh
@@ -1,14 +1,46 @@
#!/usr/bin/env bash
set -euo pipefail
+CONF_DIR="${CONF_DIR:-/azerothcore/env/dist/etc}"
+LOGS_DIR="${LOGS_DIR:-/azerothcore/env/dist/logs}"
+
+if ! touch "$CONF_DIR/.write-test" || ! touch "$LOGS_DIR/.write-test"; then
+ cat <<EOF
+===== WARNING =====
+The current user doesn't have write permissions for
+the configuration dir ($CONF_DIR) or logs dir ($LOGS_DIR).
+It's likely that services will fail due to this.
+
+This is usually caused by cloning the repository as root,
+so the files are owned by root (uid 0).
+
+To resolve this, you can set the ownership of the
+configuration directory with the command on the host machine.
+Note that if the files are owned as root, the ownership must
+be changed as root (hence sudo).
+
+$ sudo chown -R $(id -u):$(id -g) /path/to$CONF_DIR /path/to$LOGS_DIR
+
+Alternatively, you can set the DOCKER_USER environment
+variable (on the host machine) to "root", though this
+isn't recommended.
+
+$ DOCKER_USER=root docker-compose up -d
+====================
+EOF
+fi
+
+[[ -f "$CONF_DIR/.write-test" ]] && rm -f "$CONF_DIR/.write-test"
+[[ -f "$LOGS_DIR/.write-test" ]] && rm -f "$LOGS_DIR/.write-test"
+
# Copy all default config files to env/dist/etc if they don't already exist
# -r == recursive
# -n == no clobber (don't overwrite)
# -v == be verbose
-cp -rnv /azerothcore/env/ref/etc/* /azerothcore/env/dist/etc
+cp -rnv /azerothcore/env/ref/etc/* "$CONF_DIR"
-CONF="/azerothcore/env/dist/etc/$ACORE_COMPONENT.conf"
-CONF_DIST="/azerothcore/env/dist/etc/$ACORE_COMPONENT.conf.dist"
+CONF="$CONF_DIR/$ACORE_COMPONENT.conf"
+CONF_DIST="$CONF_DIR/$ACORE_COMPONENT.conf.dist"
# Copy the "dist" file to the "conf" if the conf doesn't already exist
if [[ -f "$CONF_DIST" ]]; then