#!/usr/bin/env bash # # GamePanel — one-shot Docker setup. # # ./scripts/install.sh # docker compose up -d --build # # Writes a .env with generated secrets and a daemon-config.yml with a matching # node token. Deliberately does NOT set up TLS or a domain: the panel serves # plain HTTP and you put your own reverse proxy in front of it. set -euo pipefail cd "$(dirname "$0")/.." ENV_FILE=".env" DAEMON_CONFIG="daemon-config.yml" random_hex() { if command -v openssl >/dev/null 2>&1; then openssl rand -hex "$1" else head -c "$1" /dev/urandom | od -An -tx1 | tr -d ' \n' fi } if [ -f "$ENV_FILE" ]; then echo "$ENV_FILE already exists — leaving it untouched." else echo "Generating $ENV_FILE ..." JWT_SECRET="$(random_hex 64)" JWT_REFRESH_SECRET="$(random_hex 64)" DB_PASSWORD="$(random_hex 24)" REDIS_PASSWORD="$(random_hex 24)" DAEMON_TOKEN="$(random_hex 32)" WEB_PORT="${WEB_PORT:-80}" cat > "$ENV_FILE" </dev/null || { echo " could not create $DATA_PATH / $BACKUP_PATH — rerun with sudo, or set" echo " DAEMON_DATA_PATH / DAEMON_BACKUP_PATH in $ENV_FILE to a writable path." exit 1 } if [ -f "$DAEMON_CONFIG" ] && ! grep -q 'CHANGE_ME_GENERATE_A_SECURE_TOKEN' "$DAEMON_CONFIG"; then echo "$DAEMON_CONFIG already configured — leaving it untouched." else # A pre-existing .env may predate DAEMON_TOKEN; mint one and record it so the # panel and the daemon agree on the same value. if [ -z "${DAEMON_TOKEN:-}" ]; then DAEMON_TOKEN="$(random_hex 32)" printf '\nDAEMON_TOKEN=%s\n' "$DAEMON_TOKEN" >> "$ENV_FILE" echo "Added a generated DAEMON_TOKEN to $ENV_FILE" fi echo "Writing $DAEMON_CONFIG ..." cat > "$DAEMON_CONFIG" <