#!/usr/bin/env bash set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" if [ "$(id -u)" -ne 0 ]; then echo "bootstrap-server.sh must run as root" >&2 exit 1 fi install_packages() { if command -v dnf >/dev/null 2>&1; then dnf -y install curl rsync git tar gzip python3 python3-pip dnf-plugins-core ca-certificates java-17-openjdk-devel maven >/dev/null if ! command -v docker >/dev/null 2>&1; then dnf -y install docker docker-compose-plugin >/dev/null 2>&1 || { dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo >/dev/null dnf -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin >/dev/null } fi elif command -v apt-get >/dev/null 2>&1; then apt-get update >/dev/null apt-get install -y curl rsync git tar gzip python3 python3-pip ca-certificates openjdk-17-jdk maven docker.io docker-compose-plugin >/dev/null else echo "unsupported Linux distribution: missing dnf/apt-get" >&2 exit 1 fi } install_packages systemctl enable --now docker >/dev/null mkdir -p "$ROOT_DIR"/{sources,mysql/baseline,run,logs} sysctl -w vm.max_map_count=262144 >/dev/null || true if command -v firewall-cmd >/dev/null 2>&1 && systemctl is-active --quiet firewalld; then firewall-cmd --add-service=http --permanent >/dev/null || true firewall-cmd --add-service=https --permanent >/dev/null || true firewall-cmd --reload >/dev/null || true fi if [ ! -f "$ROOT_DIR/.env" ]; then cp "$ROOT_DIR/.env.example" "$ROOT_DIR/.env" echo "created $ROOT_DIR/.env from example; please review passwords before real use" >&2 fi docker compose version