-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·51 lines (44 loc) · 1.75 KB
/
setup.sh
File metadata and controls
executable file
·51 lines (44 loc) · 1.75 KB
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
#!/usr/bin/env bash
# this File is part of OpenVPN-WebAdmin - (c) 2026 OpenVPN-WebAdmin
#
# NOTICE OF LICENSE
#
# GNU AFFERO GENERAL PUBLIC LICENSE V3
# that is bundled with this package in the file LICENSE.md.
# It is also available through the world-wide-web at this URL:
# https://www.gnu.org/licenses/agpl-3.0.en.html
#
# @fork Original Idea and parts in this script from: https://github.com/Chocobozzz/OpenVPN-Admin
#
# @author Wutze
# @copyright 2026 OpenVPN-WebAdmin
# @link https://github.com/Wutze/OpenVPN-WebAdmin
# @see Internal Documentation ~/doc/
# @version 2.0.0
# @todo new issues report here please https://github.com/Wutze/OpenVPN-WebAdmin/issues
set -euo pipefail
SELF_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# If the full repository is already present, run installer directly.
if [ -x "${SELF_DIR}/server/installation/setup.sh" ]; then
exec "${SELF_DIR}/server/installation/setup.sh" "$@"
fi
# Standalone bootstrap mode (script downloaded alone).
REPO_URL="${OVPN_SETUP_REPO_URL:-http://gitlab1.home/micro/openvpn-webadmin-intern.git}"
REPO_BRANCH="${OVPN_SETUP_REPO_BRANCH:-main}"
WORK_DIR="${OVPN_SETUP_WORKDIR:-/tmp/openvpn-webadmin-setup-src}"
command -v git >/dev/null 2>&1 || {
echo "git is required but not installed."
exit 1
}
if [ -d "${WORK_DIR}/.git" ]; then
git -C "${WORK_DIR}" fetch --all --prune
git -C "${WORK_DIR}" checkout "${REPO_BRANCH}"
git -C "${WORK_DIR}" pull --ff-only origin "${REPO_BRANCH}"
elif [ -d "${WORK_DIR}" ] && [ -n "$(ls -A "${WORK_DIR}" 2>/dev/null)" ]; then
echo "Work directory exists and is not empty: ${WORK_DIR}"
exit 1
else
mkdir -p "$(dirname "${WORK_DIR}")"
git clone --branch "${REPO_BRANCH}" "${REPO_URL}" "${WORK_DIR}"
fi
exec "${WORK_DIR}/server/installation/setup.sh" "$@"