#!/usr/bin/env bash # DogPanel installer — turns a fresh Debian/Ubuntu VPS into a working # game panel (panel + Wings + Docker) with no questions asked. # # curl -fsSL https://dogpanel.strt.host/install.sh | bash # # Options (all optional): # --domain panel.example.com use your own domain instead of a free *.p.ruas.run one # --email you@example.com admin e-mail (also used for Let's Encrypt) # --no-ssl plain HTTP on the server's IP # --tarball /path/file.tar.gz install a local build instead of downloading # --channel beta release channel (default: stable) # # Safe to run again: finished steps are skipped. Log: /var/log/dogpanel-install.log set -euo pipefail HUB_URL=${DOG_HUB_URL:-https://dogpanel.strt.host} PANEL_DIR=/var/www/dogpanel CREDENTIALS=/root/dogpanel-credentials.txt LOG=/var/log/dogpanel-install.log DOMAIN="" EMAIL="" SSL=1 TARBALL="" CHANNEL=stable while [ $# -gt 0 ]; do case "$1" in --domain) DOMAIN="$2"; shift ;; --email) EMAIL="$2"; shift ;; --no-ssl) SSL=0 ;; --tarball) TARBALL="$2"; shift ;; --channel) CHANNEL="$2"; shift ;; *) echo "Unknown option: $1" >&2; exit 1 ;; esac shift done [ "$(id -u)" = 0 ] || { echo "Run the installer as root." >&2; exit 1; } exec > >(tee -a "$LOG") 2>&1 export DEBIAN_FRONTEND=noninteractive step() { echo; echo "==> $*"; } fail() { echo "ERROR: $*" >&2; motd "DogPanel installation FAILED. See $LOG"; exit 1; } motd() { printf '\n %s\n\n' "$1" > /etc/motd; } random() { openssl rand -hex 64 | cut -c1-"${1:-24}"; } apt_install() { apt-get -o DPkg::Lock::Timeout=600 install -y -qq "$@" >/dev/null; } artisan() { (cd "$PANEL_DIR" && runuser -u www-data -- php8.3 artisan "$@"); } trap 'fail "line $LINENO failed"' ERR . /etc/os-release case "$ID-$VERSION_ID" in debian-12|debian-13|ubuntu-22.04|ubuntu-24.04) ;; *) fail "Unsupported system ($PRETTY_NAME). Use Debian 12/13 or Ubuntu 22.04/24.04." ;; esac motd "DogPanel is being installed… follow it with: tail -f $LOG" # ---------------------------------------------------------------- packages step "Installing system packages" apt-get -o DPkg::Lock::Timeout=600 update -qq apt_install ca-certificates curl gnupg jq tar unzip rsync cron lsb-release if [ "$ID" = debian ]; then curl -fsSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $VERSION_CODENAME main" > /etc/apt/sources.list.d/sury-php.list else apt_install software-properties-common add-apt-repository -y ppa:ondrej/php >/dev/null fi apt-get -o DPkg::Lock::Timeout=600 update -qq apt_install php8.3 php8.3-{cli,common,gd,mysql,mbstring,bcmath,xml,fpm,curl,zip,intl,redis} \ mariadb-server nginx redis-server certbot systemctl enable -q --now mariadb redis-server php8.3-fpm nginx cron if ! command -v docker >/dev/null; then step "Installing Docker" curl -fsSL https://get.docker.com | sh >/dev/null 2>&1 fi systemctl enable -q --now docker # ---------------------------------------------------------------- address step "Choosing an address" IP=$(curl -fsS4 --retry 3 https://cloudflare.com/cdn-cgi/trace | sed -n 's/^ip=//p') [ -n "$IP" ] || fail "Could not detect the public IPv4 address." mkdir -p /etc/dogpanel [ -f /etc/dogpanel/config ] && . /etc/dogpanel/config # reuse choices from a previous run DOMAIN=${DOMAIN:-${PANEL_DOMAIN:-}} if [ -z "$DOMAIN" ] && [ $SSL = 1 ]; then # Ask the hub for a free hostname pointing at this machine (.p.ruas.run). DOMAIN=$(curl -fsS4 --retry 3 -X POST "$HUB_URL/dns/claim" | jq -r '.hostname // empty' || true) [ -n "$DOMAIN" ] && echo "Got hostname $DOMAIN" || echo "No hostname available, falling back to plain HTTP." fi if [ -z "$DOMAIN" ]; then SSL=0; DOMAIN=$IP; fi EMAIL=${EMAIL:-admin@$([ $SSL = 1 ] && echo "$DOMAIN" || echo dogpanel.local)} # ---------------------------------------------------------------- web server write_nginx() { # $1 = http | https { if [ "$1" = https ]; then cat < /etc/nginx/sites-available/dogpanel.conf ln -sf /etc/nginx/sites-available/dogpanel.conf /etc/nginx/sites-enabled/dogpanel.conf rm -f /etc/nginx/sites-enabled/default nginx -t -q && systemctl reload nginx } # ---------------------------------------------------------------- panel files step "Installing the panel" mkdir -p "$PANEL_DIR" if [ ! -f "$PANEL_DIR/dog.json" ]; then work=$(mktemp -d) if [ -n "$TARBALL" ]; then cp "$TARBALL" "$work/release.tar.gz" else curl -fsSL --retry 3 "$HUB_URL/releases/latest.json?channel=$CHANNEL" -o "$work/latest.json" curl -fsSL --retry 3 "$(jq -r .url "$work/latest.json")" -o "$work/release.tar.gz" echo "$(jq -r .sha256 "$work/latest.json") $work/release.tar.gz" | sha256sum -c - >/dev/null || fail "Download is corrupted (checksum mismatch)." fi tar -xzf "$work/release.tar.gz" -C "$PANEL_DIR" rm -rf "$work" fi mkdir -p "$PANEL_DIR"/storage/{logs,app/dog,framework/{cache,sessions,views}} "$PANEL_DIR/bootstrap/cache" chown -R www-data:www-data "$PANEL_DIR" write_nginx http SCHEME=http if [ $SSL = 1 ]; then step "Requesting an HTTPS certificate for $DOMAIN" # DNS for a freshly claimed hostname can take a moment to show up. for _ in $(seq 1 30); do [ "$(getent ahostsv4 "$DOMAIN" | awk 'NR==1{print $1}')" = "$IP" ] && break; sleep 4; done if [ -d "/etc/letsencrypt/live/$DOMAIN" ] || certbot certonly --webroot -w "$PANEL_DIR/public" -d "$DOMAIN" \ --non-interactive --agree-tos -m "$EMAIL" --no-eff-email -q; then SCHEME=https write_nginx https printf '#!/bin/sh\nsystemctl reload nginx\nsystemctl restart wings\n' > /etc/letsencrypt/renewal-hooks/deploy/dogpanel.sh chmod +x /etc/letsencrypt/renewal-hooks/deploy/dogpanel.sh else echo "Certificate could not be issued — continuing over HTTP on the IP address." DOMAIN=$IP write_nginx http fi fi URL="$SCHEME://$DOMAIN" cat > /etc/dogpanel/config <> "$ENV_FILE"; } cp "$PANEL_DIR/.env.example" "$ENV_FILE" set_env APP_KEY "base64:$(openssl rand -base64 32)" set_env APP_URL "$URL" set_env APP_TIMEZONE "$(cat /etc/timezone 2>/dev/null || echo UTC)" set_env APP_ENVIRONMENT_ONLY false set_env APP_SERVICE_AUTHOR "$EMAIL" set_env DB_USERNAME dogpanel set_env DB_PASSWORD "$DB_PASS" set_env CACHE_DRIVER redis set_env SESSION_DRIVER redis set_env QUEUE_CONNECTION redis set_env MAIL_MAILER log set_env RECAPTCHA_ENABLED false # can be turned on under Admin > Settings set_env HASHIDS_SALT "$(random 20)" set_env PTERODACTYL_TELEMETRY_ENABLED false chown www-data:www-data "$ENV_FILE"; chmod 640 "$ENV_FILE" echo "$DBHOST_PASS" > /etc/dogpanel/dbhost.pass; chmod 600 /etc/dogpanel/dbhost.pass mv "$ENV_FILE" "$PANEL_DIR/.env" else sed -i "s|^APP_URL=.*|APP_URL=$URL|" "$PANEL_DIR/.env" fi step "Preparing the database" artisan migrate --seed --force -q artisan optimize:clear -q # ---------------------------------------------------------------- admin account if [ ! -f "$CREDENTIALS" ]; then step "Creating the administrator account" ADMIN_PASS=$(random 16) artisan p:user:make --email="$EMAIL" --username=admin --name-first=Admin --name-last=DogPanel \ --password="$ADMIN_PASS" --admin=1 -q cat > "$CREDENTIALS" < Account). Useful commands: dogpanel status | dogpanel update | dogpanel password admin TXT chmod 600 "$CREDENTIALS" fi # ---------------------------------------------------------------- node + wings step "Setting up this machine as the game server node" MEM_MB=$(awk '/MemTotal/{printf "%d", $2/1024}' /proc/meminfo) DISK_MB=$(df -m --output=avail /var/lib | tail -1 | tr -d ' ') # Leave room for the system and the panel itself. NODE_MEM=$(( MEM_MB > 3072 ? MEM_MB - 1536 : MEM_MB * 6 / 10 )) NODE_DISK=$(( DISK_MB > 20480 ? DISK_MB - 10240 : DISK_MB / 2 )) NODE_ID=$(artisan dog:setup --fqdn="$DOMAIN" --ip="$IP" --scheme="$SCHEME" --memory="$NODE_MEM" --disk="$NODE_DISK" \ --db-user=dogdbhost --db-password="$(cat /etc/dogpanel/dbhost.pass)" | tail -1) bash "$PANEL_DIR/installer/dogpanel" _install_system_files "$PANEL_DIR" command -v wings >/dev/null || bash "$PANEL_DIR/installer/dogpanel" _install_wings "$(jq -r .wings "$PANEL_DIR/dog.json")" mkdir -p /etc/pterodactyl /var/lib/pterodactyl/volumes artisan p:node:configuration "$NODE_ID" > /etc/pterodactyl/config.yml chmod 600 /etc/pterodactyl/config.yml echo "* * * * * php8.3 $PANEL_DIR/artisan schedule:run >> /dev/null 2>&1" | crontab -u www-data - systemctl enable -q --now dogpanel-queue dogpanel-update.path systemctl enable -q wings && systemctl restart wings step "Done" motd "DogPanel is installed: $URL — login details: cat $CREDENTIALS" cat "$CREDENTIALS"