summaryrefslogtreecommitdiffstats
path: root/gomf-modpanel/run-gomf-modpanel.bash
blob: bfa43859247a7c6424e55488c62bd88f90d9c964 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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[@]}"