Last active
May 11, 2020 10:56
-
-
Save Sn1p0r/37da14697ba1bf5fd303379b84f3d1b5 to your computer and use it in GitHub Desktop.
Script to automate the installation of The Pterodactyl Daemon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## Installing Daemon "Wings" | |
echo "Installing Daemon "Wings"" | |
## Input environmental vars | |
echo "FQDN:" ; read "host" | |
echo "IP:" ; read "ip" | |
echo "Admin email:" ; read "email" | |
echo "#####################" | |
echo "FQDN hostname is $host" | |
echo "IP fort this FQDN is $ip" | |
echo "Admin email is $email" | |
echo "#####################" | |
## Set hostname and setup /etc/hosts accordingly | |
hostnamectl set-hostname $host | |
echo "127.0.0.1 localhost localhost.localdomain" > /etc/hosts | |
echo "${ip} ${host}" >> /etc/hosts | |
## Add SWAP 4G /swap | |
dd if=/dev/zero of=/swap count=4096 bs=1MiB | |
chmod 600 /swap | |
mkswap /swap | |
swapon /swap | |
echo "/swap swap swap sw 0 0" >> /etc/fstab | |
yum install -y tar unzip make gcc gcc-c++ python certbot firewalld | |
yum install -y yum-utils device-mapper-persistent-data lvm2 | |
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo | |
yum install -y docker-ce | |
systemctl enable docker | |
systemctl start docker | |
systemctl enable firewalld | |
systemctl restart firewalld | |
curl --silent --location https://rpm.nodesource.com/setup_10.x | bash - | |
yum install -y nodejs | |
## Port 80 temporarely for the letsencrypt acme | |
firewall-cmd --add-port 80/tcp | |
firewall-cmd --add-port 8080/tcp --permanent | |
firewall-cmd --add-port 2022/tcp --permanent | |
firewall-cmd --permanent --zone=trusted --change-interface=docker0 | |
firewall-cmd --reload | |
mkdir -p /srv/daemon /srv/daemon-data | |
cd /srv/daemon | |
curl -L https://github.com/pterodactyl/daemon/releases/download/v0.6.13/daemon.tar.gz | tar --strip-components=1 -xzv | |
npm install --only=production --no-audit --unsafe-perm | |
# echo ' | |
# ' > /srv/daemon/config/core.json | |
cat <<EOF > /etc/systemd/system/wings.service | |
[Unit] | |
Description=Pterodactyl Wings Daemon | |
After=docker.service | |
[Service] | |
User=root | |
#Group=some_group | |
WorkingDirectory=/srv/daemon | |
LimitNOFILE=4096 | |
PIDFile=/var/run/wings/daemon.pid | |
ExecStart=/usr/bin/node /srv/daemon/src/index.js | |
Restart=on-failure | |
StartLimitInterval=600 | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
## Secure with letsencrypt after stopping serving on port 80 | |
systemctl stop nginx ; systemctl stop apache ; systemctl stop httpd | |
certbot certonly --non-interactive --standalone --agree-tos --email "${email}" --domains "${host}" | |
systemctl enable --now wings | |
echo "###############################################################" | |
echo "# Don't forget to add /srv/daemon/config/core.json manually ! #" | |
echo "###############################################################" | |
echo "# Alternatively you can go to: ################################" | |
echo "# panel>nodes>(desirednode)>configuration> "Generate Token" ###" | |
echo "# to have it auto generated and connected for you !!! #########" | |
echo "###############################################################" | |
## Reboot | |
shutdown -r now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment