summaryrefslogtreecommitdiff
path: root/entrypoint.sh
blob: 73cce7ead3eead652de091ebea712447f3f6ca26 (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
#!/bin/sh

# Export all used variables
export CGITRC_CLONE_PREFIX="${CGITRC_CLONE_PREFIX:-""}"
export CGITRC_ENABLE_HTTP_CLONE="${CGITRC_ENABLE_HTTP_CLONE:-"1"}"
export CGITRC_ENABLE_LOG_FILECOUNT="${CGITRC_ENABLE_LOG_LINECOUNT:-"1"}"
export CGITRC_ENABLE_LOG_LINECOUNT="${CGITRC_ENABLE_LOG_FILECOUNT:-"1"}"
export CGITRC_ROOT_DESC="${CGITRC_ROOT_DESC:-"Nondescript"}"
export CGITRC_ROOT_TITLE="${CGITRC_ROOT_TILE:-"Git repository browser"}"
export CGITRC_SCAN_PATH="${CGITRC_SCAN_PATH:-"/srv/git"}"
export CGITRC_SNAPSHOTS="${CGITRC_SNAPSHOTS:-"tar.gz"}"
export HOSTNAME="${HOSTNAME:-"$(hostname -f)"}"
export HTTPD_GROUP="${HTTPD_GROUP:-"1000"}"
export HTTPD_LISTEN_PORT="${HTTPD_LISTEN_PORT:-"80"}"
export HTTPD_PROXY_PROTOCOL="${HTTPD_PROXY_PROTOCOL:-"off"}"
export HTTPD_USER="${HTTPD_USER:-"1000"}"

# Output debugging info
env | grep '^CGITRC_' | sort
env | grep '^HTTPD_' | sort

# Turn templates into proper files
envsubst \
	< "/etc/apache2/httpd.conf.template" \
	> "/etc/apache2/httpd.conf"

envsubst \
	< "/etc/cgitrc.template" \
	> "/etc/cgitrc"

# Create group and user
addgroup -g "$HTTPD_GROUP" cgit
adduser -G cgit -h "$CGITRC_SCAN_PATH" -u "$HTTPD_USER" cgit

# Run apache2
exec /usr/sbin/httpd -D FOREGROUND