summaryrefslogtreecommitdiffstats
path: root/gomf-modpanel/run-gomf-modpanel.bash
diff options
context:
space:
mode:
Diffstat (limited to 'gomf-modpanel/run-gomf-modpanel.bash')
-rw-r--r--gomf-modpanel/run-gomf-modpanel.bash64
1 files changed, 64 insertions, 0 deletions
diff --git a/gomf-modpanel/run-gomf-modpanel.bash b/gomf-modpanel/run-gomf-modpanel.bash
new file mode 100644
index 0000000..bfa4385
--- /dev/null
+++ b/gomf-modpanel/run-gomf-modpanel.bash
@@ -0,0 +1,64 @@
+#!/bin/bash
+
+set -eu
+
+###############################################################################
+
+# The gomf-modpanel binary
+GOMF_MODPANEL_BIN=/app/gomf-modpanel
+
+# Root folder for Gomf containing gomf-modpanel-web files
+#
+# Defaults to current directory if not set.
+GOMF_MODPANEL_ROOT=/gomf-modpanel
+
+# Root folder for Gomf containing gomf-web files
+#
+# Defaults to current directory if not set.
+GOMF_ROOT=/gomf
+
+# The host to listen on for HTTP and/or HTTPS
+#
+# Use 'localhost' if using local reverse proxy, 0.0.0.0 to listen to any host
+# or a specific hostname to only allow connections to that address.
+LISTEN_HOST=0.0.0.0
+
+# The port to listen on for HTTP
+#
+# 80 for a standard HTTP server, probably a higher port (e.g. 9000) if
+# reverse-proxied.
+HTTP_PORT=9001
+
+# The port to listen on for HTTPS
+#
+# 443 for a standard HTTPS server. Requires TLS_CERT and TLS_KEY
+#HTTPS_PORT=8443
+
+# SSL certificate for HTTPS
+#TLS_CERT=cert.pem
+
+# SSL certificate key for HTTPS
+#TLS_KEY=key.pem
+
+source /gomf-modpanel.conf
+
+###############################################################################
+
+flags=()
+[ -n "${GOMF_MODPANEL_ROOT:-}" ] && cd "$GOMF_MODPANEL_ROOT"
+[ -n "${GOMF_ROOT:-}" ] && flags+=(--gomf-root "$GOMF_ROOT")
+[ -n "${URL_PREFIX:-}" ] && flags+=(--prefix "$URL_PREFIX")
+[ -n "${DELETION_LOG:-}" ] && flags+=(--deletion-log "$DELETION_LOG")
+[ -n "${UPLOAD_URL:-}" ] && flags+=(--upload-url "$UPLOAD_URL")
+[ -n "${HTTP_PORT:-}" ] && flags+=(--http "${LISTEN_HOST:-localhost}:$HTTP_PORT")
+[ -n "${HTTPS_PORT:-}" ] && [ -n "${TLS_CERT:-}" ] && [ -n "${TLS_KEY:-}" ] && flags+=(
+ --https "${LISTEN_HOST:-localhost}:$HTTPS_PORT"
+ --cert "$TLS_CERT" --key "$TLS_KEY")
+oldifs="$IFS" IFS=,
+[ -n "${ACCESS[*]:-}" ] && flags+=(--access "${ACCESS[*]}")
+IFS="$oldifs"
+
+printf "%s" "${GOMF_MODPANEL_BIN:-gomf-modpanel}"
+[ "${#flags}" -gt 0 ] && printf " \"%s\"" "${flags[@]}"
+printf "\n"
+exec "${GOMF_MODPANEL_BIN:-gomf-modpanel}" "${flags[@]}"