| 1 | #!/bin/bash |
| 2 | |
| 3 | set -e |
| 4 | |
| 5 | RED='\033[0;31m' |
| 6 | YELLOW='\033[1;33m' |
| 7 | GREEN='\033[0;32m' |
| 8 | LIGHT_BLUE='\033[1;34m' |
| 9 | NC='\033[0m' |
| 10 | |
| 11 | prompt() { |
| 12 | local PROMPT_MESSAGE=$1 |
| 13 | local DEFAULT_VALUE=$2 |
| 14 | read -p "$PROMPT_MESSAGE [$DEFAULT_VALUE]: " INPUT |
| 15 | echo "${INPUT:-$DEFAULT_VALUE}" |
| 16 | } |
| 17 | |
| 18 | confirm_clean_install() { |
| 19 | echo -e ${LIGHT_BLUE}"=================================================================${NC}" |
| 20 | echo -e ${LIGHT_BLUE}" Pterodactyl Wings Installer for Debian 12 by VS-Shop ${NC}" |
| 21 | echo -e ${LIGHT_BLUE}"=================================================================${NC}" |
| 22 | echo -e "${YELLOW}This installation script requires a clean installation of Debian 12 (Bookworm).${NC}" |
| 23 | echo -e "${YELLOW}Please confirm you are running it on a fresh system.${NC}" |
| 24 | echo -e ${LIGHT_BLUE}"=================================================================${NC}" |
| 25 | |
| 26 | while true; do |
| 27 | read -p "Is this a clean installation of Debian 12? (Y/N): " response |
| 28 | case $response in |
| 29 | [Yy]* ) break;; |
| 30 | [Nn]* ) echo -e "${RED}Please reinstall Debian 12 and run the script again.${NC}"; exit;; |
| 31 | * ) echo -e "${RED}Please answer with 'Y' (Yes) or 'N' (No).${NC}";; |
| 32 | esac |
| 33 | done |
| 34 | } |
| 35 | |
| 36 | confirm_clean_install |
| 37 | |
| 38 | WINGS_DOMAIN=$(prompt "Enter the domain name you want to use for Wings (e.g., wings.example.com). Leave blank if not using a public domain for Wings." "") |
| 39 | if [ -n "$WINGS_DOMAIN" ]; then |
| 40 | ADMIN_EMAIL=$(prompt "Enter an email address for Certbot to use for Wings (for urgent renewal notices and security advisories)" "me@anthony-morales.online") # Corrected default email |
| 41 | fi |
| 42 | |
| 43 | echo -e "${GREEN}Updating system and installing dependencies...${NC}" |
| 44 | apt update && apt upgrade -y |
| 45 | apt install -y curl sudo gnupg lsb-release ca-certificates |
| 46 | |
| 47 | echo -e "${GREEN}Installing Docker (from official source)...${NC}" |
| 48 | if ! command -v docker &> /dev/null; then |
| 49 | curl -fsSL https://get.docker.com | bash |
| 50 | else |
| 51 | echo -e "${YELLOW}Docker appears to be already installed. Skipping Docker installation.${NC}" |
| 52 | fi |
| 53 | |
| 54 | echo -e "${GREEN}Enabling Docker...${NC}" |
| 55 | systemctl enable --now docker |
| 56 | |
| 57 | echo -e "${GREEN}Installing Wings...${NC}" |
| 58 | mkdir -p /etc/pterodactyl |
| 59 | ARCH=$(uname -m) |
| 60 | ARCH_TYPE=$([[ "$ARCH" == "x86_64" ]] && echo "amd64" || echo "arm64") |
| 61 | |
| 62 | curl -L -o /usr/local/bin/wings "https://github.com/pterodactyl/wings/releases/latest/download/wings_linux_${ARCH_TYPE}" |
| 63 | chmod +x /usr/local/bin/wings |
| 64 | |
| 65 | echo -e "${GREEN}Creating systemd service file for Wings...${NC}" |
| 66 | cat > /etc/systemd/system/wings.service <<EOF |
| 67 | [Unit] |
| 68 | Description=Pterodactyl Wings Daemon |
| 69 | After=docker.service |
| 70 | Requires=docker.service |
| 71 | |
| 72 | [Service] |
| 73 | User=root |
| 74 | WorkingDirectory=/etc/pterodactyl |
| 75 | LimitNOFILE=4096 |
| 76 | ExecStart=/usr/local/bin/wings |
| 77 | Restart=on-failure |
| 78 | StartLimitInterval=180 |
| 79 | StartLimitBurst=30 |
| 80 | RestartSec=5s |
| 81 | |
| 82 | [Install] |
| 83 | WantedBy=multi-user.target |
| 84 | EOF |
| 85 | |
| 86 | echo -e "${GREEN}Enabling Wings service...${NC}" |
| 87 | systemctl enable --now wings |
| 88 | |
| 89 | if [ -n "$WINGS_DOMAIN" ]; then |
| 90 | echo -e "${GREEN}Installing Certbot...${NC}" |
| 91 | apt install -y certbot |
| 92 | |
| 93 | WEB_SERVICE="" |
| 94 | if systemctl is-active --quiet nginx; then |
| 95 | WEB_SERVICE="nginx" |
| 96 | elif systemctl is-active --quiet apache2; then |
| 97 | WEB_SERVICE="apache2" |
| 98 | fi |
| 99 | |
| 100 | if [ -n "$WEB_SERVICE" ]; then |
| 101 | echo -e "${YELLOW}Stopping $WEB_SERVICE temporarily to free up port 80 for Certbot...${NC}" |
| 102 | systemctl stop "$WEB_SERVICE" |
| 103 | else |
| 104 | echo -e "${YELLOW}No common web server (Nginx/Apache) found running on port 80. Proceeding with Certbot standalone.${NC}" |
| 105 | fi |
| 106 | |
| 107 | echo -e "${GREEN}Stopping Wings temporarily for Certbot standalone validation...${NC}" |
| 108 | systemctl stop wings || true |
| 109 | |
| 110 | echo -e "${GREEN}Obtaining SSL certificate for Wings domain using Certbot's standalone authenticator...${NC}" |
| 111 | certbot certonly --standalone --agree-tos --email "$ADMIN_EMAIL" -d "$WINGS_DOMAIN" --force-renewal |
| 112 | |
| 113 | CERTBOT_STATUS=$? |
| 114 | |
| 115 | if [ -n "$WEB_SERVICE" ]; then |
| 116 | echo -e "${YELLOW}Starting $WEB_SERVICE back up...${NC}" |
| 117 | systemctl start "$WEB_SERVICE" |
| 118 | fi |
| 119 | |
| 120 | echo -e "${GREEN}Restarting Wings service...${NC}" |
| 121 | systemctl start wings |
| 122 | |
| 123 | if [ $CERTBOT_STATUS -eq 0 ]; then |
| 124 | echo -e "${GREEN}SSL certificate for Wings domain obtained successfully!${NC}" |
| 125 | echo -e "${YELLOW}IMPORTANT: You must manually update your /etc/pterodactyl/config.yml to use these SSL certificates.${NC}" |
| 126 | echo -e "${YELLOW} Certificate Path: /etc/letsencrypt/live/$WINGS_DOMAIN/fullchain.pem${NC}" |
| 127 | echo -e "${YELLOW} Key Path: /etc/letsencrypt/live/$WINGS_DOMAIN/privkey.pem${NC}" |
| 128 | echo -e "${YELLOW} Ensure 'api.listen_address' is set to use HTTPS (e.g., 0.0.0.0:8443) in config.yml.${NC}" |
| 129 | echo -e "${YELLOW} After updating config.yml, restart Wings: systemctl restart wings${NC}" |
| 130 | else |
| 131 | echo -e "${RED}Failed to obtain SSL certificate for Wings domain (Certbot exit code: $CERTBOT_STATUS). Please check your DNS and ensure port 80 is open and not in use by any unexpected process.${NC}" |
| 132 | echo -e "${RED}Wings will proceed without a Let's Encrypt certificate for the domain. You will need to configure SSL manually later if desired.${NC}" |
| 133 | fi |
| 134 | else |
| 135 | echo -e "${YELLOW}No domain provided for Wings. Skipping Certbot installation for Wings.${NC}" |
| 136 | fi |
| 137 | |
| 138 | confirm_wings_configuration() { |
| 139 | echo -e ${LIGHT_BLUE}"=================================================================${NC}" |
| 140 | echo -e ${LIGHT_BLUE}" Pterodactyl Wings Configuration Reminder ${NC}" |
| 141 | echo -e ${LIGHT_BLUE}"=================================================================${NC}" |
| 142 | echo -e "${YELLOW}1. Open a new terminal and connect to this server.${NC}" |
| 143 | echo -e "${YELLOW}2. Log in to your Pterodactyl Panel and create a Location and a Node.${NC}" |
| 144 | echo -e "${YELLOW}3. Navigate to Nodes > Your Node > Configuration tab.${NC}" |
| 145 | echo -e "${YELLOW}4. Download or copy the config and paste it to: /etc/pterodactyl/config.yml${NC}" |
| 146 | if [ -n "$WINGS_DOMAIN" ]; then |
| 147 | echo -e "${YELLOW}5. IMPORTANT: Since you obtained a Let's Encrypt SSL certificate for Wings,${NC}" |
| 148 | echo -e "${YELLOW} you MUST edit the /etc/pterodactyl/config.yml file. Find the 'api' section${NC}" |
| 149 | echo -e "${YELLOW} and update 'certificate' and 'key' paths to point to the Let's Encrypt certificates:${NC}" |
| 150 | echo -e "${YELLOW} certificate: /etc/letsencrypt/live/$WINGS_DOMAIN/fullchain.pem${NC}" |
| 151 | echo -e "${YELLOW} key: /etc/letsencrypt/live/$WINGS_DOMAIN/privkey.pem${NC}" |
| 152 | echo -e "${YELLOW}6. Save the config.yml file. Then, run 'systemctl restart wings'.${NC}" |
| 153 | echo -e "${YELLOW}7. Come back to this window to continue.${NC}" |
| 154 | else |
| 155 | echo -e "${YELLOW}5. Save and come back to this window to continue.${NC}" |
| 156 | fi |
| 157 | echo -e ${LIGHT_BLUE}"=================================================================${NC}" |
| 158 | |
| 159 | while true; do |
| 160 | read -p "Have you completed the Node Configuration and any necessary SSL updates for Wings? (Y/N): " response |
| 161 | case $response in |
| 162 | [Yy]* ) break;; |
| 163 | [Nn]* ) echo -e "${RED}Please complete the Node Configuration and run the script again.${NC}"; exit;; |
| 164 | * ) echo -e "${RED}Please answer with 'Y' (Yes) or 'N' (No).${NC}";; |
| 165 | esac |
| 166 | done |
| 167 | } |
| 168 | |
| 169 | confirm_wings_configuration |
| 170 | |
| 171 | echo -e "${GREEN}Pterodactyl Wings Configuration completed successfully!${NC}" |
| 172 | echo -e "${GREEN}Pterodactyl Wings is now installed and running on Debian 12.${NC}" |