schon/scripts/Unix/install.sh
Egor fureunoir Gorbunov 7efc19e081 feat(monitoring): automate Prometheus web config generation
Remove manual password hashing and web.yml setup in favor of automated generation. Add scripts for both Unix and Windows to create `monitoring/web.yml` using credentials from `.env`.

This improves maintainability and reduces manual intervention during setup and configuration.
2026-02-22 00:17:55 +03:00

92 lines
3.3 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
source ./scripts/Unix/starter.sh
if [ ! -f .env ]; then
log_warning ".env file not found."
log_info "Run 'make generate-env' first to create your environment file."
exit 0
fi
# ─────────────────────────────────────────────────────────────────────────────
# Installation type selection
# ─────────────────────────────────────────────────────────────────────────────
echo
log_info "Select installation type:"
echo
echo " 1) Docker (recommended for development)"
echo " - Uses Docker Compose to run all services"
echo " - Includes database, Redis, Elasticsearch"
echo
echo " 2) Native Linux (production with systemd)"
echo " - Installs directly on your system"
echo " - Requires existing PostgreSQL, Redis, Elasticsearch"
echo " - Configures systemd services"
echo
if is_interactive; then
read -r -p "Choice [1/2]: " install_choice
else
# Non-interactive mode defaults to Docker
install_choice="1"
log_info "Non-interactive mode: defaulting to Docker installation"
fi
case "$install_choice" in
2)
log_step "Starting native Linux installation..."
source ./scripts/Unix/install-native.sh
;;
1|*)
# ─────────────────────────────────────────────────────────────────────────
# Docker installation (original behavior)
# ─────────────────────────────────────────────────────────────────────────
log_step "Starting Docker installation..."
# Check system requirements
if ! check_system_requirements 4 6 20; then
exit 1
fi
# Check Docker is available
if ! command_exists docker; then
log_error "Docker is not installed. Please install Docker first."
log_info "Visit: https://docs.docker.com/get-docker/"
exit 1
fi
if ! docker info >/dev/null 2>&1; then
log_error "Docker daemon is not running or you don't have permission."
log_info "Try: sudo systemctl start docker"
log_info "Or add yourself to the docker group: sudo usermod -aG docker \$USER"
exit 1
fi
# Pull Docker images
log_step "Pulling images..."
if ! output=$(docker compose pull --quiet 2>&1); then
log_error "Failed to pull Docker images"
echo "$output"
exit 1
fi
log_success "Images pulled successfully"
# Build Docker images
log_step "Building images..."
if ! output=$(docker compose build 2>&1); then
log_error "Failed to build Docker images"
echo "$output"
exit 1
fi
log_success "Images built successfully"
# Generate Prometheus web config from .env
log_step "Generating Prometheus web config..."
generate_prometheus_web_config
echo
log_result "Docker installation complete!"
log_info "You can now use: make run"
;;
esac