This commit is contained in:
Sebastian Cabrera 2026-02-26 17:11:44 -05:00
parent cd3fba634e
commit 2d36f66087
Signed by: okseby
GPG key ID: 37783FE2501AE402
2 changed files with 74 additions and 42 deletions

View file

@ -40,7 +40,7 @@ If you choose to enable SSL:
``` ```
- Automatically modifies: - Automatically modifies:
`/etc/calagopus/config.yml` `/etc/pterodactyl/config.yml`
From: From:
@ -63,7 +63,7 @@ To:
A backup of the config is created as: A backup of the config is created as:
``` ```
/etc/calagopus/config.yml.bak /etc/pterodactyl/config.yml.bak
``` ```
--- ---

View file

@ -1,17 +1,28 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
########################################
# Seby's Calagopus Wings Installer # Seby's Calagopus Wings Installer
# Safe for curl | bash usage # curl | bash safe
########################################
######################################## ########################################
# helpers # Styling
######################################## ########################################
TTY="/dev/tty" TTY="/dev/tty"
say() { printf "\n\033[1m%s\033[0m\n" "$*"; } BOLD="\033[1m"
warn() { printf "\n\033[33m[warn]\033[0m %s\n" "$*"; } DIM="\033[2m"
err() { printf "\n\033[31m[error]\033[0m %s\n" "$*"; } GREEN="\033[32m"
YELLOW="\033[33m"
RED="\033[31m"
BLUE="\033[34m"
RESET="\033[0m"
section() { printf "\n${BLUE}${BOLD}==> %s${RESET}\n" "$*"; }
say() { printf "${GREEN}✔ %s${RESET}\n" "$*"; }
warn() { printf "${YELLOW}⚠ %s${RESET}\n" "$*"; }
err() { printf "${RED}✖ %s${RESET}\n" "$*"; }
have() { command -v "$1" >/dev/null 2>&1; } have() { command -v "$1" >/dev/null 2>&1; }
@ -25,7 +36,7 @@ need_tty() {
prompt() { prompt() {
local msg="$1" local msg="$1"
local out local out
printf "%s" "$msg" >"$TTY" printf "${BOLD}%s${RESET}" "$msg" >"$TTY"
IFS= read -r out <"$TTY" IFS= read -r out <"$TTY"
printf "%s" "$out" printf "%s" "$out"
} }
@ -51,12 +62,12 @@ require_root_or_sudo() {
} }
apt_install() { apt_install() {
$SUDO apt-get update -y $SUDO apt-get update -y >/dev/null 2>&1
$SUDO apt-get install -y "$@" $SUDO apt-get install -y "$@" >/dev/null 2>&1
} }
######################################## ########################################
# SSL config updater (runs AFTER config exists) # SSL config updater
######################################## ########################################
update_ssl_config() { update_ssl_config() {
local domain="$1" local domain="$1"
@ -65,25 +76,23 @@ update_ssl_config() {
local key="/etc/letsencrypt/live/${domain}/privkey.pem" local key="/etc/letsencrypt/live/${domain}/privkey.pem"
if [[ ! -f "$cfg" ]]; then if [[ ! -f "$cfg" ]]; then
warn "Config not found at $cfg — skipping SSL update." warn "Config not found — skipping SSL update."
return return
fi fi
if [[ ! -f "$cert" || ! -f "$key" ]]; then if [[ ! -f "$cert" || ! -f "$key" ]]; then
warn "Cert files not found ($cert / $key) — skipping SSL update." warn "Cert files not found — skipping SSL update."
return return
fi fi
say "Updating SSL section in $cfg" section "Updating SSL configuration"
$SUDO cp -a "$cfg" "${cfg}.bak" $SUDO cp -a "$cfg" "${cfg}.bak"
# Rewrites only the ssl: block keys (expects standard indentation)
$SUDO awk -v cert="$cert" -v key="$key" ' $SUDO awk -v cert="$cert" -v key="$key" '
BEGIN { inssl=0 } BEGIN { inssl=0 }
{ {
if ($0 ~ /^ ssl:[[:space:]]*$/) { inssl=1; print; next } if ($0 ~ /^ ssl:[[:space:]]*$/) { inssl=1; print; next }
if (inssl==1) { if (inssl==1) {
# leave ssl block when we hit the next top-level section (two spaces + non-space)
if ($0 ~ /^ [^[:space:]]/ && $0 !~ /^ ssl:/) { inssl=0 } if ($0 ~ /^ [^[:space:]]/ && $0 !~ /^ ssl:/) { inssl=0 }
else if ($0 ~ /^ enabled:/) { print " enabled: true"; next } else if ($0 ~ /^ enabled:/) { print " enabled: true"; next }
else if ($0 ~ /^ cert:/) { print " cert: " cert; next } else if ($0 ~ /^ cert:/) { print " cert: " cert; next }
@ -93,12 +102,26 @@ update_ssl_config() {
} }
' "$cfg" | $SUDO tee "$cfg" >/dev/null ' "$cfg" | $SUDO tee "$cfg" >/dev/null
say "SSL config updated. Backup saved to ${cfg}.bak" say "SSL block updated (backup saved)"
} }
######################################## ########################################
# Start # Header
######################################## ########################################
clear
cat << "EOF"
____ _
/ ___|__ _| | __ _ __ _ ___ _ __ _ _ ___
| | / _` | |/ _` |/ _` |/ _ \| '_ \| | | / __|
| |__| (_| | | (_| | (_| | (_) | |_) | |_| \__ \
\____\__,_|_|\__,_|\__, |\___/| .__/ \__,_|___/
|___/ |_|
Calagopus Wings Installer | v1.0
EOF
need_tty need_tty
require_root_or_sudo require_root_or_sudo
@ -107,19 +130,26 @@ if ! have apt-get; then
exit 1 exit 1
fi fi
say "Calagopus Wings Installer"
######################################## ########################################
# Docker # Docker
######################################## ########################################
section "Docker Check"
if have docker; then if have docker; then
say "Docker detected: $(docker --version || true)" say "Docker detected: $(docker --version || true)"
else else
warn "Docker not installed." warn "Docker not installed."
if confirm_default_no "Install Docker?"; then if confirm_default_no "Install Docker?"; then
section "Installing Docker (quiet mode)"
apt_install ca-certificates curl apt_install ca-certificates curl
curl -fsSL https://get.docker.com/ | CHANNEL=stable $SUDO bash
say "Docker installed: $(docker --version || true)" if curl -fsSL https://get.docker.com/ | CHANNEL=stable $SUDO bash >/dev/null 2>&1; then
say "Docker installed successfully"
say "$(docker --version)"
else
err "Docker installation failed"
exit 1
fi
else else
err "Docker required. Exiting." err "Docker required. Exiting."
exit 1 exit 1
@ -129,7 +159,7 @@ fi
######################################## ########################################
# Download Wings # Download Wings
######################################## ########################################
say "Downloading Wings binary..." section "Downloading Wings"
ARCH="$(uname -m)" ARCH="$(uname -m)"
case "$ARCH" in case "$ARCH" in
@ -144,43 +174,42 @@ esac
WINGS_URL="https://github.com/calagopus/wings/releases/latest/download/wings-rs-${WINGS_ARCH}-linux" WINGS_URL="https://github.com/calagopus/wings/releases/latest/download/wings-rs-${WINGS_ARCH}-linux"
WINGS_BIN="/usr/local/bin/wings" WINGS_BIN="/usr/local/bin/wings"
$SUDO curl -fL "$WINGS_URL" -o "$WINGS_BIN" $SUDO curl -fL "$WINGS_URL" -o "$WINGS_BIN" >/dev/null 2>&1
$SUDO chmod +x "$WINGS_BIN" $SUDO chmod +x "$WINGS_BIN"
say "Wings installed to $WINGS_BIN" say "Wings installed"
"$WINGS_BIN" version || true "$WINGS_BIN" version || true
######################################## ########################################
# Configure (creates /etc/pterodactyl/config.yml) # Configure
######################################## ########################################
CONFIG_CREATED=false CONFIG_CREATED=false
section "Configuration"
if confirm_default_no "Run wings configure --join-data now? (recommended)"; then if confirm_default_no "Run wings configure --join-data now?"; then
JOIN_DATA="$(prompt "Paste join-data string: ")" JOIN_DATA="$(prompt "Paste join-data string: ")"
if [[ -n "$JOIN_DATA" ]]; then if [[ -n "$JOIN_DATA" ]]; then
$SUDO mkdir -p /etc/pterodactyl $SUDO mkdir -p /etc/pterodactyl
$SUDO "$WINGS_BIN" configure --join-data "$JOIN_DATA" $SUDO "$WINGS_BIN" configure --join-data "$JOIN_DATA"
CONFIG_CREATED=true CONFIG_CREATED=true
say "Configuration complete"
else else
warn "No join-data provided; skipping configure." warn "No join-data provided"
fi fi
else
warn "Skipping configure. SSL setup will be skipped because config.yml will not exist yet."
fi fi
######################################## ########################################
# SSL (after config exists) # SSL
######################################## ########################################
if $CONFIG_CREATED && confirm_default_no "Set up SSL with certbot now?"; then if $CONFIG_CREATED && confirm_default_no "Set up SSL with certbot?"; then
DOMAIN="$(prompt "Enter domain (e.g. node.example.com): ")" section "SSL Setup"
EMAIL="$(prompt "Enter email for Let's Encrypt renewal notices: ")"
DOMAIN="$(prompt "Enter domain: ")"
EMAIL="$(prompt "Enter email: ")"
if [[ -n "$DOMAIN" && -n "$EMAIL" ]]; then if [[ -n "$DOMAIN" && -n "$EMAIL" ]]; then
say "Installing certbot..."
apt_install certbot apt_install certbot
warn "Ports 80/443 must be open and not in use for standalone mode."
$SUDO certbot certonly \ $SUDO certbot certonly \
--standalone \ --standalone \
-d "$DOMAIN" \ -d "$DOMAIN" \
@ -191,17 +220,20 @@ if $CONFIG_CREATED && confirm_default_no "Set up SSL with certbot now?"; then
update_ssl_config "$DOMAIN" update_ssl_config "$DOMAIN"
else else
warn "Domain/email missing. Skipping SSL." warn "Domain/email missing — skipping SSL"
fi fi
fi fi
######################################## ########################################
# Install Service # Service
######################################## ########################################
if confirm_default_no "Install as systemd service? (wings service-install)"; then section "Service Installation"
if confirm_default_no "Install as systemd service?"; then
$SUDO "$WINGS_BIN" service-install $SUDO "$WINGS_BIN" service-install
say "Service status:" say "Service installed"
$SUDO systemctl --no-pager status wings || true $SUDO systemctl --no-pager status wings || true
fi fi
say "Installation complete." section "Done"
say "Calagopus Wings installation complete."