summaryrefslogtreecommitdiffstats
path: root/run-gomf-modpanel.bash
blob: 220b06d012f5acf8084b5e09e26454c437a9e878 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash

# This software is released into public domain.
# It is provided "as is", without warranties or conditions of any kind.
# Anyone is free to modify, redistribute and do anything with this software.

# Simple startup/configuration script for gomf-modpanel
# Leave options blank ("OPTION=", "OPTION=''") or comment them out to use
# gomf-modpanel defaults (see `gomf-modpanel --help`)

set -e

###############################################################################


# The gomf-modpanel binary
#GOMF_MODPANEL_BIN=gomf-modpanel

# Root folder for Gomf containing gomf-modpanel-web files
#
# Defaults to current directory if not set.
#GOMF_MODPANEL_ROOT=~/www/gomf-modpanel-web

# Root folder for Gomf containing gomf-web files
#
# Defaults to current directory if not set.
#GOMF_ROOT=~/www/gomf-web/

# URL path prefix to serve modpanel under
#URL_PREFIX=/mod/

# URL path to deletion log
#DELETION_LOG=/deleted

# The URL that Gomf serves uploaded files on
#
# Defaults to /u/
#UPLOAD_URL=https://u.example.com/

# 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=localhost

# 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=8080

# 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

# List of usernames and passwords that can access the mod panel
#
# Entries should be in the form "user:password"
#ACCESS=(
#	test:test
#)


###############################################################################

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 "${HTTP_HOST:-localhost}:$HTTP_PORT")
[ -n "$HTTPS_PORT" ] && [ -n "$TLS_CERT" ] && [ -n "$TLS_KEY" ] && flags+=(
	--https "${HTTP_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[@]}"