#!/usr/bin/env bash set -euo pipefail if [[ "${EUID}" -ne 0 ]]; then echo "Run as root: sudo bash scripts/install-system.sh" exit 1 fi REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" PUBLIC_DIR="$REPO_ROOT/public" detect_host() { if [[ -n "${XLX_PUBLIC_HOST:-}" ]]; then echo "$XLX_PUBLIC_HOST" return fi local fqdn fqdn="$(hostname -f 2>/dev/null || true)" if [[ -n "$fqdn" && "$fqdn" != "localhost" && "$fqdn" != "localhost.localdomain" ]]; then echo "$fqdn" return fi local ip ip="$(hostname -I 2>/dev/null | awk '{print $1}')" if [[ -n "$ip" ]]; then echo "$ip" return fi echo "127.0.0.1" } port_is_busy() { local port="$1" ss -ltnH "sport = :${port}" 2>/dev/null | grep -q . } detect_panel_port() { if [[ -n "${XLX_PANEL_PORT:-}" ]]; then echo "$XLX_PANEL_PORT" return fi for port in 80 8088 8090 8091; do if ! port_is_busy "$port"; then echo "$port" return fi done echo "8099" } random_token() { local token token="$(tr -dc 'A-Za-z0-9' "$REPO_ROOT/config/config.php" < /etc/xlx/xlxd.env < /etc/apache2/ports.conf < /etc/apache2/sites-available/xlx-panel.conf a2dissite 000-default.conf >/dev/null 2>&1 || true a2ensite xlx-panel.conf systemctl restart apache2 bash "$REPO_ROOT/scripts/install-xlxd.sh" systemctl start xlxd || true cat <