-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·73 lines (63 loc) · 2.17 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·73 lines (63 loc) · 2.17 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
#!/usr/bin/env bash
set -euo pipefail
APP_NAME="tak-pref-configurator"
APP_DIR="${APP_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
APP_PORT="${APP_PORT:-8080}"
log() {
printf '[install] %s\n' "$*"
}
require_root_for_docker() {
if ! command -v docker >/dev/null 2>&1; then
log "Docker not found. Installing Docker..."
if [[ "${EUID}" -ne 0 ]]; then
log "Re-run with sudo to install Docker, or install Docker manually first."
exit 1
fi
apt-get update
apt-get install -y ca-certificates curl gnupg
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" \
> /etc/apt/sources.list.d/docker.list
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
systemctl enable --now docker
fi
}
ensure_compose() {
if docker compose version >/dev/null 2>&1; then
COMPOSE="docker compose"
elif command -v docker-compose >/dev/null 2>&1; then
COMPOSE="docker-compose"
else
log "Docker Compose plugin not found. Install docker-compose-plugin and retry."
exit 1
fi
}
write_env_file() {
if [[ ! -f "${APP_DIR}/.env" ]]; then
cat > "${APP_DIR}/.env" <<EOF
APP_PORT=${APP_PORT}
EOF
log "Created ${APP_DIR}/.env"
fi
}
main() {
cd "${APP_DIR}"
log "Installing ${APP_NAME} from ${APP_DIR}"
require_root_for_docker
ensure_compose
write_env_file
APP_PORT="${APP_PORT}" ${COMPOSE} -f docker-compose.yml up -d --build
if [[ -x "${APP_DIR}/deploy/setup-nginx.sh" ]]; then
APP_DIR="${APP_DIR}" APP_PORT="${APP_PORT}" PREF_DOMAIN="${PREF_DOMAIN:-pref.tak-solutions.com}" \
CERTBOT_EMAIL="${CERTBOT_EMAIL:-}" bash "${APP_DIR}/deploy/setup-nginx.sh"
fi
log "Installation complete."
log "Application URL: http://${PREF_DOMAIN:-pref.tak-solutions.com}/"
log "Local URL: http://127.0.0.1:${APP_PORT}"
}
main "$@"