From aa8939623b4e1440ec5a87e642bd518c413cde09 Mon Sep 17 00:00:00 2001 From: HeyJack Date: Mon, 12 Oct 2020 03:11:37 +0100 Subject: [PATCH 01/18] lets just say a lot of lines --- install.sh | 633 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 546 insertions(+), 87 deletions(-) diff --git a/install.sh b/install.sh index 3a275f2..d15a712 100644 --- a/install.sh +++ b/install.sh @@ -156,66 +156,90 @@ os_check(){ install_options(){ output "Please select your installation option:" - output "[1] Install the panel." - output "[2] Install the daemon." - output "[3] Install the panel and daemon." - output "[4] Install the standalone SFTP server." - output "[5] Upgrade 0.7.x panel to 0.7.19." - output "[6] Upgrade 0.6.x daemon to 0.6.13." - output "[7] Upgrade the panel to 0.7.19 and daemon to 0.6.13" - output "[8] Upgrade the standalone SFTP server to 1.0.5." - output "[9] Make Pterodactyl compatible with the mobile app (only use this after you have installed the panel - check out https://pterodactyl.cloud for more information)." - output "[10] Update mobile compatibility." - output "[11] Install or update to phpMyAdmin 5.0.2 (only use this after you have installed the panel)." - output "[12] Install a standalone database host (only for use on daemon-only installations)." - output "[13] Change Pterodactyl theme." - output "[14] Emergency MariaDB root password reset." - output "[15] Emergency database host information reset." + output "[1] Install the panel (1.0)." + output "[2] Install the panel (0.7.19)." + output "[3] Install the wings." + output "[4] Install the daemon." + output "[5] Install the (1.0) panel and daemon." + output "[6] Install the (0.7.19) panel and daemon." + output "[7] Install the standalone SFTP server." + output "[8] Upgrade (0.7.x) panel to (1.0)." + output "[9] Upgrade (0.7.x) panel to (0.7.19)." + output "[10] Upgrade (0.6.x) daemon to (0.6.13)." + output "[11] Migrating daemon to wings." + output "[12] Upgrade the panel to 1.0 and Migrate to wings" + output "[13] Upgrade the panel to 0.7.19 and daemon to (0.6.13)" + output "[14] Upgrade the standalone SFTP server to (1.0.5)." + output "[15] Make Pterodactyl compatible with the mobile app (only use this after you have installed the panel - check out https://pterodactyl.cloud for more information)." + output "[16] Update mobile compatibility." + output "[17] Install or update to phpMyAdmin (5.0.2) (only use this after you have installed the panel)." + output "[18] Install a standalone database host (only for use on daemon-only installations)." + output "[19] Change Pterodactyl theme (0.7.19 Only)." + output "[20] Emergency MariaDB root password reset." + output "[21] Emergency database host information reset." read choice case $choice in 1 ) installoption=1 - output "You have selected panel installation only." + output "You have selected 1.0 panel installation only." ;; 2 ) installoption=2 - output "You have selected daemon installation only." + output "You have selected 0.7.19 panel installation only." ;; 3 ) installoption=3 - output "You have selected panel and daemon installation." + output "You have selected wings installation only." ;; 4 ) installoption=4 - output "You have selected to install the standalone SFTP server." + output "You have selected daemon installation only." ;; 5 ) installoption=5 - output "You have selected to upgrade the panel." + output "You have selected 1.0 panel and daemon installation." ;; 6 ) installoption=6 - output "You have selected to upgrade the daemon." + output "You have selected 0.7.19 panel and daemon installation." ;; 7 ) installoption=7 - output "You have selected to upgrade both the panel and daemon." + output "You have selected to install the standalone SFTP server." ;; 8 ) installoption=8 - output "You have selected to upgrade the standalone SFTP." + output "You have selected to upgrade the panel to 1.0." ;; 9 ) installoption=9 - output "You have activated mobile app compatibility." + output "You have selected to upgrade the panel to 0.7.19." ;; 10 ) installoption=10 - output "You have selected to update the mobile app compatibility." + output "You have selected to upgrade the daemon to 0.6.13." ;; 11 ) installoption=11 - output "You have selected to install or update phpMyAdmin." + output "You have selected to migrate daemon to wings." ;; 12 ) installoption=12 - output "You have selected to install a Database host." + output "You have selected to upgrade both the panel to 1.0 and migrating to wings." ;; 13 ) installoption=13 - output "You have selected to change Pterodactyl's theme." + output "You have selected to upgrade both the panel to 0.7.19 and daemon to 0.6.13." ;; 14 ) installoption=14 - output "You have selected MariaDB root password reset." + output "You have selected to upgrade the standalone SFTP." ;; 15 ) installoption=15 + output "You have activated mobile app compatibility." + ;; + 16 ) installoption=16 + output "You have selected to update the mobile app compatibility." + ;; + 17 ) installoption=17 + output "You have selected to install or update phpMyAdmin." + ;; + 18 ) installoption=18 + output "You have selected to install a Database host." + ;; + 19 ) installoption=19 + output "You have selected to change Pterodactyl's 0.7.19 only." + ;; + 20 ) installoption=20 + output "You have selected MariaDB root password reset." + ;; + 21 ) installoption=21 output "You have selected Database Host information reset." ;; * ) output "You did not enter a valid selection." @@ -287,15 +311,15 @@ theme_options() { 8 ) themeoption=8 output "You have selected to install Fonix's BlackEnd Space theme." output "" - ;; + ;; 9 ) themeoption=9 output "You have selected to install Fonix's Nothing But Graphite theme." output "" - ;; + ;; * ) output "You did not enter a valid selection." theme_options esac -} +} required_infos() { output "Please enter the desired user email address:" @@ -349,6 +373,109 @@ theme() { } repositories_setup(){ + 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 + curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash + if [ "$lsb_dist" = "ubuntu" ]; then + LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php + add-apt-repository -y ppa:chris-lea/redis-server + if [ "$dist_version" != "20.04" ]; then + add-apt-repository -y ppa:certbot/certbot + add-apt-repository -y ppa:nginx/development + fi + apt -y install tuned dnsutils + tuned-adm profile latency-performance + 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 + if [ "$dist_version" = "10" ]; then + 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 + elif [ "$dist_version" = "9" ]; then + 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' + fi + fi + apt-get -y update + apt-get -y upgrade + apt-get -y autoremove + apt-get -y autoclean + apt-get -y install curl + elif [ "$lsb_dist" = "fedora" ] || [ "$lsb_dist" = "centos" ]; then + if [ "$lsb_dist" = "fedora" ] ; then + if [ "$dist_version" = "32" ]; then + dnf -y install http://rpms.remirepo.net/fedora/remi-release-32.rpm + elif [ "$dist_version" = "31" ]; then + dnf -y install http://rpms.remirepo.net/fedora/remi-release-31.rpm + fi + dnf -y install dnf-plugins-core python2 libsemanage-devel + dnf config-manager --set-enabled remi + dnf -y module enable php:remi-7.4 + dnf -y module enable nginx:mainline/common + dnf -y module enable mariadb:14/server + elif [ "$lsb_dist" = "centos" ] && [ "$dist_version" = "8" ]; then + dnf -y install epel-release boost-program-options + dnf -y install http://rpms.remirepo.net/enterprise/remi-release-8.rpm + dnf config-manager --set-enabled remi + dnf -y module enable php:remi-7.4 + dnf -y module enable nginx:mainline/common + curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash + dnf config-manager --set-enabled mariadb + elif [ "$lsb_dist" = "centos" ] && [ "$dist_version" = "7" ]; then + + bash -c 'cat > /etc/yum.repos.d/nginx.repo' <<-'EOF' +[nginx-mainline] +name=nginx mainline repo +baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/ +gpgcheck=1 +enabled=0 +gpgkey=https://nginx.org/keys/nginx_signing.key +module_hotfixes=true +EOF + bash -c 'cat > /etc/yum.repos.d/mariadb.repo' <<-'EOF' +[mariadb] +name = MariaDB +baseurl = http://yum.mariadb.org/10.5/centos7-amd64 +gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB +gpgcheck=1 +EOF + + yum -y install epel-release + yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm + yum -y install policycoreutils-python yum-utils libsemanage-devel + yum-config-manager --enable remi + yum-config-manager --enable remi-php74 + yum-config-manager --enable nginx-mainline + yum-config-manager --enable mariadb + elif [ "$lsb_dist" = "rhel" ] && [ "$dist_version" = "8" ]; then + dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm + dnf -y install boost-program-options + dnf -y install http://rpms.remirepo.net/enterprise/remi-release-8.rpm + dnf config-manager --set-enabled remi + dnf -y module enable php:remi-7.4 + dnf -y module enable nginx:mainline/common + curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash + dnf config-manager --set-enabled mariadb + fi + yum -y install yum-utils tuned + tuned-adm profile latency-performance + yum -y upgrade + yum -y autoremove + yum -y clean packages + yum -y install curl bind-utils cronie + fi +} + +repositories_setup_0.7.19(){ output "Configuring your repositories..." if [ "$lsb_dist" = "ubuntu" ] || [ "$lsb_dist" = "debian" ]; then apt-get -y install sudo @@ -452,6 +579,68 @@ EOF } install_dependencies(){ + output "Installing dependencies..." + if [ "$lsb_dist" = "ubuntu" ] || [ "$lsb_dist" = "debian" ]; then + if [ "$webserver" = "1" ]; then + apt -y install php7.4 php7.4-{cli,gd,mysql,pdo,mbstring,tokenizer,bcmath,xml,fpm,curl,zip} nginx tar unzip git redis-server nginx git wget expect + elif [ "$webserver" = "2" ]; then + apt -y install php7.4 php7.4-{cli,gd,mysql,pdo,mbstring,tokenizer,bcmath,xml,fpm,curl,zip} curl tar unzip git redis-server apache2 libapache2-mod-php7.4 redis-server git wget expect + fi + sh -c "DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated mariadb-server" + elif [ "$lsb_dist" = "centos" ] && [ "$dist_version" = "7" ]; then + if [ "$webserver" = "1" ]; then + yum -y install php php-common php-fpm php-cli php-json php-mysqlnd php-mcrypt php-gd php-mbstring php-pdo php-zip php-bcmath php-dom php-opcache MariaDB-server redis nginx git policycoreutils-python-utils unzip wget expect tar + elif [ "$webserver" = "2" ]; then + yum -y install php php-common php-fpm php-cli php-json php-mysqlnd php-mcrypt php-gd php-mbstring php-pdo php-zip php-bcmath php-dom php-opcache MariaDB-server redis httpd git policycoreutils-python-utils mod_ssl unzip wget expect tar + fi + else + if [ "$lsb_dist" = "centos" ] || [ "$lsb_dist" = "rhel" ]; then + if [ "$dist_version" = "8" ]; then + dnf -y install MariaDB-server MariaDB-client --disablerepo=AppStream + fi + else + dnf -y install MariaDB-server + fi + dnf -y module install php:remi-7.4 + if [ "$webserver" = "1" ]; then + dnf -y install redis nginx git policycoreutils-python-utils unzip wget expect jq php-mysql php-zip php-bcmath tar + elif [ "$webserver" = "2" ]; then + dnf -y install redis httpd git policycoreutils-python-utils mod_ssl unzip wget expect jq php-mysql php-zip php-mcmath tar + fi + fi + + output "Enabling Services..." + if [ "$lsb_dist" = "ubuntu" ] || [ "$lsb_dist" = "debian" ]; then + systemctl enable redis-server + service redis-server start + systemctl enable php7.4-fpm + service php7.4-fpm start + elif [ "$lsb_dist" = "fedora" ] || [ "$lsb_dist" = "centos" ] || [ "$lsb_dist" = "rhel" ]; then + systemctl enable redis + service redis start + systemctl enable php-fpm + service php-fpm start + fi + + systemctl enable cron + systemctl enable mariadb + + if [ "$webserver" = "1" ]; then + systemctl enable nginx + service nginx start + elif [ "$webserver" = "2" ]; then + if [ "$lsb_dist" = "ubuntu" ] || [ "$lsb_dist" = "debian" ]; then + systemctl enable apache2 + service apache2 start + elif [ "$lsb_dist" = "fedora" ] || [ "$lsb_dist" = "centos" ] || [ "$lsb_dist" = "rhel" ]; then + systemctl enable httpd + service httpd start + fi + fi + service mysql start +} + +install_dependencies_0.7.19(){ output "Installing dependencies..." if [ "$lsb_dist" = "ubuntu" ] || [ "$lsb_dist" = "debian" ]; then if [ "$webserver" = "1" ]; then @@ -531,6 +720,132 @@ install_pterodactyl() { SQL="${Q0}${Q1}${Q2}${Q3}${Q4}${Q5}${Q6}${Q7}${Q8}${Q9}" mysql -u root -e "$SQL" + output "Binding MariaDB/MySQL to 0.0.0.0." + if grep -Fqs "bind-address" /etc/mysql/mariadb.conf.d/50-server.cnf ; then + sed -i -- '/bind-address/s/#//g' /etc/mysql/mariadb.conf.d/50-server.cnf + sed -i -- '/bind-address/s/127.0.0.1/0.0.0.0/g' /etc/mysql/mariadb.conf.d/50-server.cnf + output 'Restarting MySQL process...' + service mysql restart + elif grep -Fqs "bind-address" /etc/mysql/my.cnf ; then + sed -i -- '/bind-address/s/#//g' /etc/mysql/my.cnf + sed -i -- '/bind-address/s/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf + output 'Restarting MySQL process...' + service mysql restart + elif grep -Fqs "bind-address" /etc/my.cnf ; then + sed -i -- '/bind-address/s/#//g' /etc/my.cnf + sed -i -- '/bind-address/s/127.0.0.1/0.0.0.0/g' /etc/my.cnf + output 'Restarting MySQL process...' + service mysql restart + elif grep -Fqs "bind-address" /etc/mysql/my.conf.d/mysqld.cnf ; then + sed -i -- '/bind-address/s/#//g' /etc/mysql/my.conf.d/mysqld.cnf + sed -i -- '/bind-address/s/127.0.0.1/0.0.0.0/g' /etc/mysql/my.conf.d/mysqld.cnf + output 'Restarting MySQL process...' + service mysql restart + else + output 'A MySQL configuration file could not be detected! Please contact support.' + fi + + output "Downloading Pterodactyl..." + mkdir -p /var/www/pterodactyl + cd /var/www/pterodactyl + curl -Lo panel.tar.gz https://github.com/pterodactyl/panel/releases/download/v1.0.0/panel.tar.gz + tar --strip-components=1 -xzvf panel.tar.gz + chmod -R 755 storage/* bootstrap/cache/ + + output "Installing Pterodactyl..." + curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer + cp .env.example .env + /usr/local/bin/composer install --no-dev --optimize-autoloader + 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 + elif [ "$lsb_dist" = "fedora" ] || [ "$lsb_dist" = "centos" ] || [ "$lsb_dist" = "rhel" ]; then + if [ "$webserver" = "1" ]; then + chown -R nginx:nginx * /var/www/pterodactyl + elif [ "$webserver" = "2" ]; then + chown -R apache:apache * /var/www/pterodactyl + fi + semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/pterodactyl/storage(/.*)?" + restorecon -R /var/www/pterodactyl + fi + + output "Creating panel queue listeners..." + (crontab -l ; echo "* * * * * php /var/www/pterodactyl/artisan schedule:run >> /dev/null 2>&1")| crontab - + service cron restart + + if [ "$lsb_dist" = "ubuntu" ] || [ "$lsb_dist" = "debian" ]; then + cat > /etc/systemd/system/pteroq.service <<- 'EOF' +[Unit] +Description=Pterodactyl Queue Worker +After=redis-server.service +[Service] +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 +[Install] +WantedBy=multi-user.target +EOF + elif [ "$lsb_dist" = "fedora" ] || [ "$lsb_dist" = "centos" ] || [ "$lsb_dist" = "rhel" ]; then + if [ "$webserver" = "1" ]; then + cat > /etc/systemd/system/pteroq.service <<- 'EOF' +Description=Pterodactyl Queue Worker +After=redis-server.service +[Service] +User=nginx +Group=nginx +Restart=always +ExecStart=/usr/bin/php /var/www/pterodactyl/artisan queue:work --queue=high,standard,low --sleep=3 --tries=3 +[Install] +WantedBy=multi-user.target +EOF + elif [ "$webserver" = "2" ]; then + cat > /etc/systemd/system/pteroq.service <<- 'EOF' +[Unit] +Description=Pterodactyl Queue Worker +After=redis-server.service +[Service] +User=apache +Group=apache +Restart=always +ExecStart=/usr/bin/php /var/www/pterodactyl/artisan queue:work --queue=high,standard,low --sleep=3 --tries=3 +[Install] +WantedBy=multi-user.target +EOF + fi + setsebool -P httpd_can_network_connect 1 + setsebool -P httpd_execmem 1 + setsebool -P httpd_unified 1 + fi + sudo systemctl daemon-reload + systemctl enable pteroq.service + systemctl start pteroq +} + +install_pterodactyl_0.7.19() { + 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';" + Q4="GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, INDEX, DROP, EXECUTE, PROCESS, RELOAD, LOCK TABLES, CREATE USER ON *.* TO 'admin'@'$SERVER_IP' IDENTIFIED BY '$adminpassword' WITH GRANT OPTION;" + 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" + output "Binding MariaDB/MySQL to 0.0.0.0." if grep -Fqs "bind-address" /etc/mysql/mariadb.conf.d/50-server.cnf ; then sed -i -- '/bind-address/s/#//g' /etc/mysql/mariadb.conf.d/50-server.cnf @@ -640,6 +955,29 @@ EOF } upgrade_pterodactyl(){ + cd /var/www/pterodactyl + php artisan down + curl -L https://github.com/pterodactyl/panel/releases/download/v1.0.0/panel.tar.gz | tar --strip-components=1 -xzv + chmod -R 755 storage/* bootstrap/cache + composer install --no-dev --optimize-autoloader + php artisan view:clear + php artisan config:clear + php artisan migrate --force + php artisan db:seed --force + if [ "$lsb_dist" = "ubuntu" ] || [ "$lsb_dist" = "debian" ]; then + chown -R www-data:www-data * /var/www/pterodactyl + elif [ "$lsb_dist" = "fedora" ] || [ "$lsb_dist" = "centos" ] || [ "$lsb_dist" = "rhel" ]; then + chown -R apache:apache * /var/www/pterodactyl + chown -R nginx:nginx * /var/www/pterodactyl + semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/pterodactyl/storage(/.*)?" + restorecon -R /var/www/pterodactyl + fi + output "Your panel has successfully been updated to version 0.7.19." + php artisan up + php artisan queue:restart +} + +upgrade_pterodactyl_0.7.19(){ cd /var/www/pterodactyl php artisan down curl -L https://github.com/pterodactyl/panel/releases/download/v0.7.19/panel.tar.gz | tar --strip-components=1 -xzv @@ -943,9 +1281,73 @@ setup_pterodactyl(){ install_pterodactyl ssl_certs webserver_config +} + + +setup_pterodactyl_0.7.19(){ + install_dependencies_0.7.19 + install_pterodactyl_0.7.19 + ssl_certs + webserver_config theme } +install_wings() { + cd /root + output "Installing Pterodactyl Wings dependencies..." + if [ "$lsb_dist" = "ubuntu" ] || [ "$lsb_dist" = "debian" ]; then + apt-get -y install curl tar unzip + elif [ "$lsb_dist" = "fedora" ] || [ "$lsb_dist" = "centos" ] || [ "$lsb_dist" = "rhel" ]; then + yum -y install curl tar unzip + fi + + if [[ ( "$lsb_dist" = "centos" || "$lsb_dist" = "rhel" ) && "$dist_version" = "8" ]]; then + curl -sSL https://raw.githubusercontent.com/tommytran732/CentOS-8-Docker-Script/master/get-docker.sh | sudo bash + else + output "Installing Docker" + curl -sSL https://get.docker.com/ | CHANNEL=stable bash + fi + + service docker start + systemctl enable docker + output "Enabling SWAP support for Docker & installing NodeJS..." + sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="[^"]*/& swapaccount=1/' /etc/default/grub + mkdir -p /etc/pterodactyl + curl -L -o /usr/local/bin/wings https://github.com/pterodactyl/wings/releases/download/v1.0.0/wings_linux_amd64 + chmod u+x /usr/local/bin/wings + + output "Installing the Pterodactyl daemon..." + 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 + bash -c 'cat > /etc/systemd/system/wings.service' <<-'EOF' +[Unit] +Description=Pterodactyl Wings Daemon +After=docker.service + +[Service] +User=root +WorkingDirectory=/etc/pterodactyl +LimitNOFILE=4096 +PIDFile=/var/run/wings/daemon.pid +ExecStart=/usr/local/bin/wings +Restart=on-failure +StartLimitInterval=600 + +[Install] +WantedBy=multi-user.target +EOF + + systemctl enable --now wings + + output "Daemon installation is nearly complete, please go to the panel and get your 'Auto Deploy' command in the node configuration tab." + output "Paste your auto deploy command below: " + read AUTODEPLOY + ${AUTODEPLOY} + service wings start +} + install_daemon() { cd /root output "Installing Pterodactyl Daemon dependencies..." @@ -1029,6 +1431,36 @@ EOF service wings start } +migrate_wings(){ + mkdir -p /etc/pterodactyl + curl -L -o /usr/local/bin/wings https://github.com/pterodactyl/wings/releases/download/v1.0.0/wings_linux_amd64 + chmod u+x /usr/local/bin/wings + systemctl stop wings + rm -rf /srv/daemon + systemctl disable --now pterosftp + rm /etc/systemd/system/pterosftp.service + bash -c 'cat > /etc/systemd/system/wings.service' <<-'EOF' +[Unit] +Description=Pterodactyl Wings Daemon +After=docker.service + +[Service] +User=root +WorkingDirectory=/etc/pterodactyl +LimitNOFILE=4096 +PIDFile=/var/run/wings/daemon.pid +ExecStart=/usr/local/bin/wings +Restart=on-failure +StartLimitInterval=600 + +[Install] +WantedBy=multi-user.target +EOF + systemctl daemon-reload + systemctl enable --now wings + output "Your daemon has been migrated to wings." +} + upgrade_daemon(){ cd /srv/daemon service wings stop @@ -1438,62 +1870,89 @@ broadcast_database(){ preflight install_options case $installoption in - 1) webserver_options - theme_options - repositories_setup - required_infos - firewall - setup_pterodactyl - broadcast - ;; - 2) repositories_setup - required_infos - firewall - ssl_certs - install_daemon - broadcast - ;; - 3) webserver_options - theme_options - repositories_setup - required_infos - firewall - setup_pterodactyl - install_daemon - broadcast - ;; - 4) install_standalone_sftp - ;; - 5) theme_options - upgrade_pterodactyl - theme - ;; - 6) upgrade_daemon - ;; - 7) theme_options - upgrade_pterodactyl - theme - upgrade_daemon - ;; - 8) upgrade_standalone_sftp - ;; - 9) install_mobile - ;; - 10) upgrade_mobile - ;; - 11) install_phpmyadmin - ;; - 12) repositories_setup - install_database - ;; - 13) theme_options + 1) webserver_options + theme_options + repositories_setup + required_infos + firewall + setup_pterodactyl + broadcast + ;; + 2) webserver_options + theme_options + repositories_setup_0.7.19 + required_infos + firewall + setup_pterodactyl_0.7.19 + broadcast + ;; + 3) repositories_setup + required_infos + firewall + ssl_certs + install_wings + broadcast + ;; + 4) repositories_setup_0.7.19 + required_infos + firewall + ssl_certs + install_daemon + broadcast + ;; + 5) webserver_options + repositories_setup + required_infos + firewall + setup_pterodactyl + install_wings + broadcast + ;; + 6) webserver_options + theme_options + repositories_setup_0.7.19 + required_infos + firewall + setup_pterodactyl_0.7.19 + install_daemon + broadcast + ;; + 7) install_standalone_sftp + ;; + 8) upgrade_pterodactyl + ;; + 9) theme_options + upgrade_pterodactyl_0.7.19 + theme + ;; + 10) upgrade_daemon + ;; + 11) migrate_wings + ;; + 12) theme_options + upgrade_pterodactyl_0.7.19 + theme + migrate_wings + ;; + 13) upgrade_standalone_sftp + ;; + 14) install_mobile + ;; + 15) upgrade_mobile + ;; + 16) install_phpmyadmin + ;; + 17) repositories_setup + install_database + ;; + 18) theme_options if [ "$themeoption" = "1" ]; then - upgrade_pterodactyl + upgrade_pterodactyl fi theme - ;; - 14) curl -sSL https://raw.githubusercontent.com/tommytran732/MariaDB-Root-Password-Reset/master/mariadb-104.sh | sudo bash - ;; - 15) database_host_reset - ;; + ;; + 19) curl -sSL https://raw.githubusercontent.com/tommytran732/MariaDB-Root-Password-Reset/master/mariadb-104.sh | sudo bash + ;; + 20) database_host_reset + ;; esac From df09c74fdb5aee2bcc974e5380226a5a62253a3a Mon Sep 17 00:00:00 2001 From: HeyJack Date: Mon, 12 Oct 2020 03:33:14 +0100 Subject: [PATCH 02/18] done??? --- install.sh | 107 ++++++++++++++++++++++++++++------------------------- 1 file changed, 56 insertions(+), 51 deletions(-) diff --git a/install.sh b/install.sh index d15a712..c109526 100644 --- a/install.sh +++ b/install.sh @@ -192,7 +192,7 @@ install_options(){ output "You have selected daemon installation only." ;; 5 ) installoption=5 - output "You have selected 1.0 panel and daemon installation." + output "You have selected 1.0 panel and wings installation." ;; 6 ) installoption=6 output "You have selected 0.7.19 panel and daemon installation." @@ -1870,52 +1870,52 @@ broadcast_database(){ preflight install_options case $installoption in - 1) webserver_options - theme_options - repositories_setup - required_infos - firewall - setup_pterodactyl - broadcast + 1) webserver_options + theme_options + repositories_setup + required_infos + firewall + setup_pterodactyl + broadcast ;; - 2) webserver_options - theme_options - repositories_setup_0.7.19 - required_infos - firewall - setup_pterodactyl_0.7.19 - broadcast + 2) webserver_options + theme_options + repositories_setup_0.7.19 + required_infos + firewall + setup_pterodactyl_0.7.19 + broadcast ;; - 3) repositories_setup - required_infos - firewall - ssl_certs - install_wings - broadcast + 3) repositories_setup + required_infos + firewall + ssl_certs + install_wings + broadcast ;; - 4) repositories_setup_0.7.19 - required_infos - firewall - ssl_certs - install_daemon - broadcast + 4) repositories_setup_0.7.19 + required_infos + firewall + ssl_certs + install_daemon + broadcast ;; - 5) webserver_options - repositories_setup - required_infos - firewall - setup_pterodactyl - install_wings - broadcast + 5) webserver_options + repositories_setup + required_infos + firewall + setup_pterodactyl + install_wings + broadcast ;; - 6) webserver_options - theme_options - repositories_setup_0.7.19 - required_infos - firewall - setup_pterodactyl_0.7.19 - install_daemon - broadcast + 6) webserver_options + theme_options + repositories_setup_0.7.19 + required_infos + firewall + setup_pterodactyl_0.7.19 + install_daemon + broadcast ;; 7) install_standalone_sftp ;; @@ -1934,25 +1934,30 @@ case $installoption in theme migrate_wings ;; - 13) upgrade_standalone_sftp + 13) theme_options + upgrade_pterodactyl + theme + upgrade_daemon ;; - 14) install_mobile + 14) upgrade_standalone_sftp ;; - 15) upgrade_mobile + 15) install_mobile ;; - 16) install_phpmyadmin + 16) upgrade_mobile ;; - 17) repositories_setup + 17) install_phpmyadmin + ;; + 18) repositories_setup install_database ;; - 18) theme_options + 19) theme_options if [ "$themeoption" = "1" ]; then - upgrade_pterodactyl + upgrade_pterodactyl_0.7.19 fi theme ;; - 19) curl -sSL https://raw.githubusercontent.com/tommytran732/MariaDB-Root-Password-Reset/master/mariadb-104.sh | sudo bash + 20) curl -sSL https://raw.githubusercontent.com/tommytran732/MariaDB-Root-Password-Reset/master/mariadb-104.sh | sudo bash ;; - 20) database_host_reset + 21) database_host_reset ;; esac From 7003f26c624d572746b6ade9fb9d5adb72e14c40 Mon Sep 17 00:00:00 2001 From: HeyJack Date: Mon, 12 Oct 2020 04:26:58 +0100 Subject: [PATCH 03/18] woops --- install.sh | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/install.sh b/install.sh index c109526..fad8f32 100644 --- a/install.sh +++ b/install.sh @@ -42,9 +42,9 @@ preflight(){ apt-get -y install virt-what curl elif [ "$lsb_dist" = "debian" ]; then apt update --fix-missing - apt-get -y install software-properties-common virt-what wget curl + apt-get -y install software-properties-common virt-what wget curl dnsutils elif [ "$lsb_dist" = "fedora" ] || [ "$lsb_dist" = "centos" ] || [ "$lsb_dist" = "rhel" ]; then - yum -y install virt-what wget + yum -y install virt-what wget bind-utils fi virt_serv=$(echo $(virt-what)) if [ "$virt_serv" = "" ]; then @@ -160,7 +160,7 @@ install_options(){ output "[2] Install the panel (0.7.19)." output "[3] Install the wings." output "[4] Install the daemon." - output "[5] Install the (1.0) panel and daemon." + output "[5] Install the (1.0) panel and wings." output "[6] Install the (0.7.19) panel and daemon." output "[7] Install the standalone SFTP server." output "[8] Upgrade (0.7.x) panel to (1.0)." @@ -1310,17 +1310,13 @@ install_wings() { service docker start systemctl enable docker - output "Enabling SWAP support for Docker & installing NodeJS..." + output "Enabling SWAP support for Docker." sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="[^"]*/& swapaccount=1/' /etc/default/grub - mkdir -p /etc/pterodactyl + output "Installing the Pterodactyl wings..." + mkdir -p /etc/pterodactyl /srv/daemon-data + cd /etc/pterodactyl curl -L -o /usr/local/bin/wings https://github.com/pterodactyl/wings/releases/download/v1.0.0/wings_linux_amd64 chmod u+x /usr/local/bin/wings - - output "Installing the Pterodactyl daemon..." - 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 bash -c 'cat > /etc/systemd/system/wings.service' <<-'EOF' [Unit] Description=Pterodactyl Wings Daemon @@ -1345,7 +1341,7 @@ EOF output "Paste your auto deploy command below: " read AUTODEPLOY ${AUTODEPLOY} - service wings start + sudo wings } install_daemon() { From 9d07b014adc6a9bd3b584a5124b59614cf9b8a9f Mon Sep 17 00:00:00 2001 From: HeyJack Date: Mon, 12 Oct 2020 05:33:42 +0100 Subject: [PATCH 04/18] woops --- install.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/install.sh b/install.sh index fad8f32..8621944 100644 --- a/install.sh +++ b/install.sh @@ -749,7 +749,7 @@ install_pterodactyl() { mkdir -p /var/www/pterodactyl cd /var/www/pterodactyl curl -Lo panel.tar.gz https://github.com/pterodactyl/panel/releases/download/v1.0.0/panel.tar.gz - tar --strip-components=1 -xzvf panel.tar.gz + tar -xzvf panel.tar.gz chmod -R 755 storage/* bootstrap/cache/ output "Installing Pterodactyl..." @@ -1867,7 +1867,6 @@ preflight install_options case $installoption in 1) webserver_options - theme_options repositories_setup required_infos firewall From 53fbc57ecff611fa4ac9ed81e07de7df24df3d87 Mon Sep 17 00:00:00 2001 From: HeyJack Date: Mon, 12 Oct 2020 06:49:55 +0100 Subject: [PATCH 05/18] fix SSL configs --- install.sh | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 8621944..eb5b817 100644 --- a/install.sh +++ b/install.sh @@ -972,7 +972,7 @@ upgrade_pterodactyl(){ semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/pterodactyl/storage(/.*)?" restorecon -R /var/www/pterodactyl fi - output "Your panel has successfully been updated to version 0.7.19." + output "Your panel has successfully been updated to version 1.0." php artisan up php artisan queue:restart } @@ -1628,8 +1628,24 @@ ssl_certs(){ (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service apache2 stop" --post-hook "service apache2 restart" >> /dev/null 2>&1')| crontab - fi elif [ "$installoption" = "2" ]; then - (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "ufw allow 80" --pre-hook "service wings stop" --post-hook "ufw deny 80" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - + if [ "$webserver" = "1" ]; then + (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service nginx stop" --post-hook "service nginx restart" >> /dev/null 2>&1')| crontab - + elif [ "$webserver" = "2" ]; then + (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service apache2 stop" --post-hook "service apache2 restart" >> /dev/null 2>&1')| crontab - + fi elif [ "$installoption" = "3" ]; then + (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "ufw allow 80" --pre-hook "service wings stop" --post-hook "ufw deny 80" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - + elif [ "$installoption" = "3" ]; then + if [ "$webserver" = "1" ]; then + (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "ufw allow 80" --pre-hook "service wings stop" --post-hook "ufw deny 80" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - + fi + elif [ "$installoption" = "5" ]; then + if [ "$webserver" = "1" ]; then + (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service nginx stop" --pre-hook "service wings stop" --post-hook "service nginx restart" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - + elif [ "$webserver" = "2" ]; then + (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service apache2 stop" --pre-hook "service wings stop" --post-hook "service apache2 restart" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - + fi + elif [ "$installoption" = "6" ]; then if [ "$webserver" = "1" ]; then (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service nginx stop" --pre-hook "service wings stop" --post-hook "service nginx restart" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - elif [ "$webserver" = "2" ]; then @@ -1644,14 +1660,29 @@ ssl_certs(){ (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service httpd stop" --post-hook "service httpd restart" >> /dev/null 2>&1')| crontab - fi elif [ "$installoption" = "2" ]; then - (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "firewall-cmd --add-port=80/tcp && firewall-cmd --reload" --pre-hook "service wings stop" --post-hook "firewall-cmd --remove-port=80/tcp && firewall-cmd --reload" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - + if [ "$webserver" = "1" ]; then + (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service nginx stop" --post-hook "service nginx restart" >> /dev/null 2>&1')| crontab - + elif [ "$webserver" = "2" ]; then + (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service httpd stop" --post-hook "service httpd restart" >> /dev/null 2>&1')| crontab - + fi elif [ "$installoption" = "3" ]; then + (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "firewall-cmd --add-port=80/tcp && firewall-cmd --reload" --pre-hook "service wings stop" --post-hook "firewall-cmd --remove-port=80/tcp && firewall-cmd --reload" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - + elif [ "$installoption" = "4" ]; then + (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "firewall-cmd --add-port=80/tcp && firewall-cmd --reload" --pre-hook "service wings stop" --post-hook "firewall-cmd --remove-port=80/tcp && firewall-cmd --reload" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - + elif [ "$installoption" = "5" ]; then if [ "$webserver" = "1" ]; then (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service nginx stop" --pre-hook "service wings stop" --post-hook "service nginx restart" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - elif [ "$webserver" = "2" ]; then (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service httpd stop" --pre-hook "service wings stop" --post-hook "service httpd restart" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - fi - fi + elif [ "$installoption" = "6" ]; then + if [ "$webserver" = "1" ]; then + (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service nginx stop" --pre-hook "service wings stop" --post-hook "service nginx restart" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - + elif [ "$webserver" = "2" ]; then + (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service httpd stop" --pre-hook "service wings stop" --post-hook "service httpd restart" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - + fi + + fi fi } From 9ed4a42761f98d45c244570c1797dc74e59da061 Mon Sep 17 00:00:00 2001 From: TheRealHeyJack Date: Mon, 12 Oct 2020 06:56:06 +0100 Subject: [PATCH 06/18] Update README.md --- README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index aeadf3a..69ea9ac 100644 --- a/README.md +++ b/README.md @@ -10,14 +10,10 @@ Discord group: https://revenact.io/discord
If you need me to help you fix or debug something, contact me via Telegram Secret Chat. - Please, please don't send me your server credentials via Discord.
-# Pterodactyl v1.0 Release Candidate -Pterodactyl v1.0 will NOT be supported until it is ready for production.
-With that being said, you can still try out the v1.0 script version using:
-
-`bash <(curl -sSL https://raw.githubusercontent.com/tommytran732/Pterodactyl-Script/pterodactyl-1.0/install.sh)` -
+# Now with extra Pterodactyl v1.0 +This Script now includes the new Pterodactyl v1.0 release

-A migration script from v0.7 to v1.0 will be available at a later date. +This Script also includes a migration script for 0.7 to 1.0 and Daemon to Wings
# Supported Operating System | Operating System | Version | Supported | Recommended | Notes | From 73ae1bba8a24407473cb98c5b761c59ce0248307 Mon Sep 17 00:00:00 2001 From: HeyJack Date: Mon, 12 Oct 2020 07:16:08 +0100 Subject: [PATCH 07/18] PHP can suck a nut --- install.sh | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 128 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index eb5b817..638f858 100644 --- a/install.sh +++ b/install.sh @@ -1005,6 +1005,97 @@ nginx_config() { rm -rf /etc/nginx/sites-enabled/default output "Configuring Nginx Webserver..." +echo ' +server_tokens off; +set_real_ip_from 103.21.244.0/22; +set_real_ip_from 103.22.200.0/22; +set_real_ip_from 103.31.4.0/22; +set_real_ip_from 104.16.0.0/12; +set_real_ip_from 108.162.192.0/18; +set_real_ip_from 131.0.72.0/22; +set_real_ip_from 141.101.64.0/18; +set_real_ip_from 162.158.0.0/15; +set_real_ip_from 172.64.0.0/13; +set_real_ip_from 173.245.48.0/20; +set_real_ip_from 188.114.96.0/20; +set_real_ip_from 190.93.240.0/20; +set_real_ip_from 197.234.240.0/22; +set_real_ip_from 198.41.128.0/17; +set_real_ip_from 2400:cb00::/32; +set_real_ip_from 2606:4700::/32; +set_real_ip_from 2803:f800::/32; +set_real_ip_from 2405:b500::/32; +set_real_ip_from 2405:8100::/32; +set_real_ip_from 2c0f:f248::/32; +set_real_ip_from 2a06:98c0::/29; +real_ip_header X-Forwarded-For; +server { + listen 80 default_server; + server_name '"$FQDN"'; + return 301 https://$server_name$request_uri; +} +server { + listen 443 ssl http2 default_server; + server_name '"$FQDN"'; + root /var/www/pterodactyl/public; + index index.php; + access_log /var/log/nginx/pterodactyl.app-access.log; + error_log /var/log/nginx/pterodactyl.app-error.log error; + # allow larger file uploads and longer script runtimes + client_max_body_size 100m; + client_body_timeout 120s; + sendfile off; + # SSL Configuration + ssl_certificate /etc/letsencrypt/live/'"$FQDN"'/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/'"$FQDN"'/privkey.pem; + ssl_session_cache shared:SSL:10m; + ssl_protocols TLSv1.2; + ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256'; + ssl_prefer_server_ciphers on; + # See https://hstspreload.org/ before uncommenting the line below. + # add_header Strict-Transport-Security "max-age=15768000; preload;"; + 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; + } + location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass unix:/var/run/php/php7.4-fpm.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; + } + location ~ /\.ht { + deny all; + } +} +' | sudo -E tee /etc/nginx/sites-available/pterodactyl.conf >/dev/null 2>&1 + if [ "$lsb_dist" = "debian" ] && [ "$dist_version" = "8" ]; then + sed -i 's/http2//g' /etc/nginx/sites-available/pterodactyl.conf + fi + ln -s /etc/nginx/sites-available/pterodactyl.conf /etc/nginx/sites-enabled/pterodactyl.conf + service nginx restart +} + +nginx_config_0.7.19() { + output "Disabling default configuration..." + rm -rf /etc/nginx/sites-enabled/default + output "Configuring Nginx Webserver..." + echo ' server_tokens off; set_real_ip_from 103.21.244.0/22; @@ -1259,11 +1350,43 @@ EOF } webserver_config(){ - if [ "$lsb_dist" = "ubuntu" ] || [ "$lsb_dist" = "debian" ]; then - if [ "$webserver" = "1" ]; then - nginx_config - elif [ "$webserver" = "2" ]; then - apache_config + if [ "$lsb_dist" = "debian" ] || [ "$lsb_dist" = "ubuntu" ]; then + if [ "$installoption" = "1" ]; then + if [ "$webserver" = "1" ]; then + nginx_config + elif [ "$webserver" = "2" ]; then + apache_config + fi + elif [ "$installoption" = "2" ]; then + if [ "$webserver" = "1" ]; then + nginx_config_0.7.19 + elif [ "$webserver" = "2" ]; then + apache_config + fi + elif [ "$installoption" = "3" ]; then + if [ "$webserver" = "1" ]; then + nginx_config + elif [ "$webserver" = "2" ]; then + apache_config + fi + elif [ "$installoption" = "3" ]; then + if [ "$webserver" = "1" ]; then + nginx_config_0.7.19 + elif [ "$webserver" = "2" ]; then + apache_config + fi + elif [ "$installoption" = "5" ]; then + if [ "$webserver" = "1" ]; then + nginx_config + elif [ "$webserver" = "2" ]; then + apache_config + fi + elif [ "$installoption" = "6" ]; then + if [ "$webserver" = "1" ]; then + nginx_config_0.7.19 + elif [ "$webserver" = "2" ]; then + apache_config + fi fi elif [ "$lsb_dist" = "fedora" ] || [ "$lsb_dist" = "centos" ] || [ "$lsb_dist" = "rhel" ]; then if [ "$webserver" = "1" ]; then From 55d6de93bc1b0f78b12442200a152fac112a620d Mon Sep 17 00:00:00 2001 From: HeyJack Date: Mon, 12 Oct 2020 07:28:02 +0100 Subject: [PATCH 08/18] 1 number --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 638f858..7910045 100644 --- a/install.sh +++ b/install.sh @@ -1369,7 +1369,7 @@ webserver_config(){ elif [ "$webserver" = "2" ]; then apache_config fi - elif [ "$installoption" = "3" ]; then + elif [ "$installoption" = "4" ]; then if [ "$webserver" = "1" ]; then nginx_config_0.7.19 elif [ "$webserver" = "2" ]; then From 45cf2d619c4eca14603cb186132ecae5c1bd6061 Mon Sep 17 00:00:00 2001 From: HeyJack Date: Mon, 12 Oct 2020 07:47:32 +0100 Subject: [PATCH 09/18] Added Warnings for Scuffedness --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index 7910045..62a7432 100644 --- a/install.sh +++ b/install.sh @@ -155,6 +155,7 @@ os_check(){ } install_options(){ + warn "INSTALLING 1.0 WITH NGINX IS BROKEN AS OF THIS TIME ALSO WITH WINGS YOU NEED THE CONFIG FROM YOUR PANEL IN /etc/pterodactyl/config.yml" output "Please select your installation option:" output "[1] Install the panel (1.0)." output "[2] Install the panel (0.7.19)." From 15bed0dcb3a9dc7431e466bbe553008440e29abf Mon Sep 17 00:00:00 2001 From: HeyJack Date: Mon, 12 Oct 2020 20:29:38 +0100 Subject: [PATCH 10/18] Remove Auto-Deploy from Wings install --- install.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 62a7432..05b95e2 100644 --- a/install.sh +++ b/install.sh @@ -1138,7 +1138,7 @@ server { client_body_timeout 120s; sendfile off; # SSL Configuration - ssl_certificate /etc/letsencrypt/live/'"$FQDN"'/fullchain.pem; + ssl_certificate /etc/letsencrypt/live/'"$FQDN"'/fullchain.pem;- ssl_certificate_key /etc/letsencrypt/live/'"$FQDN"'/privkey.pem; ssl_session_cache shared:SSL:10m; ssl_protocols TLSv1.2; @@ -1461,10 +1461,6 @@ EOF systemctl enable --now wings - output "Daemon installation is nearly complete, please go to the panel and get your 'Auto Deploy' command in the node configuration tab." - output "Paste your auto deploy command below: " - read AUTODEPLOY - ${AUTODEPLOY} sudo wings } From 4c864e5a2e2f491f4a07f1de9a17aea9a3436776 Mon Sep 17 00:00:00 2001 From: HeyJack Date: Tue, 13 Oct 2020 05:18:01 +0100 Subject: [PATCH 11/18] Debug SSL --- install.sh | 76 +++++++++++++++--------------------------------------- 1 file changed, 21 insertions(+), 55 deletions(-) diff --git a/install.sh b/install.sh index 05b95e2..3d5bc2c 100644 --- a/install.sh +++ b/install.sh @@ -1007,66 +1007,33 @@ nginx_config() { output "Configuring Nginx Webserver..." echo ' -server_tokens off; -set_real_ip_from 103.21.244.0/22; -set_real_ip_from 103.22.200.0/22; -set_real_ip_from 103.31.4.0/22; -set_real_ip_from 104.16.0.0/12; -set_real_ip_from 108.162.192.0/18; -set_real_ip_from 131.0.72.0/22; -set_real_ip_from 141.101.64.0/18; -set_real_ip_from 162.158.0.0/15; -set_real_ip_from 172.64.0.0/13; -set_real_ip_from 173.245.48.0/20; -set_real_ip_from 188.114.96.0/20; -set_real_ip_from 190.93.240.0/20; -set_real_ip_from 197.234.240.0/22; -set_real_ip_from 198.41.128.0/17; -set_real_ip_from 2400:cb00::/32; -set_real_ip_from 2606:4700::/32; -set_real_ip_from 2803:f800::/32; -set_real_ip_from 2405:b500::/32; -set_real_ip_from 2405:8100::/32; -set_real_ip_from 2c0f:f248::/32; -set_real_ip_from 2a06:98c0::/29; -real_ip_header X-Forwarded-For; server { - listen 80 default_server; - server_name '"$FQDN"'; - return 301 https://$server_name$request_uri; -} -server { - listen 443 ssl http2 default_server; + listen 80; server_name '"$FQDN"'; + root /var/www/pterodactyl/public; - index index.php; - access_log /var/log/nginx/pterodactyl.app-access.log; - error_log /var/log/nginx/pterodactyl.app-error.log error; - # allow larger file uploads and longer script runtimes - client_max_body_size 100m; - client_body_timeout 120s; - sendfile off; - # SSL Configuration - ssl_certificate /etc/letsencrypt/live/'"$FQDN"'/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/'"$FQDN"'/privkey.pem; - ssl_session_cache shared:SSL:10m; - ssl_protocols TLSv1.2; - ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256'; - ssl_prefer_server_ciphers on; - # See https://hstspreload.org/ before uncommenting the line below. - # add_header Strict-Transport-Security "max-age=15768000; preload;"; - 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; + index index.html index.htm index.php; + charset utf-8; + location / { try_files $uri $uri/ /index.php?$query_string; } + + location = /favicon.ico { access_log off; log_not_found off; } + location = /robots.txt { access_log off; log_not_found off; } + + access_log off; + error_log /var/log/nginx/pterodactyl.app-error.log error; + + # allow larger file uploads and longer script runtimes + client_max_body_size 100m; + client_body_timeout 120s; + + sendfile off; + location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; + fastcgi_pass unix:/run/php/php7.4-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param PHP_VALUE "upload_max_filesize = 100M \n post_max_size=100M"; @@ -1078,12 +1045,12 @@ server { fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; - include /etc/nginx/fastcgi_params; } + location ~ /\.ht { deny all; } -} +}} ' | sudo -E tee /etc/nginx/sites-available/pterodactyl.conf >/dev/null 2>&1 if [ "$lsb_dist" = "debian" ] && [ "$dist_version" = "8" ]; then sed -i 's/http2//g' /etc/nginx/sites-available/pterodactyl.conf @@ -1403,7 +1370,6 @@ webserver_config(){ setup_pterodactyl(){ install_dependencies install_pterodactyl - ssl_certs webserver_config } From 763578a3cfe5317328dfe114562d03e31fd20469 Mon Sep 17 00:00:00 2001 From: HeyJack Date: Tue, 13 Oct 2020 05:37:35 +0100 Subject: [PATCH 12/18] .1 --- install.sh | 127 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 78 insertions(+), 49 deletions(-) diff --git a/install.sh b/install.sh index 3d5bc2c..76353e1 100644 --- a/install.sh +++ b/install.sh @@ -155,33 +155,34 @@ os_check(){ } install_options(){ - warn "INSTALLING 1.0 WITH NGINX IS BROKEN AS OF THIS TIME ALSO WITH WINGS YOU NEED THE CONFIG FROM YOUR PANEL IN /etc/pterodactyl/config.yml" + warn "INSTALLING 1.0.1 WITH NGINX IS BROKEN AS OF THIS TIME ALSO WITH WINGS YOU NEED THE CONFIG FROM YOUR PANEL IN /etc/pterodactyl/config.yml" output "Please select your installation option:" - output "[1] Install the panel (1.0)." + output "[1] Install the panel (1.0.1)." output "[2] Install the panel (0.7.19)." output "[3] Install the wings." output "[4] Install the daemon." - output "[5] Install the (1.0) panel and wings." + output "[5] Install the (1.0.1) panel and wings." output "[6] Install the (0.7.19) panel and daemon." output "[7] Install the standalone SFTP server." - output "[8] Upgrade (0.7.x) panel to (1.0)." - output "[9] Upgrade (0.7.x) panel to (0.7.19)." - output "[10] Upgrade (0.6.x) daemon to (0.6.13)." - output "[11] Migrating daemon to wings." - output "[12] Upgrade the panel to 1.0 and Migrate to wings" - output "[13] Upgrade the panel to 0.7.19 and daemon to (0.6.13)" - output "[14] Upgrade the standalone SFTP server to (1.0.5)." - output "[15] Make Pterodactyl compatible with the mobile app (only use this after you have installed the panel - check out https://pterodactyl.cloud for more information)." - output "[16] Update mobile compatibility." - output "[17] Install or update to phpMyAdmin (5.0.2) (only use this after you have installed the panel)." - output "[18] Install a standalone database host (only for use on daemon-only installations)." - output "[19] Change Pterodactyl theme (0.7.19 Only)." - output "[20] Emergency MariaDB root password reset." - output "[21] Emergency database host information reset." + output "[8] Upgrade (1.0) panel to (1.0.1)." + output "[9] Upgrade (0.7.x) panel to (1.0.1)." + output "[10] Upgrade (0.7.x) panel to (0.7.19)." + output "[11] Upgrade (0.6.x) daemon to (0.6.13)." + output "[12] Migrating daemon to wings." + output "[13] Upgrade the panel to 1.0.1 and Migrate to wings" + output "[14] Upgrade the panel to 0.7.19 and daemon to (0.6.13)" + output "[15] Upgrade the standalone SFTP server to (1.0.5)." + output "[16] Make Pterodactyl compatible with the mobile app (only use this after you have installed the panel - check out https://pterodactyl.cloud for more information)." + output "[17] Update mobile compatibility." + output "[18] Install or update to phpMyAdmin (5.0.2) (only use this after you have installed the panel)." + output "[19] Install a standalone database host (only for use on daemon-only installations)." + output "[20] Change Pterodactyl theme (0.7.19 Only)." + output "[21] Emergency MariaDB root password reset." + output "[22] Emergency database host information reset." read choice case $choice in 1 ) installoption=1 - output "You have selected 1.0 panel installation only." + output "You have selected 1.0.1 panel installation only." ;; 2 ) installoption=2 output "You have selected 0.7.19 panel installation only." @@ -193,7 +194,7 @@ install_options(){ output "You have selected daemon installation only." ;; 5 ) installoption=5 - output "You have selected 1.0 panel and wings installation." + output "You have selected 1.0.1 panel and wings installation." ;; 6 ) installoption=6 output "You have selected 0.7.19 panel and daemon installation." @@ -202,45 +203,48 @@ install_options(){ output "You have selected to install the standalone SFTP server." ;; 8 ) installoption=8 - output "You have selected to upgrade the panel to 1.0." + output "You have selected to upgrade the panel to 1.0.1." ;; 9 ) installoption=9 - output "You have selected to upgrade the panel to 0.7.19." + output "You have selected to upgrade the panel to 1.0.1." ;; 10 ) installoption=10 - output "You have selected to upgrade the daemon to 0.6.13." + output "You have selected to upgrade the panel to 0.7.19." ;; 11 ) installoption=11 - output "You have selected to migrate daemon to wings." + output "You have selected to upgrade the daemon to 0.6.13." ;; 12 ) installoption=12 - output "You have selected to upgrade both the panel to 1.0 and migrating to wings." + output "You have selected to migrate daemon to wings." ;; 13 ) installoption=13 - output "You have selected to upgrade both the panel to 0.7.19 and daemon to 0.6.13." + output "You have selected to upgrade both the panel to 1.0.1 and migrating to wings." ;; 14 ) installoption=14 - output "You have selected to upgrade the standalone SFTP." + output "You have selected to upgrade both the panel to 0.7.19 and daemon to 0.6.13." ;; 15 ) installoption=15 - output "You have activated mobile app compatibility." + output "You have selected to upgrade the standalone SFTP." ;; 16 ) installoption=16 - output "You have selected to update the mobile app compatibility." + output "You have activated mobile app compatibility." ;; 17 ) installoption=17 - output "You have selected to install or update phpMyAdmin." + output "You have selected to update the mobile app compatibility." ;; 18 ) installoption=18 - output "You have selected to install a Database host." + output "You have selected to install or update phpMyAdmin." ;; 19 ) installoption=19 - output "You have selected to change Pterodactyl's 0.7.19 only." + output "You have selected to install a Database host." ;; 20 ) installoption=20 - output "You have selected MariaDB root password reset." + output "You have selected to change Pterodactyl's 0.7.19 only." ;; 21 ) installoption=21 + output "You have selected MariaDB root password reset." + ;; + 22 ) installoption=22 output "You have selected Database Host information reset." ;; * ) output "You did not enter a valid selection." @@ -749,7 +753,7 @@ install_pterodactyl() { output "Downloading Pterodactyl..." mkdir -p /var/www/pterodactyl cd /var/www/pterodactyl - curl -Lo panel.tar.gz https://github.com/pterodactyl/panel/releases/download/v1.0.0/panel.tar.gz + curl -Lo panel.tar.gz https://github.com/pterodactyl/panel/releases/download/v1.0.1/panel.tar.gz tar -xzvf panel.tar.gz chmod -R 755 storage/* bootstrap/cache/ @@ -958,7 +962,7 @@ EOF upgrade_pterodactyl(){ cd /var/www/pterodactyl php artisan down - curl -L https://github.com/pterodactyl/panel/releases/download/v1.0.0/panel.tar.gz | tar --strip-components=1 -xzv + curl -L https://github.com/pterodactyl/panel/releases/download/v1.0.1/panel.tar.gz | tar --strip-components=1 -xzv chmod -R 755 storage/* bootstrap/cache composer install --no-dev --optimize-autoloader php artisan view:clear @@ -973,7 +977,30 @@ upgrade_pterodactyl(){ semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/pterodactyl/storage(/.*)?" restorecon -R /var/www/pterodactyl fi - output "Your panel has successfully been updated to version 1.0." + output "Your panel has successfully been updated to version 1.0.1" + php artisan up + php artisan queue:restart +} + +upgrade_pterodactyl_1.0(){ + cd /var/www/pterodactyl + php artisan down + curl -L https://github.com/pterodactyl/panel/releases/download/v1.0.1/panel.tar.gz | tar --strip-components=1 -xzv + chmod -R 755 storage/* bootstrap/cache + composer install --no-dev --optimize-autoloader + php artisan view:clear + php artisan config:clear + php artisan migrate --force + php artisan db:seed --force + if [ "$lsb_dist" = "ubuntu" ] || [ "$lsb_dist" = "debian" ]; then + chown -R www-data:www-data * /var/www/pterodactyl + elif [ "$lsb_dist" = "fedora" ] || [ "$lsb_dist" = "centos" ] || [ "$lsb_dist" = "rhel" ]; then + chown -R apache:apache * /var/www/pterodactyl + chown -R nginx:nginx * /var/www/pterodactyl + semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/pterodactyl/storage(/.*)?" + restorecon -R /var/www/pterodactyl + fi + output "Your panel has successfully been updated to version 1.0.1" php artisan up php artisan queue:restart } @@ -2033,43 +2060,45 @@ case $installoption in ;; 8) upgrade_pterodactyl ;; - 9) theme_options + 9) upgrade_pterodactyl_1.0 + ;; + 10) theme_options upgrade_pterodactyl_0.7.19 theme ;; - 10) upgrade_daemon + 11) upgrade_daemon ;; - 11) migrate_wings + 12) migrate_wings ;; - 12) theme_options + 13) theme_options upgrade_pterodactyl_0.7.19 theme migrate_wings ;; - 13) theme_options - upgrade_pterodactyl + 14) theme_options + upgrade_pterodactyl_1.0 theme upgrade_daemon ;; - 14) upgrade_standalone_sftp + 15) upgrade_standalone_sftp ;; - 15) install_mobile + 16) install_mobile ;; - 16) upgrade_mobile + 17) upgrade_mobile ;; - 17) install_phpmyadmin + 18) install_phpmyadmin ;; - 18) repositories_setup + 19) repositories_setup install_database ;; - 19) theme_options + 20) theme_options if [ "$themeoption" = "1" ]; then upgrade_pterodactyl_0.7.19 fi theme ;; - 20) curl -sSL https://raw.githubusercontent.com/tommytran732/MariaDB-Root-Password-Reset/master/mariadb-104.sh | sudo bash + 21) curl -sSL https://raw.githubusercontent.com/tommytran732/MariaDB-Root-Password-Reset/master/mariadb-104.sh | sudo bash ;; - 21) database_host_reset + 22) database_host_reset ;; esac From 3241f4b32e2f91d7e473f02189c07aa2197bc076 Mon Sep 17 00:00:00 2001 From: HeyJack Date: Tue, 13 Oct 2020 05:50:31 +0100 Subject: [PATCH 13/18] Fix 0.7 upgrade to 1.0 --- install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install.sh b/install.sh index 76353e1..283e4ff 100644 --- a/install.sh +++ b/install.sh @@ -986,6 +986,8 @@ upgrade_pterodactyl_1.0(){ cd /var/www/pterodactyl php artisan down curl -L https://github.com/pterodactyl/panel/releases/download/v1.0.1/panel.tar.gz | tar --strip-components=1 -xzv + rm -rf $(find app public resources -depth | head -n -1 | grep -Fv "$(tar -tf panel.tar.gz)") + tar -xzvf panel.tar.gz && rm -f panel.tar.gz chmod -R 755 storage/* bootstrap/cache composer install --no-dev --optimize-autoloader php artisan view:clear From de2a087a957f8ed39b11fda9ada0332d73766df4 Mon Sep 17 00:00:00 2001 From: HeyJack Date: Thu, 15 Oct 2020 15:41:34 +0100 Subject: [PATCH 14/18] Fix Firewall Ports --- install.sh | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 283e4ff..f1c85e5 100644 --- a/install.sh +++ b/install.sh @@ -1838,10 +1838,24 @@ EOF ufw allow 443 ufw allow 3306 elif [ "$installoption" = "2" ]; then + ufw allow 80 + ufw allow 443 + ufw allow 3306 + elif [ "$installoption" = "3" ]; then ufw allow 80 ufw allow 8080 ufw allow 2022 - elif [ "$installoption" = "3" ]; then + elif [ "$installoption" = "4" ]; then + ufw allow 80 + ufw allow 8080 + ufw allow 2022 + elif [ "$installoption" = "5" ]; then + ufw allow 80 + ufw allow 443 + ufw allow 8080 + ufw allow 2022 + ufw allow 3306 + elif [ "$installoption" = "6" ]; then ufw allow 80 ufw allow 443 ufw allow 8080 @@ -1856,17 +1870,31 @@ EOF if [ "$installoption" = "1" ]; then firewall-cmd --add-service=http --permanent firewall-cmd --add-service=https --permanent - firewall-cmd --add-service=mysql --permanent + firewall-cmd --add-service=mysql --permanent elif [ "$installoption" = "2" ]; then + firewall-cmd --add-service=http --permanent + firewall-cmd --add-service=https --permanent + firewall-cmd --add-service=mysql --permanent + elif [ "$installoption" = "3" ]; then firewall-cmd --permanent --add-service=80/tcp firewall-cmd --permanent --add-port=2022/tcp firewall-cmd --permanent --add-port=8080/tcp - elif [ "$installoption" = "3" ]; then + elif [ "$installoption" = "4" ]; then + firewall-cmd --permanent --add-service=80/tcp + firewall-cmd --permanent --add-port=2022/tcp + firewall-cmd --permanent --add-port=8080/tcp + elif [ "$installoption" = "5" ]; then 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 - firewall-cmd --permanent --add-service=mysql + firewall-cmd --permanent --add-service=mysql + elif [ "$installoption" = "6" ]; then + 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 + firewall-cmd --permanent --add-service=mysql fi fi } From cc3f2d9888bd9663462376d43a3cac31a3df9f0e Mon Sep 17 00:00:00 2001 From: HeyJack Date: Thu, 15 Oct 2020 16:04:38 +0100 Subject: [PATCH 15/18] Fix NGINX 443 --- install.sh | 73 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 19 deletions(-) diff --git a/install.sh b/install.sh index f1c85e5..af62008 100644 --- a/install.sh +++ b/install.sh @@ -1036,33 +1036,66 @@ nginx_config() { output "Configuring Nginx Webserver..." echo ' +server_tokens off; +set_real_ip_from 103.21.244.0/22; +set_real_ip_from 103.22.200.0/22; +set_real_ip_from 103.31.4.0/22; +set_real_ip_from 104.16.0.0/12; +set_real_ip_from 108.162.192.0/18; +set_real_ip_from 131.0.72.0/22; +set_real_ip_from 141.101.64.0/18; +set_real_ip_from 162.158.0.0/15; +set_real_ip_from 172.64.0.0/13; +set_real_ip_from 173.245.48.0/20; +set_real_ip_from 188.114.96.0/20; +set_real_ip_from 190.93.240.0/20; +set_real_ip_from 197.234.240.0/22; +set_real_ip_from 198.41.128.0/17; +set_real_ip_from 2400:cb00::/32; +set_real_ip_from 2606:4700::/32; +set_real_ip_from 2803:f800::/32; +set_real_ip_from 2405:b500::/32; +set_real_ip_from 2405:8100::/32; +set_real_ip_from 2c0f:f248::/32; +set_real_ip_from 2a06:98c0::/29; +real_ip_header X-Forwarded-For; server { - listen 80; + listen 80 default_server; + server_name '"$FQDN"'; + return 301 https://$server_name$request_uri; +} +server { + listen 443 ssl http2 default_server; server_name '"$FQDN"'; - root /var/www/pterodactyl/public; - index index.html index.htm index.php; - charset utf-8; - - location / { - try_files $uri $uri/ /index.php?$query_string; - } - - location = /favicon.ico { access_log off; log_not_found off; } - location = /robots.txt { access_log off; log_not_found off; } - - access_log off; + index index.php; + access_log /var/log/nginx/pterodactyl.app-access.log; error_log /var/log/nginx/pterodactyl.app-error.log error; - # allow larger file uploads and longer script runtimes client_max_body_size 100m; client_body_timeout 120s; - sendfile off; - + # SSL Configuration + ssl_certificate /etc/letsencrypt/live/'"$FQDN"'/fullchain.pem;- + ssl_certificate_key /etc/letsencrypt/live/'"$FQDN"'/privkey.pem; + ssl_session_cache shared:SSL:10m; + ssl_protocols TLSv1.2; + ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256'; + ssl_prefer_server_ciphers on; + # See https://hstspreload.org/ before uncommenting the line below. + # add_header Strict-Transport-Security "max-age=15768000; preload;"; + 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; + } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass unix:/run/php/php7.4-fpm.sock; + fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param PHP_VALUE "upload_max_filesize = 100M \n post_max_size=100M"; @@ -1074,12 +1107,12 @@ server { fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; + include /etc/nginx/fastcgi_params; } - location ~ /\.ht { deny all; } -}} +} ' | sudo -E tee /etc/nginx/sites-available/pterodactyl.conf >/dev/null 2>&1 if [ "$lsb_dist" = "debian" ] && [ "$dist_version" = "8" ]; then sed -i 's/http2//g' /etc/nginx/sites-available/pterodactyl.conf @@ -1399,6 +1432,7 @@ webserver_config(){ setup_pterodactyl(){ install_dependencies install_pterodactyl + ssl_certs webserver_config } @@ -2073,6 +2107,7 @@ case $installoption in repositories_setup required_infos firewall + ssl_certs setup_pterodactyl install_wings broadcast From b4a75e8c1bf0c6324ff48fa7e7bb8d22a7fce6e8 Mon Sep 17 00:00:00 2001 From: HeyJack Date: Thu, 15 Oct 2020 16:10:22 +0100 Subject: [PATCH 16/18] Move some SSL setup stuff around and that --- install.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index af62008..535ab78 100644 --- a/install.sh +++ b/install.sh @@ -1784,8 +1784,7 @@ ssl_certs(){ fi elif [ "$installoption" = "3" ]; then (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "ufw allow 80" --pre-hook "service wings stop" --post-hook "ufw deny 80" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - - elif [ "$installoption" = "3" ]; then - if [ "$webserver" = "1" ]; then + elif [ "$installoption" = "4" ]; then (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "ufw allow 80" --pre-hook "service wings stop" --post-hook "ufw deny 80" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - fi elif [ "$installoption" = "5" ]; then @@ -2127,11 +2126,11 @@ case $installoption in ;; 9) upgrade_pterodactyl_1.0 ;; - 10) theme_options + 10) theme_options upgrade_pterodactyl_0.7.19 theme ;; - 11) upgrade_daemon + 11) upgrade_daemon ;; 12) migrate_wings ;; From 00b223140455d00fe159026d8f621e55e7581d21 Mon Sep 17 00:00:00 2001 From: HeyJack Date: Thu, 15 Oct 2020 16:23:52 +0100 Subject: [PATCH 17/18] Remade Certbot Install --- install.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 535ab78..6d83a37 100644 --- a/install.sh +++ b/install.sh @@ -1769,7 +1769,7 @@ ssl_certs(){ fi fi - if [ "$lsb_dist" = "debian" ] || [ "$lsb_dist" = "ubuntu" ]; then + if [ "$lsb_dist" = "debian" ] || [ "$lsb_dist" = "ubuntu" ]; then if [ "$installoption" = "1" ]; then if [ "$webserver" = "1" ]; then (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service nginx stop" --post-hook "service nginx restart" >> /dev/null 2>&1')| crontab - @@ -1783,10 +1783,9 @@ ssl_certs(){ (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service apache2 stop" --post-hook "service apache2 restart" >> /dev/null 2>&1')| crontab - fi elif [ "$installoption" = "3" ]; then - (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "ufw allow 80" --pre-hook "service wings stop" --post-hook "ufw deny 80" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - + (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "ufw allow 80" --pre-hook "service wings stop" --post-hook "ufw deny 80" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - elif [ "$installoption" = "4" ]; then - (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "ufw allow 80" --pre-hook "service wings stop" --post-hook "ufw deny 80" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - - fi + (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "ufw allow 80" --pre-hook "service wings stop" --post-hook "ufw deny 80" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - elif [ "$installoption" = "5" ]; then if [ "$webserver" = "1" ]; then (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service nginx stop" --pre-hook "service wings stop" --post-hook "service nginx restart" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - @@ -1799,7 +1798,7 @@ ssl_certs(){ elif [ "$webserver" = "2" ]; then (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service apache2 stop" --pre-hook "service wings stop" --post-hook "service apache2 restart" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - fi - fi + fi elif [ "$lsb_dist" = "fedora" ] || [ "$lsb_dist" = "centos" ] || [ "$lsb_dist" = "rhel" ]; then if [ "$installoption" = "1" ]; then if [ "$webserver" = "1" ]; then @@ -1823,13 +1822,18 @@ ssl_certs(){ elif [ "$webserver" = "2" ]; then (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service httpd stop" --pre-hook "service wings stop" --post-hook "service httpd restart" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - fi - elif [ "$installoption" = "6" ]; then + elif [ "$installoption" = "5" ]; then + if [ "$webserver" = "1" ]; then + (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service nginx stop" --pre-hook "service wings stop" --post-hook "service nginx restart" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - + elif [ "$webserver" = "2" ]; then + (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service httpd stop" --pre-hook "service wings stop" --post-hook "service httpd restart" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - + fi + elif [ "$installoption" = "6" ]; then if [ "$webserver" = "1" ]; then (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service nginx stop" --pre-hook "service wings stop" --post-hook "service nginx restart" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - elif [ "$webserver" = "2" ]; then (crontab -l ; echo '0 0,12 * * * certbot renew --pre-hook "service httpd stop" --pre-hook "service wings stop" --post-hook "service httpd restart" --post-hook "service wings restart" >> /dev/null 2>&1')| crontab - fi - fi fi } From 5b70c3fd89e7bcd8883276af977f2810818ad662 Mon Sep 17 00:00:00 2001 From: HeyJack Date: Thu, 15 Oct 2020 16:52:59 +0100 Subject: [PATCH 18/18] Remove random - Ready for PR --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 6d83a37..93c8ce4 100644 --- a/install.sh +++ b/install.sh @@ -1076,7 +1076,7 @@ server { client_body_timeout 120s; sendfile off; # SSL Configuration - ssl_certificate /etc/letsencrypt/live/'"$FQDN"'/fullchain.pem;- + ssl_certificate /etc/letsencrypt/live/'"$FQDN"'/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/'"$FQDN"'/privkey.pem; ssl_session_cache shared:SSL:10m; ssl_protocols TLSv1.2;