-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·104 lines (92 loc) · 3.92 KB
/
Copy pathrun.sh
File metadata and controls
executable file
·104 lines (92 loc) · 3.92 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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env bash
# run.sh -- Main entry point for Mifos Gazelle deployment scripts
# macOS ships bash 3.2 which lacks associative arrays (declare -A) and
# name references (local -n). Re-exec with Homebrew bash 5 when needed.
if [[ "${BASH_VERSINFO[0]}" -lt 4 ]]; then
# Re-exec with an already-installed bash 4+
for brew_bash in /opt/homebrew/bin/bash /usr/local/bin/bash; do
if [[ -x "$brew_bash" ]]; then
exec "$brew_bash" "$0" "$@"
fi
done
# Not found — locate brew and install bash as the non-root invoking user
brew_bin=""
for candidate in /opt/homebrew/bin/brew /usr/local/bin/brew; do
[[ -x "$candidate" ]] && brew_bin="$candidate" && break
done
if [[ -z "$brew_bin" ]]; then
echo "ERROR: bash 4+ and Homebrew are both required on macOS." >&2
echo " Install Homebrew from https://brew.sh then re-run." >&2
exit 1
fi
# Determine the non-root user to run brew as (brew refuses to run as root)
brew_user="${SUDO_USER:-}"
if [[ -z "$brew_user" || "$brew_user" == "root" ]]; then
brew_user=$(stat -f '%Su' /dev/console 2>/dev/null || echo "")
fi
if [[ -z "$brew_user" || "$brew_user" == "root" ]]; then
echo "ERROR: Cannot determine a non-root user to run 'brew install bash'." >&2
echo " Please run: brew install bash" >&2
exit 1
fi
echo "INFO bash 4+ not found. Installing via Homebrew (this may take a moment)..."
if ! sudo -u "$brew_user" "$brew_bin" install bash; then
echo "ERROR: 'brew install bash' failed. Please install it manually and re-run." >&2
exit 1
fi
for brew_bash in /opt/homebrew/bin/bash /usr/local/bin/bash; do
if [[ -x "$brew_bash" ]]; then
exec "$brew_bash" "$0" "$@"
fi
done
echo "ERROR: bash 4+ still not found after install. Please check your Homebrew setup." >&2
exit 1
fi
if [[ "$(id -u)" -eq 0 ]]; then
echo "ERROR: run.sh must not be run as root or with sudo." >&2
echo " Use: ./run.sh -m deploy -a all" >&2
echo " For environment setup (k3s, /etc/hosts), use: sudo ./setup-env.sh" >&2
exit 1
fi
RUN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # the directory that this script is in
export RUN_DIR
# On macOS, sudo strips PATH so Homebrew binaries are not found.
# Prepend both known Homebrew locations so all subsequent commands work.
if [[ "$(uname -s)" == "Darwin" ]]; then
export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
fi
########################################################################
# GLOBAL VARS
# these are not user configurables - for internal script use only
########################################################################
BASE_DIR="$( cd "$(dirname "$0")" ; pwd )"
DEPLOY_WORK_DIR="/tmp/gazelle-deploy"
CONFIG_DIR="$BASE_DIR/config"
UTILS_DIR="$BASE_DIR/src/utils"
DATA_LOADING_DIR="$UTILS_DIR/data-loading"
export UTILS_DIR DATA_LOADING_DIR
# Python interpreter: use the project-local venv when available so data-loading
# scripts have their dependencies (requests, etc.) without touching system Python.
# Falls back to system python3 if the venv hasn't been created yet (e.g. first run
# before env-setup, or when running a deploy directly against a remote cluster).
if [[ -x "$BASE_DIR/.venv/bin/python3" ]]; then
PYTHON3="$BASE_DIR/.venv/bin/python3"
else
PYTHON3="python3"
fi
export PYTHON3
INFRA_CHART_DIR="$BASE_DIR/src/deployer/helm/infra"
NGINX_VALUES_FILE="$CONFIG_DIR/nginx_values.yaml"
# Mojaloop vNext
VNEXT_LAYER_DIRS=("$DEPLOY_WORK_DIR/vnext/crosscut" "$DEPLOY_WORK_DIR/vnext/apps" "$DEPLOY_WORK_DIR/vnext/reporting")
#PaymentHub EE
PH_VALUES_FILE="$CONFIG_DIR/ph_values.yaml"
#MifosX
MIFOSX_MANIFESTS_DIR="$DEPLOY_WORK_DIR/mifosx"
# Source commandline.sh
source "$RUN_DIR/src/commandline/commandline.sh"
## Dependency versioning ##
KUBECTL_VERSION="v1.30.0"
HELM_VERSION="v3.14.4"
# Call main with all arguments
main "$@"