2020-06-25 05:31:54 -04:00
#!/bin/bash
output( ) {
echo -e '\e[36m' $1 '\e[0m' ;
}
warn( ) {
echo -e '\e[31m' $1 '\e[0m' ;
}
2021-11-02 01:05:08 -04:00
PANEL = latest
WINGS = latest
2020-11-15 01:35:12 -05:00
2020-06-25 05:31:54 -04:00
preflight( ) {
2020-07-15 18:26:34 -04:00
output "Pterodactyl Installation & Upgrade Script"
2021-10-14 02:57:19 -04:00
output "Copyright © 2021 Thien Tran <contact@tommytran.io>."
2021-09-25 22:59:44 -04:00
output "Please join my Matrix for community support: https://matrix.to/#/#tommytran732:matrix.org"
2020-06-25 05:31:54 -04:00
output ""
output "Please note that this script is meant to be installed on a fresh OS. Installing it on a non-fresh OS may cause problems."
2020-06-25 06:17:28 -04:00
output "Automatic operating system detection initialized..."
2020-06-25 05:31:54 -04:00
os_check
if [ " $EUID " -ne 0 ] ; then
output "Please run as root."
exit 3
fi
2020-06-25 06:17:28 -04:00
output "Automatic architecture detection initialized..."
2020-06-25 05:31:54 -04:00
MACHINE_TYPE = ` uname -m`
2021-08-13 08:41:44 -04:00
if [ " ${ MACHINE_TYPE } " = = 'x86_64' ] ; then
2020-06-25 05:31:54 -04:00
output "64-bit server detected! Good to go."
output ""
else
output "Unsupported architecture detected! Please switch to 64-bit (x86_64)."
exit 4
fi
2020-06-25 06:17:28 -04:00
output "Automatic virtualization detection initialized..."
2020-06-25 05:31:54 -04:00
if [ " $lsb_dist " = "ubuntu" ] ; then
apt-get update --fix-missing
apt-get -y install software-properties-common
add-apt-repository -y universe
apt-get -y install virt-what curl
elif [ " $lsb_dist " = "debian" ] ; then
apt update --fix-missing
2020-10-11 23:26:58 -04:00
apt-get -y install software-properties-common virt-what wget curl dnsutils
2021-11-01 22:46:20 -04:00
elif [ " $lsb_dist " = "fedora" ] || [ " $lsb_dist " = "centos" ] || [ " $lsb_dist " = "rhel" ] || [ " $lsb_dist " = "rocky" ] || [ " $lsb_dist " = "almalinux" ] ; then
2020-10-11 23:26:58 -04:00
yum -y install virt-what wget bind-utils
2020-06-25 05:31:54 -04:00
fi
virt_serv = $( echo $( virt-what) )
if [ " $virt_serv " = "" ] ; then
output "Virtualization: Bare Metal detected."
elif [ " $virt_serv " = "openvz lxc" ] ; then
output "Virtualization: OpenVZ 7 detected."
elif [ " $virt_serv " = "xen xen-hvm" ] ; then
output "Virtualization: Xen-HVM detected."
elif [ " $virt_serv " = "xen xen-hvm aws" ] ; then
output "Virtualization: Xen-HVM on AWS detected."
2020-06-25 06:17:28 -04:00
warn "When creating allocations for this node, please use the internal IP as Google Cloud uses NAT routing."
warn "Resuming in 10 seconds..."
2020-06-25 05:31:54 -04:00
sleep 10
else
output " Virtualization: $virt_serv detected. "
fi
output ""
if [ " $virt_serv " != "" ] && [ " $virt_serv " != "kvm" ] && [ " $virt_serv " != "vmware" ] && [ " $virt_serv " != "hyperv" ] && [ " $virt_serv " != "openvz lxc" ] && [ " $virt_serv " != "xen xen-hvm" ] && [ " $virt_serv " != "xen xen-hvm aws" ] ; then
2020-06-25 06:17:28 -04:00
warn "Unsupported type of virtualization detected. Please consult with your hosting provider whether your server can run Docker or not. Proceed at your own risk."
2020-06-25 05:31:54 -04:00
warn "No support would be given if your server breaks at any point in the future."
warn "Proceed?\n[1] Yes.\n[2] No."
read choice
case $choice in
1) output "Proceeding..."
; ;
2) output "Cancelling installation..."
exit 5
; ;
esac
output ""
fi
2020-06-25 10:33:12 -04:00
output "Kernel detection initialized..."
2020-06-25 05:31:54 -04:00
if echo $( uname -r) | grep -q xxxx; then
2020-06-25 10:33:12 -04:00
output "OVH kernel detected. This script will not work. Please reinstall your server using a generic/distribution kernel."
2020-06-25 05:31:54 -04:00
output "When you are reinstalling your server, click on 'custom installation' and click on 'use distribution' kernel after that."
2020-06-25 10:33:12 -04:00
output "You might also want to do custom partitioning, remove the /home partition and give / all the remaining space."
2020-06-25 05:31:54 -04:00
output "Please do not hesitate to contact us if you need help regarding this issue."
exit 6
elif echo $( uname -r) | grep -q pve; then
2020-06-25 06:17:28 -04:00
output "Proxmox LXE kernel detected. You have chosen to continue in the last step, therefore we are proceeding at your own risk."
2020-06-25 05:31:54 -04:00
output "Proceeding with a risky operation..."
elif echo $( uname -r) | grep -q stab; then
if echo $( uname -r) | grep -q 2.6; then
output "OpenVZ 6 detected. This server will definitely not work with Docker, regardless of what your provider might say. Exiting to avoid further damages."
exit 6
fi
elif echo $( uname -r) | grep -q gcp; then
2020-06-25 06:17:28 -04:00
output "Google Cloud Platform detected."
warn "Please make sure you have a static IP setup, otherwise the system will not work after a reboot."
warn " Please also make sure the GCP firewall allows the ports needed for the server to function normally. "
warn "When creating allocations for this node, please use the internal IP as Google Cloud uses NAT routing."
warn "Resuming in 10 seconds..."
2020-06-25 05:31:54 -04:00
sleep 10
else
2020-06-25 06:17:28 -04:00
output "Did not detect any bad kernel. Moving forward..."
2020-06-25 05:31:54 -04:00
output ""
fi
}
os_check( ) {
if [ -r /etc/os-release ] ; then
lsb_dist = " $( . /etc/os-release && echo " $ID " ) "
dist_version = " $( . /etc/os-release && echo " $VERSION_ID " ) "
2021-11-02 03:09:59 -04:00
if [ " $lsb_dist " = "rhel" ] || [ " $lsb_dist " = "rocky" ] || [ " $lsb_dist " = "almalinux" ] ; then
2020-06-25 05:31:54 -04:00
dist_version = " $( echo $dist_version | awk -F. '{print $1}' ) "
fi
else
exit 1
fi
if [ " $lsb_dist " = "ubuntu" ] ; then
2021-09-25 23:48:39 -04:00
if [ " $dist_version " != "20.04" ] ; then
output "Unsupported Ubuntu version. Only Ubuntu 20.04 is supported."
2020-06-25 05:31:54 -04:00
exit 2
fi
elif [ " $lsb_dist " = "debian" ] ; then
2021-11-01 22:26:30 -04:00
if [ " $dist_version " != "11" ] ; then
2020-12-08 15:14:27 -05:00
output "Unsupported Debian version. Only Debian 10 is supported."
2020-06-25 05:31:54 -04:00
exit 2
fi
elif [ " $lsb_dist " = "fedora" ] ; then
2021-11-01 22:26:30 -04:00
if [ " $dist_version " != "35" ] ; then
2021-09-25 23:48:39 -04:00
output "Unsupported Fedora version. Only Fedora 34 is supported."
2020-06-25 05:31:54 -04:00
exit 2
fi
elif [ " $lsb_dist " = "centos" ] ; then
2020-12-08 15:58:55 -05:00
if [ " $dist_version " != "8" ] ; then
2021-09-25 23:48:39 -04:00
output "Unsupported CentOS version. Only CentOS Stream 8 is supported."
2020-06-25 05:31:54 -04:00
exit 2
fi
elif [ " $lsb_dist " = "rhel" ] ; then
if [ $dist_version != "8" ] ; then
output "Unsupported RHEL version. Only RHEL 8 is supported."
exit 2
fi
2021-10-23 03:23:57 -04:00
elif [ " $lsb_dist " = "rocky" ] ; then
if [ " $dist_version " != "8" ] ; then
2021-11-01 22:46:20 -04:00
output "Unsupported Rocky Linux version. Only Rocky Linux 8 is supported."
2021-10-23 03:23:57 -04:00
exit 2
fi
2021-11-01 22:46:20 -04:00
elif [ " $lsb_dist " = "almalinux" ] ; then
if [ " $dist_version " != "8" ] ; then
output "Unsupported AlmaLinux version. Only AlmaLinux 8 is supported."
exit 2
fi
elif [ " $lsb_dist " != "ubuntu" ] && [ " $lsb_dist " != "debian" ] && [ " $lsb_dist " != "fedora" ] && [ " $lsb_dist " != "centos" ] && [ " $lsb_dist " != "rhel" ] && [ " $lsb_dist " != "rocky" ] && [ " $lsb_dist " != "almalinux" ] ; then
2020-06-25 06:17:28 -04:00
output "Unsupported operating system."
2020-06-25 05:31:54 -04:00
output ""
output "Supported OS:"
2021-09-25 23:48:39 -04:00
output "Ubuntu: 20.04"
2021-11-01 22:26:30 -04:00
output "Debian: 11"
output "Fedora: 35"
2021-09-25 23:48:39 -04:00
output "CentOS Stream: 8"
2021-10-12 20:12:01 -04:00
output "Rocky Linux: 8"
2021-11-01 22:46:20 -04:00
output "AlmaLinux: 8"
2020-06-25 05:31:54 -04:00
output "RHEL: 8"
exit 2
fi
}
install_options( ) {
output "Please select your installation option:"
2020-11-15 01:35:12 -05:00
output " [1] Install the panel ${ PANEL } . "
2021-09-25 23:20:55 -04:00
output " [2] Install the wings ${ WINGS } . "
output " [3] Install the panel ${ PANEL } and wings ${ WINGS } . "
2021-10-23 03:19:48 -04:00
output " [4] Upgrade panel to ${ PANEL } . "
2021-11-02 02:45:09 -04:00
output " [5] Upgrade wings to ${ WINGS } . "
2021-10-23 03:19:48 -04:00
output " [6] Upgrade panel to ${ PANEL } and daemon to ${ DAEMON } . "
2021-11-02 03:11:30 -04:00
output "[7] Install phpMyAdmin (only use this after you have installed the panel)."
2021-10-23 03:19:48 -04:00
output "[8] Emergency MariaDB root password reset."
output "[9] Emergency database host information reset."
2021-08-13 08:41:44 -04:00
read -r choice
2020-06-25 05:31:54 -04:00
case $choice in
1 ) installoption = 1
2020-11-15 01:35:12 -05:00
output " You have selected ${ PANEL } panel installation only. "
2020-06-25 05:31:54 -04:00
; ;
2 ) installoption = 2
2020-11-17 14:56:38 -05:00
output " You have selected wings ${ WINGS } installation only. "
2020-06-25 05:31:54 -04:00
; ;
2021-09-25 23:20:55 -04:00
3 ) installoption = 3
2020-11-17 14:56:38 -05:00
output " You have selected ${ PANEL } panel and wings ${ WINGS } installation. "
2020-06-25 05:31:54 -04:00
; ;
2021-09-25 23:20:55 -04:00
4 ) installoption = 4
2020-11-15 01:35:12 -05:00
output " You have selected to upgrade the panel to ${ PANEL } . "
2020-06-25 05:31:54 -04:00
; ;
2021-10-23 03:19:48 -04:00
5 ) installoption = 5
output " You have selected to upgrade the daemon to ${ DAEMON } . "
2020-10-11 22:11:37 -04:00
; ;
2021-10-23 03:08:01 -04:00
6 ) installoption = 6
2021-10-23 03:19:48 -04:00
output " You have selected to upgrade panel to ${ PANEL } and daemon to ${ DAEMON } . "
2020-10-11 22:11:37 -04:00
; ;
2021-10-23 03:08:01 -04:00
7 ) installoption = 7
2021-11-02 03:12:11 -04:00
output "You have selected to install phpMyAdmin."
2020-10-13 00:37:35 -04:00
; ;
2021-10-23 03:08:01 -04:00
8 ) installoption = 8
2021-10-23 03:19:48 -04:00
output "You have selected MariaDB root password reset."
; ;
9 ) installoption = 9
2020-06-25 05:31:54 -04:00
output "You have selected Database Host information reset."
; ;
* ) output "You did not enter a valid selection."
install_options
esac
}
required_infos( ) {
output "Please enter the desired user email address:"
2021-08-13 08:41:44 -04:00
read -r email
2020-06-25 05:31:54 -04:00
dns_check
}
dns_check( ) {
2020-06-25 06:17:28 -04:00
output "Please enter your FQDN (panel.domain.tld):"
2021-08-13 08:41:44 -04:00
read -r FQDN
2020-12-08 14:11:43 -05:00
2020-06-25 10:33:12 -04:00
output "Resolving DNS..."
2021-09-18 13:41:12 -04:00
SERVER_IP = $( dig +short myip.opendns.com @resolver1.opendns.com -4)
2020-06-25 05:31:54 -04:00
DOMAIN_RECORD = $( dig +short ${ FQDN } )
if [ " ${ SERVER_IP } " != " ${ DOMAIN_RECORD } " ] ; then
output ""
output "The entered domain does not resolve to the primary public IP of this server."
2020-06-25 06:17:28 -04:00
output "Please make an A record pointing to your server's IP. For example, if you make an A record called 'panel' pointing to your server's IP, your FQDN is panel.domain.tld"
2020-06-25 06:27:15 -04:00
output "If you are using Cloudflare, please disable the orange cloud."
2020-06-25 06:17:28 -04:00
output "If you do not have a domain, you can get a free one at https://freenom.com"
2020-06-25 05:31:54 -04:00
dns_check
2020-12-08 14:11:43 -05:00
else
2020-06-25 06:17:28 -04:00
output "Domain resolved correctly. Good to go..."
2020-06-25 05:31:54 -04:00
fi
}
repositories_setup( ) {
2020-10-11 22:11:37 -04:00
output "Configuring your repositories..."
if [ " $lsb_dist " = "ubuntu" ] || [ " $lsb_dist " = "debian" ] ; then
apt-get -y install sudo
apt-get -y install software-properties-common curl apt-transport-https ca-certificates gnupg
dpkg --remove-architecture i386
echo 'Acquire::ForceIPv4 "true";' | sudo tee /etc/apt/apt.conf.d/99force-ipv4
apt-get -y update
2021-11-01 21:14:07 -04:00
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
2020-10-11 22:11:37 -04:00
if [ " $lsb_dist " = "ubuntu" ] ; then
LC_ALL = C.UTF-8 add-apt-repository -y ppa:ondrej/php
2021-11-01 20:25:04 -04:00
apt -y install tuned dnsutils
2021-09-25 23:20:55 -04:00
tuned-adm profile latency-performance
2020-06-25 05:31:54 -04:00
elif [ " $lsb_dist " = "debian" ] ; then
apt-get -y install ca-certificates apt-transport-https
echo " deb https://packages.sury.org/php/ $( lsb_release -sc) main " | sudo tee /etc/apt/sources.list.d/php.list
2021-09-25 23:48:39 -04:00
apt -y install dirmngr
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
apt -y install tuned
tuned-adm profile latency-performance
apt-get -y update
apt-get -y upgrade
apt-get -y autoremove
apt-get -y autoclean
apt-get -y install curl
2021-10-23 03:02:03 -04:00
fi
2021-11-02 02:47:51 -04:00
elif [ " $lsb_dist " = "fedora" ] || [ " $lsb_dist " = "centos" ] || [ " $lsb_dist " = "rhel" ] || [ " $lsb_dist " = "rocky" ] || [ " $lsb_dist " = "almalinux" ] ; then
2021-11-01 21:25:53 -04:00
dnf -y install dnf-utils
2020-06-25 05:31:54 -04:00
if [ " $lsb_dist " = "fedora" ] ; then
2021-11-01 22:46:20 -04:00
dnf -y install http://rpms.remirepo.net/fedora/remi-release-35.rpm
2021-11-01 21:25:53 -04:00
else
dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf -y install http://rpms.remirepo.net/enterprise/remi-release-8.rpm
2021-11-01 21:09:22 -04:00
fi
2021-11-01 21:25:53 -04:00
dnf config-manager --set-enabled remi
2021-11-02 17:19:31 -04:00
dnf -y install tuned dnf-automatic
2020-06-25 05:31:54 -04:00
tuned-adm profile latency-performance
2021-11-02 17:19:31 -04:00
sed -i 's/apply_updates = no/apply_updates = yes/g' /etc/dnf/automatic.conf
systemctl enable --now dnf-automatic.timer
2021-11-01 20:57:07 -04:00
dnf -y upgrade
dnf -y autoremove
dnf -y clean packages
dnf -y install curl bind-utils cronie
2020-06-25 05:31:54 -04:00
fi
}
install_dependencies( ) {
2020-10-11 22:11:37 -04:00
output "Installing dependencies..."
if [ " $lsb_dist " = "ubuntu" ] || [ " $lsb_dist " = "debian" ] ; then
2021-11-02 03:07:42 -04:00
apt -y install php8.0 php8.0-{ cli,gd,mysql,pdo,mbstring,tokenizer,bcmath,xml,fpm,curl,zip} nginx tar unzip git redis-server nginx git wget expect composer
2020-10-11 22:11:37 -04:00
sh -c "DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated mariadb-server"
else
2021-11-02 03:27:22 -04:00
dnf -y module install nginx:mainline/common
2021-11-01 21:44:09 -04:00
dnf -y module install php:remi-8.0/common
dnf -y module install redis:remi-6.2/common
2021-11-02 03:27:22 -04:00
dnf -y module install mariadb:10.5/server
2021-11-02 03:07:42 -04:00
dnf -y install git policycoreutils-python-utils unzip wget expect jq php-mysql php-zip php-bcmath tar composer
2020-10-11 22:11:37 -04:00
fi
output "Enabling Services..."
if [ " $lsb_dist " = "ubuntu" ] || [ " $lsb_dist " = "debian" ] ; then
2021-11-01 21:44:09 -04:00
systemctl enable --now redis-server
2021-10-23 03:31:34 -04:00
systemctl enable --now php8.0-fpm
2021-11-02 02:47:51 -04:00
elif [ " $lsb_dist " = "fedora" ] || [ " $lsb_dist " = "centos" ] || [ " $lsb_dist " = "rhel" ] || [ " $lsb_dist " = "rocky" ] || [ " $lsb_dist " = "almalinux" ] ; then
2021-10-12 20:12:01 -04:00
systemctl enable --now redis
systemctl enable --now php-fpm
2021-09-25 23:20:55 -04:00
fi
2021-10-12 20:12:01 -04:00
systemctl enable --now cron
2021-09-25 23:48:39 -04:00
systemctl enable --now mariadb
systemctl enable --now nginx
2020-10-11 22:11:37 -04:00
}
2021-09-25 23:20:55 -04:00
install_pterodactyl( ) {
2020-10-11 22:11:37 -04:00
output "Creating the databases and setting root password..."
password = ` cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`
adminpassword = ` cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`
rootpassword = ` cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`
Q0 = "DROP DATABASE IF EXISTS test;"
Q1 = "CREATE DATABASE IF NOT EXISTS panel;"
Q2 = "SET old_passwords=0;"
Q3 = " GRANT ALL ON panel.* TO 'pterodactyl'@'127.0.0.1' IDENTIFIED BY ' $password '; "
2021-11-02 18:17:57 -04:00
Q4 = " GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, INDEX, DROP, CREATE ROUTINE, ALTER ROUTINE, EXECUTE, PROCESS, RELOAD, LOCK TABLES, CREATE USER ON *.* TO 'admin'@' $SERVER_IP ' IDENTIFIED BY ' $adminpassword ' WITH GRANT OPTION; "
2020-10-11 22:11:37 -04:00
Q5 = " SET PASSWORD FOR 'root'@'localhost' = PASSWORD(' $rootpassword '); "
Q6 = "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');"
Q7 = "DELETE FROM mysql.user WHERE User='';"
Q8 = "DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%';"
Q9 = "FLUSH PRIVILEGES;"
SQL = " ${ Q0 } ${ Q1 } ${ Q2 } ${ Q3 } ${ Q4 } ${ Q5 } ${ Q6 } ${ Q7 } ${ Q8 } ${ Q9 } "
mysql -u root -e " $SQL "
2021-11-03 01:56:47 -04:00
output "Binding MariaDB/MySQL to 0.0.0.0"
2020-09-11 19:41:25 -04:00
if grep -Fqs "bind-address" /etc/mysql/mariadb.conf.d/50-server.cnf ; then
2020-09-11 19:23:17 -04:00
sed -i -- '/bind-address/s/#//g' /etc/mysql/mariadb.conf.d/50-server.cnf
2020-09-11 05:49:25 -04:00
sed -i -- '/bind-address/s/127.0.0.1/0.0.0.0/g' /etc/mysql/mariadb.conf.d/50-server.cnf
2021-11-03 01:56:47 -04:00
sed -i '/\[mysqld\]/a ssl-key=/etc/letsencrypt/live/' " ${ FQDN } " '/privkey.pem' /etc/mysql/mariadb.conf.d/50-server.cnf
sed -i '/\[mysqld\]/a ssl-ca=/etc/letsencrypt/live/' " ${ FQDN } " '/chain.pem' /etc/mysql/mariadb.conf.d/50-server.cnf
sed -i '/\[mysqld\]/a ssl-cert=/etc/letsencrypt/live/' " ${ FQDN } " '/cert.pem' /etc/mysql/mariadb.conf.d/50-server.cnf
output 'Restarting MariaDB process...'
2021-11-01 21:54:05 -04:00
service mariadb restart
2020-09-11 19:41:25 -04:00
elif grep -Fqs "bind-address" /etc/mysql/my.cnf ; then
2020-09-11 19:23:17 -04:00
sed -i -- '/bind-address/s/#//g' /etc/mysql/my.cnf
2020-09-11 06:04:03 -04:00
sed -i -- '/bind-address/s/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf
2021-11-03 01:56:47 -04:00
sed -i '/\[mysqld\]/a ssl-key=/etc/letsencrypt/live/' " ${ FQDN } " '/privkey.pem' /etc/mysql/my.cnf
sed -i '/\[mysqld\]/a ssl-ca=/etc/letsencrypt/live/' " ${ FQDN } " '/chain.pem' /etc/mysql/my.cnf
sed -i '/\[mysqld\]/a ssl-cert=/etc/letsencrypt/live/' " ${ FQDN } " '/cert.pem' /etc/mysql/my.cnf
output 'Restarting MariaDB process...'
2021-11-01 21:54:05 -04:00
service mariadb restart
2020-09-11 19:41:25 -04:00
elif grep -Fqs "bind-address" /etc/my.cnf ; then
2020-09-11 19:23:17 -04:00
sed -i -- '/bind-address/s/#//g' /etc/my.cnf
2020-09-11 06:04:03 -04:00
sed -i -- '/bind-address/s/127.0.0.1/0.0.0.0/g' /etc/my.cnf
2021-11-03 01:56:47 -04:00
sed -i '/\[mysqld\]/a ssl-key=/etc/letsencrypt/live/' " ${ FQDN } " '/privkey.pem' /etc/my.cnf
sed -i '/\[mysqld\]/a ssl-ca=/etc/letsencrypt/live/' " ${ FQDN } " '/chain.pem' /etc/my.cnf
sed -i '/\[mysqld\]/a ssl-cert=/etc/letsencrypt/live/' " ${ FQDN } " '/cert.pem' /etc/my.cnf
output 'Restarting MariaDB process...'
2021-11-01 21:54:05 -04:00
service mariadb restart
2020-09-11 19:41:25 -04:00
elif grep -Fqs "bind-address" /etc/mysql/my.conf.d/mysqld.cnf ; then
2020-09-11 19:23:17 -04:00
sed -i -- '/bind-address/s/#//g' /etc/mysql/my.conf.d/mysqld.cnf
2020-09-11 06:04:03 -04:00
sed -i -- '/bind-address/s/127.0.0.1/0.0.0.0/g' /etc/mysql/my.conf.d/mysqld.cnf
2021-11-03 01:56:47 -04:00
sed -i '/\[mysqld\]/a ssl-key=/etc/letsencrypt/live/' " ${ FQDN } " '/privkey.pem' /etc/mysql/my.conf.d/mysqld.cnf
sed -i '/\[mysqld\]/a ssl-ca=/etc/letsencrypt/live/' " ${ FQDN } " '/chain.pem' /etc/mysql/my.conf.d/mysqld.cnf
sed -i '/\[mysqld\]/a ssl-cert=/etc/letsencrypt/live/' " ${ FQDN } " '/cert.pem' /etc/mysql/my.conf.d/mysqld.cnf
output 'Restarting MariaDB process...'
2021-11-01 21:54:05 -04:00
service mariadb restart
elif grep -Fqs "bind-address" /etc/my.cnf.d/mariadb-server.cnf ; then
sed -i -- '/bind-address/s/#//g' /etc/my.cnf.d/mariadb-server.cnf
sed -i -- '/bind-address/s/127.0.0.1/0.0.0.0/g' /etc/my.cnf.d/mariadb-server.cnf
2021-11-03 01:56:47 -04:00
sed -i '/\[mysqld\]/a ssl-key=/etc/letsencrypt/live/' " ${ FQDN } " '/privkey.pem' /etc/my.cnf.d/mariadb-server.cnf
sed -i '/\[mysqld\]/a ssl-ca=/etc/letsencrypt/live/' " ${ FQDN } " '/chain.pem' /etc/my.cnf.d/mariadb-server.cnf
sed -i '/\[mysqld\]/a ssl-cert=/etc/letsencrypt/live/' " ${ FQDN } " '/cert.pem' /etc/my.cnf.d/mariadb-server.cnf
output 'Restarting MariaDB process...'
2021-11-01 21:54:05 -04:00
service mariadb restart
2020-12-08 14:11:43 -05:00
else
2021-11-01 21:54:05 -04:00
output 'A MariaDB configuration file could not be detected! Please contact support.'
2020-06-25 05:31:54 -04:00
fi
2020-12-08 14:11:43 -05:00
2020-06-25 10:33:12 -04:00
output "Downloading Pterodactyl..."
2020-06-25 05:31:54 -04:00
mkdir -p /var/www/pterodactyl
2021-08-13 08:41:44 -04:00
cd /var/www/pterodactyl || exit
2021-11-02 02:59:15 -04:00
if [ ${ PANEL } = "latest" ] ; then
2021-11-02 03:07:42 -04:00
curl -Lo panel.tar.gz https://github.com/pterodactyl/panel/releases/latest/download/panel.tar.gz
2021-11-02 02:59:15 -04:00
else
curl -Lo panel.tar.gz https://github.com/pterodactyl/panel/releases/download/${ PANEL } /panel.tar.gz
fi
2021-09-25 23:20:55 -04:00
tar -xzvf panel.tar.gz
2020-06-25 05:31:54 -04:00
chmod -R 755 storage/* bootstrap/cache/
2020-06-25 06:17:28 -04:00
output "Installing Pterodactyl..."
2021-11-01 21:57:54 -04:00
2020-06-25 05:31:54 -04:00
cp .env.example .env
2021-11-02 03:07:42 -04:00
composer update --no-interaction
composer install --no-dev --optimize-autoloader --no-interaction
2021-11-01 23:07:21 -04:00
2020-06-25 05:31:54 -04:00
php artisan key:generate --force
php artisan p:environment:setup -n --author= $email --url= https://$FQDN --timezone= America/New_York --cache= redis --session= database --queue= redis --redis-host= 127.0.0.1 --redis-pass= --redis-port= 6379
php artisan p:environment:database --host= 127.0.0.1 --port= 3306 --database= panel --username= pterodactyl --password= $password
output "To use PHP's internal mail sending, select [mail]. To use a custom SMTP server, select [smtp]. TLS Encryption is recommended."
php artisan p:environment:mail
php artisan migrate --seed --force
php artisan p:user:make --email= $email --admin= 1
if [ " $lsb_dist " = "ubuntu" ] || [ " $lsb_dist " = "debian" ] ; then
chown -R www-data:www-data * /var/www/pterodactyl
2021-11-02 02:47:51 -04:00
elif [ " $lsb_dist " = "fedora" ] || [ " $lsb_dist " = "centos" ] || [ " $lsb_dist " = "rhel" ] || [ " $lsb_dist " = "rocky" ] || [ " $lsb_dist " = "almalinux" ] ; then
2021-09-25 23:48:39 -04:00
chown -R nginx:nginx * /var/www/pterodactyl
2021-11-01 23:20:17 -04:00
semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/pterodactyl/storage(/.*)?"
2020-06-25 05:31:54 -04:00
restorecon -R /var/www/pterodactyl
fi
2020-06-25 06:17:28 -04:00
output "Creating panel queue listeners..."
2020-06-25 05:31:54 -04:00
( crontab -l ; echo "* * * * * php /var/www/pterodactyl/artisan schedule:run >> /dev/null 2>&1" ) | crontab -
if [ " $lsb_dist " = "ubuntu" ] || [ " $lsb_dist " = "debian" ] ; then
cat > /etc/systemd/system/pteroq.service <<- 'EOF'
2021-11-01 23:22:30 -04:00
# Pterodactyl Queue Worker File
# ----------------------------------
2020-06-25 05:31:54 -04:00
[ Unit]
Description = Pterodactyl Queue Worker
After = redis-server.service
2021-11-01 23:22:30 -04:00
2020-06-25 05:31:54 -04:00
[ Service]
2021-11-01 23:22:30 -04:00
# On some systems the user and group might be different.
# Some systems use `apache` or `nginx` as the user and group.
2020-06-25 05:31:54 -04:00
User = www-data
Group = www-data
Restart = always
ExecStart = /usr/bin/php /var/www/pterodactyl/artisan queue:work --queue= high,standard,low --sleep= 3 --tries= 3
2021-11-01 23:22:30 -04:00
StartLimitInterval = 180
StartLimitBurst = 30
RestartSec = 5s
2020-06-25 05:31:54 -04:00
[ Install]
WantedBy = multi-user.target
EOF
2021-11-02 02:47:51 -04:00
elif [ " $lsb_dist " = "fedora" ] || [ " $lsb_dist " = "centos" ] || [ " $lsb_dist " = "rhel" ] || [ " $lsb_dist " = "rocky" ] || [ " $lsb_dist " = "almalinux" ] ; then
2021-09-25 23:48:39 -04:00
cat > /etc/systemd/system/pteroq.service <<- 'EOF'
2021-11-01 23:22:30 -04:00
# Pterodactyl Queue Worker File
# ----------------------------------
[ Unit]
2020-06-25 05:31:54 -04:00
Description = Pterodactyl Queue Worker
After = redis-server.service
2021-11-01 23:22:30 -04:00
2020-06-25 05:31:54 -04:00
[ Service]
2021-11-01 23:22:30 -04:00
# On some systems the user and group might be different.
# Some systems use `apache` or `nginx` as the user and group.
2020-06-25 05:31:54 -04:00
User = nginx
Group = nginx
Restart = always
ExecStart = /usr/bin/php /var/www/pterodactyl/artisan queue:work --queue= high,standard,low --sleep= 3 --tries= 3
2021-11-01 23:22:30 -04:00
StartLimitInterval = 180
StartLimitBurst = 30
RestartSec = 5s
2020-06-25 05:31:54 -04:00
[ Install]
WantedBy = multi-user.target
EOF
setsebool -P httpd_can_network_connect 1
2021-11-01 20:14:59 -04:00
setsebool -P httpd_execmem 1
setsebool -P httpd_unified 1
2020-06-25 05:31:54 -04:00
fi
sudo systemctl daemon-reload
2021-10-12 20:12:01 -04:00
systemctl enable --now pteroq.service
2020-06-25 05:31:54 -04:00
}
upgrade_pterodactyl( ) {
2021-11-02 01:46:51 -04:00
cd /var/www/pterodactyl && php artisan p:upgrade
2020-10-11 22:11:37 -04:00
if [ " $lsb_dist " = "ubuntu" ] || [ " $lsb_dist " = "debian" ] ; then
chown -R www-data:www-data * /var/www/pterodactyl
2021-11-02 02:47:51 -04:00
elif [ " $lsb_dist " = "fedora" ] || [ " $lsb_dist " = "centos" ] || [ " $lsb_dist " = "rhel" ] || [ " $lsb_dist " = "rocky" ] || [ " $lsb_dist " = "almalinux" ] ; then
2020-10-11 22:11:37 -04:00
chown -R nginx:nginx * /var/www/pterodactyl
restorecon -R /var/www/pterodactyl
fi
2020-12-07 13:02:09 -05:00
output " Your panel has successfully been updated to version ${ PANEL } "
2020-10-13 00:37:35 -04:00
}
2020-06-25 05:31:54 -04:00
nginx_config( ) {
2020-06-25 06:17:28 -04:00
output "Disabling default configuration..."
2020-06-25 05:31:54 -04:00
rm -rf /etc/nginx/sites-enabled/default
2020-06-25 06:17:28 -04:00
output "Configuring Nginx Webserver..."
2020-12-08 14:11:43 -05:00
2020-10-12 02:16:08 -04:00
echo '
2020-10-15 11:04:38 -04:00
server {
listen 80 default_server;
2021-11-01 23:44:39 -04:00
listen [ ::] :80 default_server;
2020-10-15 11:04:38 -04:00
server_name '"$FQDN"' ;
return 301 https://$server_name $request_uri ;
}
2020-10-12 02:16:08 -04:00
server {
2020-10-15 11:04:38 -04:00
listen 443 ssl http2 default_server;
2021-11-01 23:44:39 -04:00
listen [ ::] :443 ssl http2 default_server;
2020-10-12 02:16:08 -04:00
server_name '"$FQDN"' ;
2021-11-02 00:36:39 -04:00
2020-10-12 02:16:08 -04:00
root /var/www/pterodactyl/public;
2020-10-15 11:04:38 -04:00
index index.php;
2021-11-02 00:36:39 -04:00
2020-10-15 11:04:38 -04:00
access_log /var/log/nginx/pterodactyl.app-access.log;
2020-10-12 02:16:08 -04:00
error_log /var/log/nginx/pterodactyl.app-error.log error;
2021-11-02 00:36:39 -04:00
2020-10-12 02:16:08 -04:00
# allow larger file uploads and longer script runtimes
client_max_body_size 100m;
client_body_timeout 120s;
2021-11-02 00:36:39 -04:00
2020-10-12 02:16:08 -04:00
sendfile off;
2021-11-02 00:36:39 -04:00
2020-10-15 11:04:38 -04:00
# SSL Configuration
2020-10-15 11:52:59 -04:00
ssl_certificate /etc/letsencrypt/live/'"$FQDN"' /fullchain.pem;
2020-10-15 11:04:38 -04:00
ssl_certificate_key /etc/letsencrypt/live/'"$FQDN"' /privkey.pem;
ssl_session_cache shared:SSL:10m;
2021-11-02 00:36:39 -04:00
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384" ;
2020-10-15 11:04:38 -04:00
ssl_prefer_server_ciphers on;
2021-11-02 00:36:39 -04:00
2021-11-02 03:52:24 -04:00
add_header Strict-Transport-Security "max-age=15768000; preload;" ;
2020-10-15 11:04:38 -04:00
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block" ;
add_header X-Robots-Tag none;
add_header Content-Security-Policy "frame-ancestors 'self'" ;
add_header X-Frame-Options DENY;
add_header Referrer-Policy same-origin;
location / {
try_files $uri $uri / /index.php?$query_string ;
}
2020-10-12 02:16:08 -04:00
location ~ \. php$ {
fastcgi_split_path_info ^( .+\. php) ( /.+) $;
2021-11-02 00:36:39 -04:00
fastcgi_pass unix:/run/php/php8.0-fpm.sock;
2020-10-12 02:16:08 -04:00
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param PHP_VALUE "upload_max_filesize = 100M \n post_max_size=100M" ;
fastcgi_param SCRIPT_FILENAME $document_root $fastcgi_script_name ;
fastcgi_param HTTP_PROXY "" ;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
2020-10-15 11:04:38 -04:00
include /etc/nginx/fastcgi_params;
2020-10-12 02:16:08 -04:00
}
2021-11-02 00:36:39 -04:00
2020-10-12 02:16:08 -04:00
location ~ /\. ht {
deny all;
}
2020-10-15 11:04:38 -04:00
}
2020-10-12 02:16:08 -04:00
' | sudo -E tee /etc/nginx/sites-available/pterodactyl.conf >/dev/null 2>& 1
ln -s /etc/nginx/sites-available/pterodactyl.conf /etc/nginx/sites-enabled/pterodactyl.conf
service nginx restart
}
2020-06-25 05:31:54 -04:00
nginx_config_redhat( ) {
2020-06-25 06:17:28 -04:00
output "Configuring Nginx web server..."
2020-12-08 14:11:43 -05:00
2020-06-25 05:31:54 -04:00
echo '
server {
listen 80 default_server;
2021-11-01 23:44:39 -04:00
listen [ ::] :80 default_server;
2020-06-25 05:31:54 -04:00
server_name '"$FQDN"' ;
return 301 https://$server_name $request_uri ;
}
server {
listen 443 ssl http2 default_server;
2021-11-01 23:44:39 -04:00
listen [ ::] :443 ssl http2 default_server;
2020-06-25 05:31:54 -04:00
server_name '"$FQDN"' ;
root /var/www/pterodactyl/public;
index index.php;
2021-11-02 00:45:32 -04:00
2020-06-25 05:31:54 -04:00
access_log /var/log/nginx/pterodactyl.app-access.log;
error_log /var/log/nginx/pterodactyl.app-error.log error;
2021-11-02 00:45:32 -04:00
2020-06-25 05:31:54 -04:00
# allow larger file uploads and longer script runtimes
client_max_body_size 100m;
client_body_timeout 120s;
2021-11-02 00:45:32 -04:00
2020-06-25 05:31:54 -04:00
sendfile off;
ssl_certificate /etc/letsencrypt/live/'"$FQDN"' /fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/'"$FQDN"' /privkey.pem;
ssl_session_cache shared:SSL:10m;
2021-11-02 00:45:32 -04:00
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384" ;
ssl_prefer_server_ciphers on;
2021-11-02 03:52:24 -04:00
add_header Strict-Transport-Security "max-age=15768000; preload;" ;
2020-06-25 05:31:54 -04:00
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block" ;
add_header X-Robots-Tag none;
add_header Content-Security-Policy "frame-ancestors 'self'" ;
2021-11-02 00:45:32 -04:00
add_header X-Frame-Options DENY;
add_header Referrer-Policy same-origin;
2020-06-25 05:31:54 -04:00
location / {
try_files $uri $uri / /index.php?$query_string ;
}
2021-11-02 00:45:32 -04:00
2020-06-25 05:31:54 -04:00
location ~ \. php$ {
fastcgi_split_path_info ^( .+\. php) ( /.+) $;
fastcgi_pass unix:/var/run/php-fpm/pterodactyl.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param PHP_VALUE "upload_max_filesize = 100M \n post_max_size=100M" ;
fastcgi_param SCRIPT_FILENAME $document_root $fastcgi_script_name ;
fastcgi_param HTTP_PROXY "" ;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
include /etc/nginx/fastcgi_params;
}
2021-11-02 00:45:32 -04:00
2020-06-25 05:31:54 -04:00
location ~ /\. ht {
deny all;
}
}
' | sudo -E tee /etc/nginx/conf.d/pterodactyl.conf >/dev/null 2>& 1
service nginx restart
chown -R nginx:nginx $( pwd )
restorecon -R /var/www/pterodactyl
}
php_config( ) {
2020-06-25 06:17:28 -04:00
output "Configuring PHP socket..."
2020-06-25 05:31:54 -04:00
bash -c 'cat > /etc/php-fpm.d/www-pterodactyl.conf' <<-'EOF'
[ pterodactyl]
2021-11-01 23:46:59 -04:00
2020-06-25 05:31:54 -04:00
user = nginx
group = nginx
2021-11-01 23:46:59 -04:00
2020-06-25 05:31:54 -04:00
listen = /var/run/php-fpm/pterodactyl.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0750
2021-11-01 23:46:59 -04:00
2020-06-25 05:31:54 -04:00
pm = ondemand
pm.max_children = 9
pm.process_idle_timeout = 10s
pm.max_requests = 200
EOF
systemctl restart php-fpm
}
webserver_config( ) {
2020-10-12 02:16:08 -04:00
if [ " $lsb_dist " = "debian" ] || [ " $lsb_dist " = "ubuntu" ] ; then
2021-09-25 23:48:39 -04:00
nginx_config
2021-11-02 02:47:51 -04:00
elif [ " $lsb_dist " = "fedora" ] || [ " $lsb_dist " = "centos" ] || [ " $lsb_dist " = "rhel" ] || [ " $lsb_dist " = "rocky" ] || [ " $lsb_dist " = "almalinux" ] ; then
2021-09-25 23:48:39 -04:00
php_config
nginx_config_redhat
2021-11-01 22:46:20 -04:00
chown -R nginx:nginx /var/lib/php/session
2020-06-25 05:31:54 -04:00
fi
}
setup_pterodactyl( ) {
install_dependencies
install_pterodactyl
2020-10-15 11:04:38 -04:00
ssl_certs
2020-06-25 05:31:54 -04:00
webserver_config
2020-10-11 22:11:37 -04:00
}
install_wings( ) {
2021-08-13 08:41:44 -04:00
cd /root || exit
2020-10-11 22:11:37 -04:00
output "Installing Pterodactyl Wings dependencies..."
if [ " $lsb_dist " = "ubuntu" ] || [ " $lsb_dist " = "debian" ] ; then
apt-get -y install curl tar unzip
2021-11-02 02:47:51 -04:00
elif [ " $lsb_dist " = "fedora" ] || [ " $lsb_dist " = "centos" ] || [ " $lsb_dist " = "rhel" ] || [ " $lsb_dist " = "rocky" ] || [ " $lsb_dist " = "almalinux" ] ; then
2021-11-01 22:46:20 -04:00
dnf -y install curl tar unzip
2020-10-11 22:11:37 -04:00
fi
2020-12-08 16:01:52 -05:00
output "Installing Docker"
2021-11-02 02:47:51 -04:00
if [ " $lsb_dist " = "centos" ] || [ " $lsb_dist " = "rhel" ] || [ " $lsb_dist " = "rocky" ] || [ " $lsb_dist " = "almalinux" ] ; then
2021-11-02 01:39:38 -04:00
dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
2021-11-02 03:33:23 -04:00
dnf -y install docker-ce --allowerasing
2021-09-26 00:13:00 -04:00
else
curl -sSL https://get.docker.com/ | CHANNEL = stable bash
fi
2021-11-02 01:39:38 -04:00
systemctl enable --now docker
2020-10-11 23:26:58 -04:00
output "Installing the Pterodactyl wings..."
2021-11-02 01:08:17 -04:00
mkdir -p /etc/pterodactyl
2021-08-13 08:41:44 -04:00
cd /etc/pterodactyl || exit
2021-11-02 02:59:15 -04:00
if [ ${ WINGS } = "latest" ] ; then
curl -L -o /usr/local/bin/wings https://github.com/pterodactyl/wings/releases/latest/download/wings_linux_amd64
else
curl -L -o /usr/local/bin/wings https://github.com/pterodactyl/wings/releases/download/${ WINGS } /wings_linux_amd64
fi
2020-10-11 22:11:37 -04:00
chmod u+x /usr/local/bin/wings
2021-11-02 01:44:28 -04:00
bash -c 'cat > /etc/systemd/system/wings.service' <<-'EOF'
2020-10-11 22:11:37 -04:00
[ Unit]
Description = Pterodactyl Wings Daemon
After = docker.service
2021-11-02 01:10:58 -04:00
Requires = docker.service
PartOf = docker.service
2020-10-11 22:11:37 -04:00
[ Service]
User = root
WorkingDirectory = /etc/pterodactyl
LimitNOFILE = 4096
PIDFile = /var/run/wings/daemon.pid
ExecStart = /usr/local/bin/wings
Restart = on-failure
2021-11-02 01:10:58 -04:00
StartLimitInterval = 180
StartLimitBurst = 30
RestartSec = 5s
2020-10-11 22:11:37 -04:00
[ Install]
WantedBy = multi-user.target
EOF
2021-11-02 01:44:28 -04:00
2021-11-02 01:24:53 -04:00
systemctl enable wings
2020-12-07 13:04:29 -05:00
output " Wings ${ WINGS } has now been installed on your system. "
2021-11-02 01:24:53 -04:00
output "You should go to your panel and configure the node now."
2021-11-02 01:30:58 -04:00
output "Do `systemctl start wings` after you have run the auto deployment command."
2021-11-02 02:47:51 -04:00
if [ " $lsb_dist " != "fedora" ] || [ " $lsb_dist " = "centos" ] || [ " $lsb_dist " = "rhel" ] || [ " $lsb_dist " = "rocky" ] || [ " $lsb_dist " = "almalinux" ] ; then
2021-11-02 01:24:53 -04:00
output "------------------------------------------------------------------"
output "IMPORTANT NOTICE!!!"
output "Since you are on a system with targetted SELinux policies, you should be changing the Daemon Server File Directory from /var/lib/pterodactyl/volumes to /var/srv/containers/pterodactyl."
output "------------------------------------------------------------------"
fi
2020-10-11 22:11:37 -04:00
}
2020-06-25 05:31:54 -04:00
2021-09-26 00:06:17 -04:00
upgrade_wings( ) {
2021-11-02 02:59:15 -04:00
if [ ${ WINGS } = "latest" ] ; then
curl -L -o /usr/local/bin/wings https://github.com/pterodactyl/wings/releases/latest/download/wings_linux_amd64
else
curl -L -o /usr/local/bin/wings https://github.com/pterodactyl/wings/releases/download/${ WINGS } /wings_linux_amd64
fi
2021-09-26 00:06:17 -04:00
chmod u+x /usr/local/bin/wings
systemctl restart wings
output " Your wings have been updated to version ${ WINGS } . "
2020-06-25 05:31:54 -04:00
}
install_phpmyadmin( ) {
2020-06-25 06:17:28 -04:00
output "Installing phpMyAdmin..."
2021-11-02 02:47:51 -04:00
if [ " $lsb_dist " = "fedora" ] || [ " $lsb_dist " = "centos" ] || [ " $lsb_dist " = "rhel" ] || [ " $lsb_dist " = "rocky" ] || [ " $lsb_dist " = "almalinux" ] ; then
2021-11-02 02:03:07 -04:00
dnf -y install phpmyadmin
2021-11-02 03:11:30 -04:00
ln -s /usr/share/phpMyAdmin /var/www/pterodactyl/public/phpmyadmin
2021-11-02 02:03:07 -04:00
else
2021-11-02 03:11:30 -04:00
apt -y install phpmyadmin
ln -s /usr/share/phpmyadmin /var/www/pterodactyl/public/phpmyadmin
2021-11-02 02:03:07 -04:00
fi
2021-08-13 08:41:44 -04:00
cd /var/www/pterodactyl/public/phpmyadmin || exit
2021-11-02 02:04:20 -04:00
SERVER_IP = $( dig +short myip.opendns.com @resolver1.opendns.com -4)
2020-06-25 05:31:54 -04:00
BOWFISH = ` cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 34 | head -n 1`
2021-11-02 05:34:53 -04:00
if [ " $lsb_dist " = "fedora" ] || [ " $lsb_dist " = "centos" ] || [ " $lsb_dist " = "rhel" ] || [ " $lsb_dist " = "rocky" ] || [ " $lsb_dist " = "almalinux" ] ; then
bash -c 'cat > /etc/phpMyAdmin/config.inc.php' <<EOF
2020-06-25 05:31:54 -04:00
<?php
/* Servers configuration */
\$ i = 0;
/* Server: MariaDB [ 1] */
\$ i++;
\$ cfg[ 'Servers' ] [ \$ i] [ 'verbose' ] = 'MariaDB' ;
\$ cfg[ 'Servers' ] [ \$ i] [ 'host' ] = '${SERVER_IP}' ;
2021-11-03 02:02:48 -04:00
\$ cfg[ 'Servers' ] [ \$ i] [ 'port' ] = '3306' ;
2020-06-25 05:31:54 -04:00
\$ cfg[ 'Servers' ] [ \$ i] [ 'socket' ] = '' ;
\$ cfg[ 'Servers' ] [ \$ i] [ 'auth_type' ] = 'cookie' ;
\$ cfg[ 'Servers' ] [ \$ i] [ 'user' ] = 'root' ;
\$ cfg[ 'Servers' ] [ \$ i] [ 'password' ] = '' ;
2021-11-03 01:56:47 -04:00
\$ cfg[ 'Servers' ] [ $i ] [ 'ssl' ] = true;
\$ cfg[ 'ForceSSL' ] = true;
2020-06-25 05:31:54 -04:00
/* End of servers configuration */
\$ cfg[ 'blowfish_secret' ] = '${BOWFISH}' ;
\$ cfg[ 'DefaultLang' ] = 'en' ;
\$ cfg[ 'ServerDefault' ] = 1;
2021-11-02 05:34:53 -04:00
\$ cfg[ 'UploadDir' ] = '/var/lib/phpMyAdmin/upload' ;
\$ cfg[ 'SaveDir' ] = '/var/lib/phpMyAdmin/save' ;
2020-06-25 05:31:54 -04:00
\$ cfg[ 'CaptchaLoginPublicKey' ] = '6LcJcjwUAAAAAO_Xqjrtj9wWufUpYRnK6BW8lnfn' ;
2021-11-03 03:32:19 -04:00
\$ cfg[ 'CaptchaLoginPrivateKey' ] = '6LcJcjwUAAAAALOcDJqAEYKTDhwELCkzUkNDQ0J5' ;
\$ cfg[ 'AuthLog' ] = syslog
2020-06-25 05:31:54 -04:00
?>
EOF
2021-11-02 17:58:02 -04:00
chmod 755 /etc/phpMyAdmin
chmod 644 /etc/phpMyAdmin/config.inc.php
2021-11-02 05:36:15 -04:00
chown -R nginx:nginx /var/www/pterodactyl
2021-11-02 17:58:02 -04:00
chown -R nginx:nginx /var/lib/phpMyAdmin/temp
2021-11-02 05:34:53 -04:00
if [ " $lsb_dist " = "ubuntu" ] || [ " $lsb_dist " = "debian" ] ; then
bash -c 'cat > /etc/phpmyadmin/config.inc.php' <<EOF
<?php
/* Servers configuration */
\$ i = 0;
/* Server: MariaDB [ 1] */
\$ i++;
\$ cfg[ 'Servers' ] [ \$ i] [ 'verbose' ] = 'MariaDB' ;
\$ cfg[ 'Servers' ] [ \$ i] [ 'host' ] = '${SERVER_IP}' ;
2021-11-03 01:56:47 -04:00
\$ cfg[ 'Servers' ] [ \$ i] [ 'port' ] = '3306' ;
2021-11-02 05:34:53 -04:00
\$ cfg[ 'Servers' ] [ \$ i] [ 'socket' ] = '' ;
\$ cfg[ 'Servers' ] [ \$ i] [ 'auth_type' ] = 'cookie' ;
\$ cfg[ 'Servers' ] [ \$ i] [ 'user' ] = 'root' ;
\$ cfg[ 'Servers' ] [ \$ i] [ 'password' ] = '' ;
2021-11-03 01:56:47 -04:00
\$ cfg[ 'Servers' ] [ $i ] [ 'ssl' ] = true;
\$ cfg[ 'ForceSSL' ] = true;
2021-11-02 05:34:53 -04:00
/* End of servers configuration */
\$ cfg[ 'blowfish_secret' ] = '${BOWFISH}' ;
\$ cfg[ 'DefaultLang' ] = 'en' ;
\$ cfg[ 'ServerDefault' ] = 1;
\$ cfg[ 'UploadDir' ] = '/var/lib/phpmyadmin/upload' ;
\$ cfg[ 'SaveDir' ] = '/var/lib/phpmyadmin/save' ;
\$ cfg[ 'CaptchaLoginPublicKey' ] = '6LcJcjwUAAAAAO_Xqjrtj9wWufUpYRnK6BW8lnfn' ;
2021-11-03 03:32:19 -04:00
\$ cfg[ 'CaptchaLoginPrivateKey' ] = '6LcJcjwUAAAAALOcDJqAEYKTDhwELCkzUkNDQ0J5' ;
\$ cfg[ 'AuthLog' ] = syslog
2021-11-02 05:34:53 -04:00
?>
EOF
2021-11-02 17:58:02 -04:00
chmod 755 /etc/phpmyadmin
chmod 644 /etc/phpmyadmin/config.inc.php
chown -R www-data:www-data /var/www/pterodactyl
chown -R www-data:www-data /var/lib/phpmyadmin/temp
2020-06-25 05:31:54 -04:00
fi
2021-11-03 03:32:19 -04:00
bash -c 'cat > /etc/fail2ban/jail.local' <<-'EOF'
[ DEFAULT]
# Ban hosts for ten hours:
bantime = 36000
# Override /etc/fail2ban/jail.d/00-firewalld.conf:
banaction = iptables-multiport
[ sshd]
enabled = true
[ phpmyadmin-syslog]
enable = true
maxentry = 15
EOF
service fail2ban restart
2020-06-25 05:31:54 -04:00
}
ssl_certs( ) {
2020-06-25 06:17:28 -04:00
output "Installing Let's Encrypt and creating an SSL certificate..."
2021-08-13 08:41:44 -04:00
cd /root || exit
2020-06-25 05:31:54 -04:00
if [ " $lsb_dist " = "ubuntu" ] || [ " $lsb_dist " = "debian" ] ; then
2020-07-07 11:09:01 -04:00
apt-get -y install certbot
2021-11-02 02:47:51 -04:00
elif [ " $lsb_dist " = "fedora" ] || [ " $lsb_dist " = "centos" ] || [ " $lsb_dist " = "rhel" ] || [ " $lsb_dist " = "rocky" ] || [ " $lsb_dist " = "almalinux" ] ; then
2021-10-23 03:31:34 -04:00
dnf -y install certbot
2020-06-25 05:31:54 -04:00
fi
2021-11-01 23:37:48 -04:00
if [ " $installoption " = "1" ] || [ " $installoption " = "3" ] ; then
2021-11-01 23:40:10 -04:00
if [ " $lsb_dist " = "ubuntu" ] || [ " $lsb_dist " = "debian" ] ; then
apt-get -y install python3-certbot-nginx
2021-11-02 02:47:51 -04:00
elif [ " $lsb_dist " = "fedora" ] || [ " $lsb_dist " = "centos" ] || [ " $lsb_dist " = "rhel" ] || [ " $lsb_dist " = "rocky" ] || [ " $lsb_dist " = "almalinux" ] ; then
2021-11-01 23:40:10 -04:00
dnf -y install python3-certbot-nginx
fi
2021-11-02 04:46:40 -04:00
certbot --nginx --redirect --no-eff-email --email " $email " --agree-tos -d " $FQDN "
2021-11-03 01:56:47 -04:00
setfacl -Rdm u:mysql:rx /etc/letsencrypt
setfacl -Rm u:mysql:rx /etc/letsencrypt
systemctl restart mariadb
2021-11-01 23:37:48 -04:00
fi
2020-07-07 11:09:01 -04:00
2020-06-25 05:31:54 -04:00
if [ " $installoption " = "2" ] ; then
2021-11-01 23:37:48 -04:00
certbot certonly --standalone --no-eff-email --email " $email " --agree-tos -d " $FQDN " --non-interactive
2020-06-25 05:31:54 -04:00
fi
}
firewall( ) {
2020-06-25 10:33:12 -04:00
output "Setting up Fail2Ban..."
2020-06-25 05:31:54 -04:00
if [ " $lsb_dist " = "ubuntu" ] || [ " $lsb_dist " = "debian" ] ; then
apt -y install fail2ban
2021-11-02 02:47:51 -04:00
elif [ " $lsb_dist " = "fedora" ] || [ " $lsb_dist " = "centos" ] || [ " $lsb_dist " = "rhel" ] || [ " $lsb_dist " = "rocky" ] || [ " $lsb_dist " = "almalinux" ] ; then
2021-11-01 22:46:20 -04:00
dnf -y install fail2ban
2020-06-25 05:31:54 -04:00
fi
systemctl enable fail2ban
bash -c 'cat > /etc/fail2ban/jail.local' <<-'EOF'
[ DEFAULT]
# Ban hosts for ten hours:
bantime = 36000
# Override /etc/fail2ban/jail.d/00-firewalld.conf:
banaction = iptables-multiport
[ sshd]
enabled = true
2021-11-03 03:32:19 -04:00
2020-06-25 05:31:54 -04:00
EOF
service fail2ban restart
2020-06-25 06:17:28 -04:00
output "Configuring your firewall..."
2020-06-25 05:31:54 -04:00
if [ " $lsb_dist " = "ubuntu" ] || [ " $lsb_dist " = "debian" ] ; then
apt-get -y install ufw
ufw allow 22
if [ " $installoption " = "1" ] ; then
ufw allow 80
ufw allow 443
ufw allow 3306
elif [ " $installoption " = "2" ] ; then
2020-10-15 10:41:34 -04:00
ufw allow 80
ufw allow 8080
ufw allow 2022
2021-09-25 23:53:24 -04:00
elif [ " $installoption " = "3" ] ; then
2020-06-25 05:31:54 -04:00
ufw allow 80
ufw allow 443
ufw allow 8080
ufw allow 2022
ufw allow 3306
fi
2021-09-25 23:53:24 -04:00
yes | ufw enable
2021-11-02 02:47:51 -04:00
elif [ " $lsb_dist " = "fedora" ] || [ " $lsb_dist " = "centos" ] || [ " $lsb_dist " = "rhel" ] || [ " $lsb_dist " = "rocky" ] || [ " $lsb_dist " = "almalinux" ] ; then
2021-11-01 22:46:20 -04:00
dnf -y install firewalld
2020-06-25 05:31:54 -04:00
systemctl enable firewalld
systemctl start firewalld
if [ " $installoption " = "1" ] ; then
firewall-cmd --add-service= http --permanent
firewall-cmd --add-service= https --permanent
2020-10-15 10:41:34 -04:00
firewall-cmd --add-service= mysql --permanent
2020-06-25 05:31:54 -04:00
elif [ " $installoption " = "2" ] ; then
2020-10-15 10:41:34 -04:00
firewall-cmd --permanent --add-service= 80/tcp
firewall-cmd --permanent --add-port= 2022/tcp
firewall-cmd --permanent --add-port= 8080/tcp
2021-11-02 00:39:37 -04:00
firewall-cmd --permanent --zone= trusted --change-interface= pterodactyl0
firewall-cmd --zone= trusted --add-masquerade --permanent
2021-09-25 23:53:24 -04:00
elif [ " $installoption " = "3" ] ; then
2020-06-25 05:31:54 -04:00
firewall-cmd --add-service= http --permanent
firewall-cmd --add-service= https --permanent
firewall-cmd --permanent --add-port= 2022/tcp
firewall-cmd --permanent --add-port= 8080/tcp
2020-10-15 10:41:34 -04:00
firewall-cmd --permanent --add-service= mysql
2021-11-02 00:39:37 -04:00
firewall-cmd --permanent --zone= trusted --change-interface= pterodactyl0
firewall-cmd --zone= trusted --add-masquerade --permanent
2020-06-25 05:31:54 -04:00
fi
fi
}
database_host_reset( ) {
2021-11-02 01:48:00 -04:00
SERVER_IP = $( dig +short myip.opendns.com @resolver1.opendns.com -4)
2020-06-25 05:31:54 -04:00
adminpassword = ` cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`
Q0 = "SET old_passwords=0;"
Q1 = " SET PASSWORD FOR 'admin'@' $SERVER_IP ' = PASSWORD(' $adminpassword '); "
Q2 = "FLUSH PRIVILEGES;"
SQL = " ${ Q0 } ${ Q1 } ${ Q2 } "
mysql mysql -e " $SQL "
output "New database host information:"
output " Host: $SERVER_IP "
output "Port: 3306"
output "User: admin"
output " Password: $adminpassword "
}
broadcast( ) {
if [ " $installoption " = "1" ] || [ " $installoption " = "3" ] ; then
broadcast_database
fi
2021-11-02 01:24:53 -04:00
output "------------------------------------------------------------------"
2020-06-25 05:31:54 -04:00
output "FIREWALL INFORMATION"
output ""
output "All unnecessary ports are blocked by default."
if [ " $lsb_dist " = "ubuntu" ] || [ " $lsb_dist " = "debian" ] ; then
2020-06-25 10:33:12 -04:00
output "Use 'ufw allow <port>' to enable your desired ports."
2021-11-02 02:47:51 -04:00
elif [ " $lsb_dist " = "fedora" ] || [ " $lsb_dist " = "centos" ] || [ " $lsb_dist " = "rhel" ] || [ " $lsb_dist " = "rocky" ] || [ " $lsb_dist " = "almalinux" ] ; then
2020-06-25 05:31:54 -04:00
output "Use 'firewall-cmd --permanent --add-port=<port>/tcp' to enable your desired ports."
fi
2021-11-02 01:24:53 -04:00
output "------------------------------------------------------------------"
2020-06-25 05:31:54 -04:00
output ""
}
broadcast_database( ) {
2021-11-02 01:24:53 -04:00
output "------------------------------------------------------------------"
2021-09-26 00:32:45 -04:00
output "MARIADB/MySQL INFORMATION"
output ""
output " Your MariaDB/MySQL root password is $rootpassword "
output ""
output "Create your MariaDB/MySQL host with the following information:"
output " Host: $SERVER_IP "
output "Port: 3306"
output "User: admin"
output " Password: $adminpassword "
2021-11-02 01:24:53 -04:00
output "------------------------------------------------------------------"
2021-09-26 00:32:45 -04:00
output ""
2020-06-25 05:31:54 -04:00
}
#Execution
preflight
install_options
case $installoption in
2021-10-23 03:31:34 -04:00
1) repositories_setup
required_infos
firewall
setup_pterodactyl
broadcast
2021-11-01 20:09:16 -04:00
broadcast_database
2021-10-23 03:31:34 -04:00
; ;
2) repositories_setup
required_infos
firewall
ssl_certs
install_wings
broadcast
2021-11-01 20:09:16 -04:00
broadcast_database
2021-10-23 03:31:34 -04:00
; ;
3) repositories_setup
required_infos
firewall
setup_pterodactyl
install_wings
broadcast
; ;
4) upgrade_pterodactyl
; ;
5) upgrade_wings
; ;
2021-11-01 20:09:16 -04:00
6) upgrade_pterodactyl
upgrade_wings
; ;
2021-10-23 03:31:34 -04:00
7) install_phpmyadmin
; ;
8) curl -sSL https://raw.githubusercontent.com/tommytran732/MariaDB-Root-Password-Reset/master/mariadb-104.sh | sudo bash
; ;
9) database_host_reset
; ;
2020-12-31 06:34:36 -05:00
esac