Advertisement
Guest User

install.sh.x | Dumped

a guest
Oct 23rd, 2019
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 77.17 KB | None | 0 0
  1. output(){
  2.     echo -e '\e[36m'$1'\e[0m';
  3. warn(){
  4.     echo -e '\e[31m'$1'\e[0m';
  5. version=v1.23
  6. preflight(){
  7.     output "Pterodactyl Installation & Upgrade script ${version}"
  8.     output "Copyright
  9. 2019 Thien Tran <thientran@securesrv.io>."
  10.     output "Please report any issues or copyright violations to https://securesrv.io/discord"
  11.     output ""
  12.     output "Thank you for your purchase. Please note that this script is meant to be installed on a fresh OS. Installing it on a non-fresh OS may cause problems."
  13.     output "Automatic Operating System Detection initialized."
  14.     if [ -r /etc/os-release ]; then
  15.         lsb_dist="$(. /etc/os-release && echo "$ID")"
  16.         dist_version="$(. /etc/os-release && echo "$VERSION_ID")"
  17.     else
  18.         exit 1
  19.     fi
  20.     output "OS: $lsb_dist $dist_version detected."
  21.     output ""
  22.     if [ "$lsb_dist" =  "ubuntu" ]; then
  23.         if [ "$dist_version" != "19.04" ] && [ "$dist_version" != "18.04" ] && [ "$dist_version" != "16.04" ]; then
  24.             output "Unsupported Ubuntu version. Only Ubuntu 19.04, 18.04, 16.04 are supported."
  25.             exit 2
  26.         fi
  27.     elif [ "$lsb_dist" = "debian" ]; then
  28.         if [ "$dist_version" != "10" ] &&[ "$dist_version" != "9" ] && [ "$dist_version" != "8" ]; then
  29.             output "Unsupported Debian version. Only Debian 10, 9 and 8 are supported.."
  30.             exit 2
  31.         fi
  32.     elif [ "$lsb_dist" = "fedora" ]; then
  33.         if [ "$dist_version" != "30" ] && [ "$dist_version" != "29" ]; then
  34.             output "Unsupported Fedora version. Only Fedora 30 and 29 are supported."
  35.             exit 2
  36.         fi
  37.     elif [ "$lsb_dist" = "centos" ]; then
  38.         if [ "$dist_version" != "7" ]; then
  39.             output "Unsupported CentOS version. Only CentOS 7 are supported."
  40.             exit 2
  41.         fi
  42.     elif [ "$lsb_dist" = "rhel" ]; then
  43.         if [ "$dist_version" != "7" ]&&[ "$dist_version" != "7.1" ]&&[ "$dist_version" != "7.2" ]&&[ "$dist_version" != "7.3" ]&&[ "$dist_version" != "7.4" ]&&[ "$dist_version" != "7.5" ]&&[ "$dist_version" != "7.6" ]; then
  44.             output "Unsupported RHEL version. Only RHEL 7 is supported."
  45.             exit 2
  46.         fi
  47.     elif [ "$lsb_dist" != "ubuntu" ] && [ "$lsb_dist" != "debian" ] && [ "$lsb_dist" != "centos" ] && [ "$lsb_dist" != "rhel" ]; then
  48.         output "Unsupported Operating System."
  49.         output ""
  50.         output "Supported OS:"
  51.         output "Ubuntu: 19.04, 18.04, 16.04"
  52.         output "Debian: 10, 9, 8"
  53.         output "Fedora: 30, 29"
  54.         output "CentOS: 7"
  55.         output "RHEL: 7"
  56.         exit 2
  57.     fi
  58.     if [ "$EUID" -ne 0 ]; then
  59.         output "Please run as root."
  60.         exit 3
  61.     fi
  62.     output "Automatic Architecture Detection initialized."
  63.     MACHINE_TYPE=`uname -m`
  64.     if [ ${MACHINE_TYPE} == 'x86_64' ]; then
  65.         output "64-bit server detected! Good to go."
  66.         output ""
  67.     else
  68.         output "Unsupported architecture detected! Please switch to 64-bit (x86_64)."
  69.         exit 4
  70.     fi
  71.     output "Automatic Virtualization Detection initialized."
  72.     if [ "$lsb_dist" =  "ubuntu" ]; then
  73.         apt-get update --fix-missing
  74.         apt-get -y install software-properties-common
  75.         add-apt-repository -y universe
  76.         apt-get -y install virt-what
  77.     elif [ "$lsb_dist" =  "debian" ]; then
  78.         apt update --fix-missing
  79.         apt-get -y install software-properties-common virt-what wget
  80.     elif [ "$lsb_dist" =  "fedora" ] || [ "$lsb_dist" =  "centos" ] || [ "$lsb_dist" =  "rhel" ]; then
  81.         yum -y install virt-what wget
  82.     fi
  83.     virt_serv=$(echo $(virt-what))
  84.     if [ "$virt_serv" = "" ]; then
  85.         output "Virtualization: Bare Metal detected."
  86.     elif [ "$virt_serv" = "openvz lxc" ]; then
  87.         output "Virtualization: OpenVZ 7 detected."
  88.     elif [ "$virt_serv" = "xen xen-hvm" ]; then
  89.         output "Virtualization: Xen-HVM detected."
  90.     elif [ "$virt_serv" = "xen xen-hvm aws" ]; then
  91.         output "Virtualization: Xen-HVM on AWS detected."
  92.         warn "When doing allocation for the node, please use the internal ip as Google Cloud uses NAT."
  93.         warn "Resuming in 10 seconds."
  94.         sleep 10
  95.     else
  96.         output "Virtualization: $virt_serv detected."
  97.     fi
  98.     output ""
  99.     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
  100.         warn "Unsupported Virtualization method. Please consult with your provider whether your server can run Docker or not. Proceed at your own risk."
  101.         warn "No support would be given if your server breaks at any point in the future."
  102.         warn "Proceed?\n[1] Yes.\n[2] No."
  103.         read choice
  104.         case $choice in
  105.             1)  output "Proceeding..."
  106.                 ;;
  107.             2)  output "Cancelling installation..."
  108.                 exit 5
  109.                 ;;
  110.         esac
  111.         output ""
  112.     fi
  113.     output "Kernel Detection Initialized."
  114.     if echo $(uname -r) | grep -q xxxx; then
  115.         output "OVH Kernel Detected. The script will not work. Please install your server with a generic/distribution kernel."
  116.         output "When you are reinstalling your server, click on 'custom installation' and click on 'use distribution' kernel after that."
  117.         output "You might also want to do custom partritioning, remove the /home partrition and give / all the remaining space."
  118.         output "Please do not hesitate to contact us if you need help regarding this issue."
  119.         exit 6
  120.     elif echo $(uname -r) | grep -q pve; then
  121.         output "Proxmox LXE Kernel Detected. You have chosen to continue in the last step, therefore we are proceeding at your own risk."
  122.         output "Proceeding with a risky operation..."
  123.     elif echo $(uname -r) | grep -q stab; then
  124.         if echo $(uname -r) | grep -q 2.6; then
  125.             output "OpenVZ 6 detected. This server will definitely not work with Docker, regardless of what your provider might say. Exiting to avoid further damages."
  126.             exit 6
  127.         fi
  128.     elif echo $(uname -r) | grep -q gcp; then
  129.         output "Google Cloud Platform Detected."
  130.         warn "Please make sure you have static ip setup, otherwise the system will not work after a reboot."
  131.         warn "Please also make sure the google firewall allows the ports needed for the server to function normally."
  132.         warn "When doing allocation for the node, please use the internal ip as Google Cloud uses NAT."
  133.         warn "Resuming in 10 seconds."
  134.         sleep 10
  135.     else
  136.         output "Did not detect any bad kernel. Moving forward."
  137.         output ""
  138.     fi
  139.     output "Checking for updates..."
  140.     wget https://mirrors.securesrv.io >/dev/null 2>&1
  141.     if grep -q "${version}" index.html; then
  142.         output "Up to date, good to go!"
  143.         output ""
  144.         rm -rf index.html
  145.     else
  146.         output "Outdated script, please use the latest version. If you believe this is an error, please contact us on Discord."
  147.         output "If you happen to be using one of the pirated version of the script, please buy the resource to support the author. We accept both paypal and cryptocurrencies."
  148.         rm -rf index.html
  149.         exit 69
  150.     fi
  151. install_options(){
  152.     output "Please select your installation option:"
  153.     output "[1] Install the panel."
  154.     output "[2] Install the daemon."
  155.     output "[3] Install the panel and daemon."
  156.     output "[4] Install the standalone SFTP server."
  157.     output "[5] Upgrade 0.7.x panel to 0.7.15."
  158.     output "[6] Upgrade 0.6.x daemon to 0.6.12."
  159.     output "[7] Upgrade the panel to 0.7.15 and daemon to 0.6.12"
  160.     output "[8] Upgrade the standalone SFTP server to 1.0.4."
  161.     output "[9] Make Pterodactyl compatible with the mobile app. (Only use this after you have installed the panel. Check out https://pterodactyl.cloud for the mobile app.)"
  162.     output "[10] Update Mobile compatibility."
  163.     output "[11] Install or Update to phpMyAdmin 4.9.1 (Only use this after you have installed the panel.)"
  164.     output "[12] Change Pterodactyl theme."
  165.     output "[13] Emergency MariaDB root password reset."
  166.     output "[14] Emergency Database host information reset."
  167.     read choice
  168.     case $choice in
  169.         1 ) installoption=1
  170.             output "You have selected panel installation only."
  171.             ;;
  172.         2 ) installoption=2
  173.             output "You have selected daemon installation only."
  174.             ;;
  175.         3 ) installoption=3
  176.             output "You have selected panel and daemon installation."
  177.             ;;
  178.         4 ) installoption=4
  179.             output "You have selected to install the standalone SFTP server."
  180.             ;;
  181.         5 ) installoption=5
  182.             output "You have selected to upgrade the panel."
  183.             ;;
  184.         6 ) installoption=6
  185.             output "You have selected to upgrade the daemon."
  186.             ;;
  187.         7 ) installoption=7
  188.             output "You have selected to upgrade both the panel and daemon."
  189.             ;;
  190.         8 ) installoption=8
  191.             output "You have selected to upgrade the standalone SFTP."
  192.             ;;
  193.         9 ) installoption=9
  194.             output "You have activated mobile app compatibility."
  195.             ;;
  196.         10 ) installoption=10
  197.             output "you have selected to update the mobile app compatibility."
  198.             ;;
  199.         11 ) installoption=11
  200.             output "You have selected to install or update phpMyAdmin."
  201.             ;;
  202.         12 ) installoption=12
  203.             output "You have selected to change Pterodactyl's theme."
  204.             ;;
  205.         13 ) installoption=13
  206.             output "You have selected MariaDB root password reset."
  207.             ;;
  208.         14 ) installoption=14
  209.             output "You have selected Database Host information reset."
  210.             ;;
  211.         * ) output "You did not enter a valid selection."
  212.             install_options
  213.     esac
  214. webserver_options() {
  215.     output "Please select which web server you would like to use:\n[1] Nginx (Recommended).\n[2] Apache2/Httpd."
  216.     read choice
  217.     case $choice in
  218.         1 ) webserver=1
  219.             output "You have selected Nginx."
  220.             output ""
  221.             ;;
  222.         2 ) webserver=2
  223.             output "You have selected Apache2 / Httpd."
  224.             output ""
  225.             ;;
  226.         * ) output "You did not enter a valid selection."
  227.             webserver_options
  228.     esac
  229. database_options(){
  230.     if [ "$lsb_dist" =  "debian" ] && [ "$dist_version" = "10" ]; then
  231.         db=mariadb
  232.     else
  233.         output "Please select your database version:"
  234.         output "[1] MariaDB 10.4 (Recommended)."
  235.         output "[2] MySQL 5.7."
  236.         read database
  237.         case $database in
  238.             1 ) db=mariadb
  239.                 output "You have selected to install MariaDB 10.4."
  240.                 output ""
  241.                 ;;
  242.             2 ) if [ "$lsb_dist" =  "ubuntu" ] || [ "$lsb_dist" =  "debian" ]; then
  243.                     db=mysql
  244.                 elif [ "$lsb_dist" =  "fedora" ] || [ "$lsb_dist" =  "centos" ] || [ "$lsb_dist" =  "rhel" ]; then
  245.                     db=mysql-community
  246.                 fi
  247.                 output "You have selected to install MySQL 5.7."
  248.                 output ""
  249.                 ;;      
  250.             * ) output "You did not enter a a valid selection."
  251.                 database_options
  252.         esac
  253.     fi
  254. theme_options() {
  255.     output "Would you like to install Fonix's themes?"
  256.     output "[1] No."
  257.     output "[2] Tango Twist."
  258.     output "[3] Blue Brick."
  259.     output "[4] Minecraft Madness."
  260.     output "[5] Lime Stitch."
  261.     output "[6] Red Ape."
  262.     output "[7] BlackEnd Space."
  263.     output "[8] Nothing But Graphite."
  264.     output ""
  265.     output "You can find out about Fonix's themes here: https://github.com/TheFonix/Pterodactyl-Themes"
  266.     read choice
  267.     case $choice in
  268.         1 ) themeoption=1
  269.             output "You have selected to install vanilla Pterodactyl theme."
  270.             output ""
  271.             ;;
  272.         2 ) themeoption=2
  273.             output "You have selected to install Fonix's Tango Twist theme."
  274.             output ""
  275.             ;;
  276.         3 ) themeoption=3
  277.             output "You have selected to install Fonix's Blue Brick theme."
  278.             output ""
  279.             ;;
  280.         4 ) themeoption=4
  281.             output "You have selected to install Fonix's Minecraft Madness theme."
  282.             output ""
  283.             ;;
  284.         5 ) themeoption=5
  285.             output "You have selected to install Fonix's Lime Stitch theme."
  286.             output ""
  287.             ;;
  288.         6 ) themeoption=6
  289.             output "You have selected to install Fonix's Red Ape theme."
  290.             output ""
  291.             ;;
  292.         7 ) themeoption=7
  293.             output "You have selected to install Fonix's BlackEnd Space theme."
  294.             output ""
  295.             ;;
  296.         8 ) themeoption=8
  297.             output "You have selected to install Fonix's Nothing But Graphite theme."
  298.             output ""
  299.             ;;        
  300.         * ) output "You did not enter a a valid selection."
  301.             theme_options
  302.     esac
  303. }  
  304. required_infos() {
  305.     output "Please enter the desired user email address:"
  306.     read email
  307.     dns_check
  308. ssl_option(){
  309.     output "Do you want to use SSL? [Y/n]: "
  310.     output "If you have a domain, please set it to 'yes' for maximum security."
  311.     output "If you choose 'no', the server will be accessible via the IP without SSL. Please keep in mind this is HIGHLY INSECURE and is NOT RECOMMENDED!"
  312.     output "If you panel has SSL, your daemon must have SSL as well."
  313.     read RESPONSE
  314.     USE_SSL=true
  315.     if [[ "${RESPONSE}" =~ ^([nN][oO]|[nN])+$ ]]; then
  316.         USE_SSL=false
  317.     fi
  318.     if [ $USE_SSL = "true" ]; then
  319.         dns_check
  320.     fi
  321. dns_check(){
  322.     output "Please enter your FQDN (panel.yourdomain.com):"
  323.     read FQDN
  324.     if [[ "${FQDN}" == *falixnode* ]] || [[ "${FQDN}" == *bjncloud* ]]; then
  325.         output "Blacklisted Domain."
  326.         exit 96
  327.     fi
  328.     output "Resolving DNS."
  329.     SERVER_IP=$(curl -s http://checkip.amazonaws.com)
  330.     DOMAIN_RECORD=$(dig +short ${FQDN})
  331.     if [ "${SERVER_IP}" != "${DOMAIN_RECORD}" ]; then
  332.         output ""
  333.         output "The entered domain does not resolve to the primary public IP of this server."
  334.         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.yourdomain.tld"
  335.         output "If you are using Cloudflare, please disable the orange cloud."
  336.         output "If you do not have a domain, you can get a free one at https://www.freenom.com/en/index.html?lang=en."
  337.         dns_check
  338.     else
  339.         output "Domain resolved correctly. Good to go."
  340.     fi
  341. theme() {
  342.     output "Theme installation initialized."
  343.     cd /var/www/pterodactyl
  344.     if [ "$themeoption" = "1" ]; then
  345.         output "Keeping Pterodactyl's vanilla theme."
  346.     elif [ "$themeoption" = "2" ]; then
  347.         curl https://raw.githubusercontent.com/TheFonix/Pterodactyl-Themes/master/MasterThemes/TangoTwist/build.sh | sh
  348.     elif [ "$themeoption" = "3" ]; then
  349.         curl https://raw.githubusercontent.com/TheFonix/Pterodactyl-Themes/master/MasterThemes/BlueBrick/build.sh | sh
  350.     elif [ "$themeoption" = "4" ]; then
  351.         curl https://raw.githubusercontent.com/TheFonix/Pterodactyl-Themes/master/MasterThemes/MinecraftMadness/build.sh | sh
  352.     elif [ "$themeoption" = "5" ]; then
  353.         curl https://raw.githubusercontent.com/TheFonix/Pterodactyl-Themes/master/MasterThemes/LimeStitch/build.sh | sh
  354.     elif [ "$themeoption" = "6" ]; then
  355.         curl https://raw.githubusercontent.com/TheFonix/Pterodactyl-Themes/master/MasterThemes/RedApe/build.sh | sh
  356.     elif [ "$themeoption" = "7" ]; then
  357.         curl https://raw.githubusercontent.com/TheFonix/Pterodactyl-Themes/master/MasterThemes/BlackEndSpace/build.sh | sh
  358.     elif [ "$themeoption" = "8" ]; then
  359.         curl https://raw.githubusercontent.com/TheFonix/Pterodactyl-Themes/master/MasterThemes/NothingButGraphite/build.sh | sh
  360.     fi
  361.     php artisan view:clear
  362.     php artisan cache:clear
  363. repositories_setup(){
  364.     output "Configuring your repositories."
  365.     if [ "$lsb_dist" =  "ubuntu" ] || [ "$lsb_dist" =  "debian" ]; then
  366.         apt-get -y install sudo
  367.         apt-get -y install software-properties-common iptables
  368.         echo 'Acquire::ForceIPv4 "true";' | sudo tee /etc/apt/apt.conf.d/99force-ipv4
  369.         apt-get -y update
  370.         if [ "$lsb_dist" =  "ubuntu" ]; then
  371.             LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
  372.             add-apt-repository -y ppa:chris-lea/redis-server
  373.             add-apt-repository -y ppa:certbot/certbot
  374.             add-apt-repository -y ppa:nginx/development
  375.             if [ "$dist_version" = "19.04" ]; then
  376.                 sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
  377.                 if [ "$db" = "mariadb"  ]; then
  378.                     sudo add-apt-repository 'deb [arch=amd64] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.4/ubuntu disco main'
  379.                 fi
  380.                 apt -y install tuned
  381.                 tuned-adm profile latency-performance
  382.             elif [ "$dist_version" = "18.10" ]; then
  383.                 apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
  384.                 if [ "$db" = "mariadb"  ]; then
  385.                     add-apt-repository 'deb [arch=amd64] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.3/ubuntu cosmic main'
  386.                 fi
  387.                 apt -y install tuned
  388.                 tuned-adm profile latency-performance
  389.             elif [ "$dist_version" = "18.04" ]; then
  390.                 apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
  391.                 if [ "$db" = "mariadb"  ]; then
  392.                     add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.4/ubuntu bionic main'
  393.                 fi
  394.                 apt -y install tuned
  395.                 tuned-adm profile latency-performance
  396.             elif [ "$dist_version" = "16.04" ]; then
  397.                 sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
  398.                 if [ "$db" = "mariadb"  ]; then
  399.                     sudo add-apt-repository 'deb [arch=amd64,arm64,i386,ppc64el] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.4/ubuntu xenial main'
  400.                 fi
  401.                 apt -y install tuned
  402.                 tuned-adm profile latency-performance  
  403.             fi
  404.         elif [ "$lsb_dist" =  "debian" ]; then
  405.             apt-get -y install ca-certificates apt-transport-https
  406.             echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
  407.             if [ "$dist_version" = "10" ]; then
  408.                 apt -y install software-properties-common dirmngr
  409.                 wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
  410.                 if [ "$db" = "mariadb"  ]; then
  411.                     sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
  412.                     sudo add-apt-repository 'deb [arch=amd64] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.4/debian buster main'
  413.                 fi
  414.                 apt -y install tuned
  415.                 tuned-adm profile latency-performance
  416.             elif [ "$dist_version" = "9" ]; then
  417.                 apt -y install software-properties-common dirmngr
  418.                 wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
  419.                 if [ "$db" = "mariadb"  ]; then
  420.                     sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
  421.                     sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.4/debian stretch main'
  422.                 fi
  423.             elif [ "$dist_version" = "8" ]; then
  424.                 apt -y install software-properties-common
  425.                 wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
  426.                 if [ "$db" = "mariadb"  ]; then
  427.                     sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
  428.                     sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.4/debian jessie main'
  429.                 fi
  430.             fi
  431.         fi
  432.         apt-get -y update
  433.         apt-get -y upgrade
  434.         apt-get -y autoremove
  435.         apt-get -y autoclean  
  436.         apt-get -y install dnsutils curl
  437.     elif  [ "$lsb_dist" =  "fedora" ] || [ "$lsb_dist" =  "centos" ] || [ "$lsb_dist" =  "rhel" ]; then
  438.         if  [ "$lsb_dist" =  "fedora" ] && [ "$dist_version" = "30" ]; then
  439.             bash -c 'cat > /etc/yum.repos.d/nginx.repo' <<-'EOF'
  440. [heffer-nginx-mainline]
  441. name=Copr repo for nginx-mainline owned by heffer
  442. baseurl=https://copr-be.cloud.fedoraproject.org/results/heffer/nginx-mainline/fedora-$releasever-$basearch/
  443. type=rpm-md
  444. skip_if_unavailable=True
  445. gpgcheck=1
  446. gpgkey=https://copr-be.cloud.fedoraproject.org/results/heffer/nginx-mainline/pubkey.gpg
  447. repo_gpgcheck=0
  448. enabled=1
  449. enabled_metadata=1
  450.             if [ "$db" = "mariadb"  ]; then
  451.                 bash -c 'cat > /etc/yum.repos.d/mariadb.repo' <<-'EOF'
  452. [mariadb]
  453. name = MariaDB
  454. baseurl = http://yum.mariadb.org/10.4/fedora30-amd64
  455. gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
  456. gpgcheck=1
  457.             fi
  458.             if [ "$db" = "mysql-community"  ]; then
  459.                 dnf install https://dev.mysql.com/get/mysql80-community-release-fc30-1.noarch.rpm
  460.                 dnf config-manager --set-disabled mysql80-community
  461.                 dnf config-manager --set-enabled mysql57-community
  462.             fi    
  463.             dnf -y install  http://rpms.remirepo.net/fedora/remi-release-30.rpm
  464.             dnf -y install dnf-plugins-core
  465.             dnf config-manager --set-enabled remi-php73
  466.             dnf config-manager --set-enabled remi
  467.         elif  [ "$lsb_dist" =  "fedora" ] && [ "$dist_version" = "29" ]; then
  468.             bash -c 'cat > /etc/yum.repos.d/nginx.repo' <<-'EOF'
  469. [heffer-nginx-mainline]
  470. name=Copr repo for nginx-mainline owned by heffer
  471. baseurl=https://copr-be.cloud.fedoraproject.org/results/heffer/nginx-mainline/fedora-$releasever-$basearch/
  472. type=rpm-md
  473. skip_if_unavailable=True
  474. gpgcheck=1
  475. gpgkey=https://copr-be.cloud.fedoraproject.org/results/heffer/nginx-mainline/pubkey.gpg
  476. repo_gpgcheck=0
  477. enabled=1
  478. enabled_metadata=1
  479.             if [ "$db" = "mariadb"  ]; then
  480.                 bash -c 'cat > /etc/yum.repos.d/mariadb.repo' <<-'EOF'
  481. [mariadb]
  482. name = MariaDB
  483. baseurl = http://yum.mariadb.org/10.4/fedora29-amd64
  484. gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
  485. gpgcheck=1
  486.             fi
  487.             if [ "$db" = "mysql-community"  ]; then
  488.                 dnf install https://dev.mysql.com/get/mysql80-community-release-fc29-2.noarch.rpm
  489.                 dnf config-manager --set-disabled mysql80-community
  490.                 dnf config-manager --set-enabled mysql57-community
  491.             fi
  492.             dnf -y install  http://rpms.remirepo.net/fedora/remi-release-29.rpm
  493.             dnf -y install dnf-plugins-core
  494.             dnf config-manager --set-enabled remi-php73
  495.             dnf config-manager --set-enabled remi
  496.         elif  [ "$lsb_dist" =  "centos" ] && [ "$dist_version" = "7" ]; then
  497.             bash -c 'cat > /etc/yum.repos.d/nginx.repo' <<-'EOF'
  498. [heffer-nginx-mainline]
  499. name=Copr repo for nginx-mainline owned by heffer
  500. baseurl=https://copr-be.cloud.fedoraproject.org/results/heffer/nginx-mainline/epel-7-$basearch/
  501. type=rpm-md
  502. skip_if_unavailable=True
  503. gpgcheck=1
  504. gpgkey=https://copr-be.cloud.fedoraproject.org/results/heffer/nginx-mainline/pubkey.gpg
  505. repo_gpgcheck=0
  506. enabled=1
  507. enabled_metadata=1
  508.             if [ "$db" = "mariadb"  ]; then
  509.                 bash -c 'cat > /etc/yum.repos.d/mariadb.repo' <<-'EOF'
  510. [mariadb]
  511. name = MariaDB
  512. baseurl = http://yum.mariadb.org/10.4/centos7-amd64
  513. gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
  514. gpgcheck=1
  515.             fi
  516.             yum -y install epel-release
  517.             yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
  518.         elif  [ "$lsb_dist" =  "rhel" ]; then
  519.             bash -c 'cat > /etc/yum.repos.d/nginx.repo' <<-'EOF'
  520. [heffer-nginx-mainline]
  521. name=Copr repo for nginx-mainline owned by heffer
  522. baseurl=https://copr-be.cloud.fedoraproject.org/results/heffer/nginx-mainline/epel-7-$basearch/
  523. type=rpm-md
  524. skip_if_unavailable=True
  525. gpgcheck=1
  526. gpgkey=https://copr-be.cloud.fedoraproject.org/results/heffer/nginx-mainline/pubkey.gpg
  527. repo_gpgcheck=0
  528. enabled=1
  529. enabled_metadata=1
  530.             if [ "$db" = "mariadb"  ]; then
  531.                 bash -c 'cat > /etc/yum.repos.d/mariadb.repo' <<-'EOF'        
  532. [mariadb]
  533. name = MariaDB
  534. baseurl = http://yum.mariadb.org/10.4/rhel7-ppc64le
  535. gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
  536. gpgcheck=1
  537.             fi
  538.             yum -y install epel-release
  539.             yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
  540.            
  541.         fi
  542.         yum -y install yum-utils tuned iptables policycoreutils-python
  543.         tuned-adm profile latency-performance
  544.         yum-config-manager --enable remi-php73
  545.         yum -y upgrade
  546.         yum -y autoremove
  547.         yum -y clean packages
  548.         yum -y install curl bind-utils
  549.     fi
  550. install_dependencies(){
  551.     output "Installing dependencies."
  552.     if  [ "$lsb_dist" =  "ubuntu" ] ||  [ "$lsb_dist" =  "debian" ]; then
  553.         if [ "$webserver" = "1" ]; then
  554.             apt-get -y install php7.3 php7.3-cli php7.3-gd php7.3-mysql php7.3-pdo php7.3-mbstring php7.3-tokenizer php7.3-bcmath php7.3-xml php7.3-fpm php7.3-curl php7.3-zip curl tar unzip git redis-server nginx git wget expect jq
  555.         elif [ "$webserver" = "2" ]; then
  556.             apt-get -y install php7.3 php7.3-cli php7.3-gd php7.3-mysql php7.3-pdo php7.3-mbstring php7.3-tokenizer php7.3-bcmath php7.3-xml php7.3-fpm php7.3-curl php7.3-zip curl tar unzip git redis-server apache2 libapache2-mod-php7.3 redis-server git wget expect jq
  557.         fi
  558.         sh -c "DEBIAN_FRONTEND=noninteractive apt-get install -y ${db}-server"
  559.     elif [ "$lsb_dist" =  "fedora" ] ||  [ "$lsb_dist" =  "centos" ] ||  [ "$lsb_dist" =  "rhel" ]; then
  560.         if [ "$webserver" = "1" ]; then
  561.             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 ${db}-server redis nginx git policycoreutils-python-utils libsemanage-devel unzip wget expect jq
  562.         elif [ "$webserver" = "2" ]; then
  563.             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 ${db}-server redis httpd git policycoreutils-python-utils libsemanage-devel mod_ssl unzip wget expect jq
  564.         fi
  565.     fi
  566.     output "Enabling Services."
  567.     if [ "$lsb_dist" =  "ubuntu" ] || [ "$lsb_dist" =  "debian" ]; then
  568.         systemctl enable redis-server
  569.         service redis-server start
  570.         systemctl enable php7.3-fpm
  571.         service php7.3-fpm start
  572.     elif [ "$lsb_dist" =  "fedora" ] || [ "$lsb_dist" =  "centos" ] || [ "$lsb_dist" =  "rhel" ]; then
  573.         systemctl enable redis
  574.         service redis start
  575.         systemctl enable php-fpm
  576.         service php-fpm start
  577.     fi
  578.    
  579.     systemctl enable cron
  580.     systemctl enable mariadb
  581.     if [ "$webserver" = "1" ]; then
  582.         systemctl enable nginx
  583.         service nginx start
  584.     elif [ "$webserver" = "2" ]; then
  585.         if [ "$lsb_dist" =  "ubuntu" ] || [ "$lsb_dist" =  "debian" ]; then
  586.             systemctl enable apache2
  587.             service apache2 start
  588.         elif [ "$lsb_dist" =  "fedora" ] || [ "$lsb_dist" =  "centos" ] || [ "$lsb_dist" =  "rhel" ]; then
  589.             systemctl enable httpd
  590.             service httpd start
  591.         fi
  592.     fi
  593.     service cron start
  594.     service mysql start
  595. install_pterodactyl() {
  596.     output "Creating the databases and setting root password."
  597.     password=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`
  598.     adminpassword=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`
  599.     rootpassword=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`
  600.     Q0="DROP DATABASE IF EXISTS test;"
  601.     Q1="CREATE DATABASE IF NOT EXISTS panel;"
  602.     Q2="GRANT ALL ON panel.* TO 'pterodactyl'@'127.0.0.1' IDENTIFIED BY '$password';"
  603.     Q3="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;"
  604.     Q4="SET PASSWORD FOR 'root'@'localhost' = PASSWORD('$rootpassword');"
  605.     if [ "$db" = "mysql" ]; then
  606.         Q5="SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('$rootpassword');"
  607.         Q6="SET PASSWORD FOR 'root'@'::1' = PASSWORD('$rootpassword');"
  608.     fi
  609.     Q7="DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');"
  610.     Q8="DELETE FROM mysql.user WHERE User='';"
  611.     Q9="DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%';"
  612.     Q10="FLUSH PRIVILEGES;"
  613.     if [ "$db" = "mariadb" ]; then
  614.         SQL="${Q0}${Q1}${Q2}${Q3}${Q4}${Q7}${Q8}${Q9}${Q10}"
  615.     else
  616.         SQL="${Q0}${Q1}${Q2}${Q3}${Q4}${Q5}${Q6}${Q7}${Q8}${Q9}${Q10}"
  617.     fi
  618.     mysql -u root -e "$SQL"
  619.     output "Binding MariaDB/MySQL to 0.0.0.0."
  620.         if [ -f /etc/mysql/my.cnf ] ; then
  621.         sed -i -- 's/bind-address/# bind-address/g' /etc/mysql/my.cnf
  622.                 sed -i '/\[mysqld\]/a bind-address = 0.0.0.0' /etc/mysql/my.cnf
  623.                 output 'Restarting MySQL process...'
  624.                 service mysql restart
  625.         elif [ -f /etc/my.cnf ] ; then
  626.         sed -i -- 's/bind-address/# bind-address/g' /etc/my.cnf
  627.                 sed -i '/\[mysqld\]/a bind-address = 0.0.0.0' /etc/my.cnf
  628.                 output 'Restarting MySQL process...'
  629.                 service mysql restart
  630.     elif [ -f /etc/mysql/my.conf.d/mysqld.cnf ] ; then
  631.         sed -i -- 's/bind-address/# bind-address/g' /etc/my.cnf
  632.                 sed -i '/\[mysqld\]/a bind-address = 0.0.0.0' /etc/my.cnf
  633.                 output 'Restarting MySQL process...'
  634.                 service mysql restart
  635.         else
  636.                 output 'File my.cnf was not found! Please contact support.'
  637.    
  638.     output "Downloading Pterodactyl."
  639.     mkdir -p /var/www/pterodactyl
  640.     cd /var/www/pterodactyl
  641.     curl -Lo panel.tar.gz https://github.com/pterodactyl/panel/releases/download/v0.7.15/panel.tar.gz
  642.     tar --strip-components=1 -xzvf panel.tar.gz
  643.     chmod -R 755 storage/* bootstrap/cache/
  644.     output "Installing Pterodactyl."
  645.     curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
  646.     cp .env.example .env
  647.     if [ "$lsb_dist" =  "rhel" ]; then
  648.         yum -y install composer
  649.         composer update
  650.     else
  651.         composer install --no-dev --optimize-autoloader
  652.     fi
  653.     php artisan key:generate --force
  654.     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
  655.     php artisan p:environment:database --host=127.0.0.1 --port=3306 --database=panel --username=pterodactyl --password=$password
  656.     output "To use PHP's internal mail sending, select [mail]. To use a custom SMTP server, select [smtp]. TLS Encryption is recommended."
  657.     php artisan p:environment:mail
  658.     php artisan migrate --seed --force
  659.     php artisan p:user:make --email=$email --admin=1
  660.     if  [ "$lsb_dist" =  "ubuntu" ] || [ "$lsb_dist" =  "debian" ]; then
  661.         chown -R www-data:www-data * /var/www/pterodactyl
  662.     elif  [ "$lsb_dist" =  "fedora" ] || [ "$lsb_dist" =  "centos" ] || [ "$lsb_dist" =  "rhel" ]; then
  663.         if [ "$webserver" = "1" ]; then
  664.             chown -R nginx:nginx * /var/www/pterodactyl
  665.         elif [ "$webserver" = "2" ]; then
  666.             chown -R apache:apache * /var/www/pterodactyl
  667.         fi
  668.             semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/pterodactyl/storage(/.*)?"
  669.         restorecon -R /var/www/pterodactyl
  670.     fi
  671.     output "Creating panel queue listeners"
  672.     (crontab -l ; echo "* * * * * php /var/www/pterodactyl/artisan schedule:run >> /dev/null 2>&1")| crontab -
  673.     service cron restart
  674.     if  [ "$lsb_dist" =  "ubuntu" ] ||  [ "$lsb_dist" =  "debian" ]; then
  675.         cat > /etc/systemd/system/pteroq.service <<- 'EOF'
  676. [Unit]
  677. Description=Pterodactyl Queue Worker
  678. After=redis-server.service
  679. [Service]
  680. User=www-data
  681. Group=www-data
  682. Restart=always
  683. ExecStart=/usr/bin/php /var/www/pterodactyl/artisan queue:work --queue=high,standard,low --sleep=3 --tries=3
  684. [Install]
  685. WantedBy=multi-user.target
  686.     elif  [ "$lsb_dist" =  "fedora" ] ||  [ "$lsb_dist" =  "centos" ] ||  [ "$lsb_dist" =  "rhel" ]; then
  687.         if [ "$webserver" = "1" ]; then
  688.             cat > /etc/systemd/system/pteroq.service <<- 'EOF'
  689. Description=Pterodactyl Queue Worker
  690. After=redis-server.service
  691. [Service]
  692. User=nginx
  693. Group=nginx
  694. Restart=always
  695. ExecStart=/usr/bin/php /var/www/pterodactyl/artisan queue:work --queue=high,standard,low --sleep=3 --tries=3
  696. [Install]
  697. WantedBy=multi-user.target
  698.         elif [ "$webserver" = "2" ]; then
  699.             cat > /etc/systemd/system/pteroq.service <<- 'EOF'
  700. [Unit]
  701. Description=Pterodactyl Queue Worker
  702. After=redis-server.service
  703. [Service]
  704. User=apache
  705. Group=apache
  706. Restart=always
  707. ExecStart=/usr/bin/php /var/www/pterodactyl/artisan queue:work --queue=high,standard,low --sleep=3 --tries=3
  708. [Install]
  709. WantedBy=multi-user.target
  710.         fi
  711.         semanage permissive -a redis_t
  712.     fi
  713.     sudo systemctl daemon-reload
  714.     systemctl enable pteroq.service
  715.     systemctl start pteroq
  716. upgrade_pterodactyl(){
  717.     cd /var/www/pterodactyl
  718.     php artisan down
  719.     curl -L https://github.com/pterodactyl/panel/releases/download/v0.7.15/panel.tar.gz | tar --strip-components=1 -xzv
  720.     chmod -R 755 storage/* bootstrap/cache
  721.     composer install --no-dev --optimize-autoloader
  722.     php artisan view:clear
  723.     php artisan config:clear
  724.     php artisan migrate --force
  725.     php artisan db:seed --force
  726.     chown -R www-data:www-data * /var/www/pterodactyl
  727.     if [ "$lsb_dist" =  "fedora" ] || [ "$lsb_dist" =  "centos" ] || [ "$lsb_dist" =  "rhel" ]; then
  728.         chown -R apache:apache * /var/www/pterodactyl
  729.         chown -R nginx:nginx * /var/www/pterodactyl
  730.         semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/pterodactyl/storage(/.*)?"
  731.         restorecon -R /var/www/pterodactyl
  732.     fi
  733.     output "Your panel has been updated to version 0.7.15."
  734.     php artisan up
  735.     php artisan queue:restart
  736. nginx_config() {
  737.     output "Disabling default configuration"
  738.     rm -rf /etc/nginx/sites-enabled/default
  739.     output "Configuring Nginx Webserver"
  740.    
  741. echo '
  742. server_tokens off;
  743. set_real_ip_from 103.21.244.0/22;
  744. set_real_ip_from 103.22.200.0/22;
  745. set_real_ip_from 103.31.4.0/22;
  746. set_real_ip_from 104.16.0.0/12;
  747. set_real_ip_from 108.162.192.0/18;
  748. set_real_ip_from 131.0.72.0/22;
  749. set_real_ip_from 141.101.64.0/18;
  750. set_real_ip_from 162.158.0.0/15;
  751. set_real_ip_from 172.64.0.0/13;
  752. set_real_ip_from 173.245.48.0/20;
  753. set_real_ip_from 188.114.96.0/20;
  754. set_real_ip_from 190.93.240.0/20;
  755. set_real_ip_from 197.234.240.0/22;
  756. set_real_ip_from 198.41.128.0/17;
  757. set_real_ip_from 2400:cb00::/32;
  758. set_real_ip_from 2606:4700::/32;
  759. set_real_ip_from 2803:f800::/32;
  760. set_real_ip_from 2405:b500::/32;
  761. set_real_ip_from 2405:8100::/32;
  762. set_real_ip_from 2c0f:f248::/32;
  763. set_real_ip_from 2a06:98c0::/29;
  764. real_ip_header X-Forwarded-For;
  765. server {
  766.    listen 80;
  767.    server_name '"$FQDN"';
  768.    return 301 https://$server_name$request_uri;
  769. server {
  770.    listen 443 ssl http2;
  771.    server_name '"$FQDN"';
  772.    root /var/www/pterodactyl/public;
  773.    index index.php;
  774.    access_log /var/log/nginx/pterodactyl.app-access.log;
  775.    error_log  /var/log/nginx/pterodactyl.app-error.log error;
  776.    # allow larger file uploads and longer script runtimes
  777.    client_max_body_size 100m;
  778.    client_body_timeout 120s;
  779.    sendfile off;
  780.    # SSL Configuration
  781.    ssl_certificate /etc/letsencrypt/live/'"$FQDN"'/fullchain.pem;
  782.    ssl_certificate_key /etc/letsencrypt/live/'"$FQDN"'/privkey.pem;
  783.    ssl_session_cache shared:SSL:10m;
  784.    ssl_protocols TLSv1.2;
  785.    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';
  786.    ssl_prefer_server_ciphers on;
  787.    # See https://hstspreload.org/ before uncommenting the line below.
  788.    # add_header Strict-Transport-Security "max-age=15768000; preload;";
  789.    add_header X-Content-Type-Options nosniff;
  790.    add_header X-XSS-Protection "1; mode=block";
  791.    add_header X-Robots-Tag none;
  792.    add_header Content-Security-Policy "frame-ancestors 'self'";
  793.    add_header X-Frame-Options DENY;
  794.    add_header Referrer-Policy same-origin;
  795.    location / {
  796.        try_files $uri $uri/ /index.php?$query_string;
  797.    }
  798.    location ~ \.php$ {
  799.        fastcgi_split_path_info ^(.+\.php)(/.+)$;
  800.        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
  801.        fastcgi_index index.php;
  802.        include fastcgi_params;
  803.        fastcgi_param PHP_VALUE "upload_max_filesize = 100M \n post_max_size=100M";
  804.        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  805.        fastcgi_param HTTP_PROXY "";
  806.        fastcgi_intercept_errors off;
  807.        fastcgi_buffer_size 16k;
  808.        fastcgi_buffers 4 16k;
  809.        fastcgi_connect_timeout 300;
  810.        fastcgi_send_timeout 300;
  811.        fastcgi_read_timeout 300;
  812.        include /etc/nginx/fastcgi_params;
  813.    }
  814.    location ~ /\.ht {
  815.        deny all;
  816.    }
  817. ' | sudo -E tee /etc/nginx/sites-available/pterodactyl.conf >/dev/null 2>&1
  818.     ln -s /etc/nginx/sites-available/pterodactyl.conf /etc/nginx/sites-enabled/pterodactyl.conf
  819.     service nginx restart
  820. nginx_config_nossl() {
  821.     output "Disabling default configuration"
  822.     rm -rf /etc/nginx/sites-enabled/default
  823.     output "Configuring Nginx Webserver"
  824.    
  825. echo '
  826. server_tokens off;
  827. set_real_ip_from 103.21.244.0/22;
  828. set_real_ip_from 103.22.200.0/22;
  829. set_real_ip_from 103.31.4.0/22;
  830. set_real_ip_from 104.16.0.0/12;
  831. set_real_ip_from 108.162.192.0/18;
  832. set_real_ip_from 131.0.72.0/22;
  833. set_real_ip_from 141.101.64.0/18;
  834. set_real_ip_from 162.158.0.0/15;
  835. set_real_ip_from 172.64.0.0/13;
  836. set_real_ip_from 173.245.48.0/20;
  837. set_real_ip_from 188.114.96.0/20;
  838. set_real_ip_from 190.93.240.0/20;
  839. set_real_ip_from 197.234.240.0/22;
  840. set_real_ip_from 198.41.128.0/17;
  841. set_real_ip_from 2400:cb00::/32;
  842. set_real_ip_from 2606:4700::/32;
  843. set_real_ip_from 2803:f800::/32;
  844. set_real_ip_from 2405:b500::/32;
  845. set_real_ip_from 2405:8100::/32;
  846. set_real_ip_from 2c0f:f248::/32;
  847. set_real_ip_from 2a06:98c0::/29;
  848. real_ip_header X-Forwarded-For;
  849. server {
  850.    listen 80 default_server;
  851.    server_name _;
  852.    root /var/www/pterodactyl/public;
  853.    index index.php;
  854.    access_log /var/log/nginx/pterodactyl.app-access.log;
  855.    error_log  /var/log/nginx/pterodactyl.app-error.log error;
  856.    # allow larger file uploads and longer script runtimes
  857.    client_max_body_size 100m;
  858.    client_body_timeout 120s;
  859.    sendfile off;
  860.    location / {
  861.        try_files $uri $uri/ /index.php?$query_string;
  862.    }
  863.    location ~ \.php$ {
  864.        fastcgi_split_path_info ^(.+\.php)(/.+)$;
  865.        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
  866.        fastcgi_index index.php;
  867.        include fastcgi_params;
  868.        fastcgi_param PHP_VALUE "upload_max_filesize = 100M \n post_max_size=100M";
  869.        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  870.        fastcgi_param HTTP_PROXY "";
  871.        fastcgi_intercept_errors off;
  872.        fastcgi_buffer_size 16k;
  873.        fastcgi_buffers 4 16k;
  874.        fastcgi_connect_timeout 300;
  875.        fastcgi_send_timeout 300;
  876.        fastcgi_read_timeout 300;
  877.        include /etc/nginx/fastcgi_params;
  878.    }
  879.    location ~ /\.ht {
  880.        deny all;
  881.    }
  882. ' | sudo -E tee /etc/nginx/sites-available/pterodactyl.conf >/dev/null 2>&1
  883.     ln -s /etc/nginx/sites-available/pterodactyl.conf /etc/nginx/sites-enabled/pterodactyl.conf
  884.     service nginx restart
  885. apache_config() {
  886.     output "Disabling default configuration"
  887.     rm -rf /etc/nginx/sites-enabled/default
  888.     output "Configuring Apache2"
  889. echo '
  890. <VirtualHost *:80>
  891.  ServerName '"$FQDN"'
  892.  RewriteEngine On
  893.  RewriteCond %{HTTPS} !=on
  894.  RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
  895. </VirtualHost>
  896. <VirtualHost *:443>
  897.  ServerName '"$FQDN"'
  898.  DocumentRoot "/var/www/pterodactyl/public"
  899.  AllowEncodedSlashes On
  900.  php_value upload_max_filesize 100M
  901.  php_value post_max_size 100M
  902.  <Directory "/var/www/pterodactyl/public">
  903.    AllowOverride all
  904.  </Directory>
  905.  SSLEngine on
  906.  SSLCertificateFile /etc/letsencrypt/live/'"$FQDN"'/fullchain.pem
  907.  SSLCertificateKeyFile /etc/letsencrypt/live/'"$FQDN"'/privkey.pem
  908. </VirtualHost>
  909. ' | sudo -E tee /etc/apache2/sites-available/pterodactyl.conf >/dev/null 2>&1
  910.    
  911.     ln -s /etc/apache2/sites-available/pterodactyl.conf /etc/apache2/sites-enabled/pterodactyl.conf
  912.     a2enmod ssl
  913.     a2enmod rewrite
  914.     service apache2 restart
  915. nginx_config_redhat(){
  916.     output "Configuring Nginx Webserver"
  917.    
  918. echo '
  919. server_tokens off;
  920. set_real_ip_from 103.21.244.0/22;
  921. set_real_ip_from 103.22.200.0/22;
  922. set_real_ip_from 103.31.4.0/22;
  923. set_real_ip_from 104.16.0.0/12;
  924. set_real_ip_from 108.162.192.0/18;
  925. set_real_ip_from 131.0.72.0/22;
  926. set_real_ip_from 141.101.64.0/18;
  927. set_real_ip_from 162.158.0.0/15;
  928. set_real_ip_from 172.64.0.0/13;
  929. set_real_ip_from 173.245.48.0/20;
  930. set_real_ip_from 188.114.96.0/20;
  931. set_real_ip_from 190.93.240.0/20;
  932. set_real_ip_from 197.234.240.0/22;
  933. set_real_ip_from 198.41.128.0/17;
  934. set_real_ip_from 2400:cb00::/32;
  935. set_real_ip_from 2606:4700::/32;
  936. set_real_ip_from 2803:f800::/32;
  937. set_real_ip_from 2405:b500::/32;
  938. set_real_ip_from 2405:8100::/32;
  939. set_real_ip_from 2c0f:f248::/32;
  940. set_real_ip_from 2a06:98c0::/29;
  941. real_ip_header X-Forwarded-For;
  942. server {
  943.    listen 80;
  944.    server_name '"$FQDN"';
  945.    return 301 https://$server_name$request_uri;
  946. server {
  947.    listen 443 ssl http2;
  948.    server_name '"$FQDN"';
  949.    root /var/www/pterodactyl/public;
  950.    index index.php;
  951.    access_log /var/log/nginx/pterodactyl.app-access.log;
  952.    error_log  /var/log/nginx/pterodactyl.app-error.log error;
  953.    # allow larger file uploads and longer script runtimes
  954.    client_max_body_size 100m;
  955.    client_body_timeout 120s;
  956.    
  957.    sendfile off;
  958.    # strengthen ssl security
  959.    ssl_certificate /etc/letsencrypt/live/'"$FQDN"'/fullchain.pem;
  960.    ssl_certificate_key /etc/letsencrypt/live/'"$FQDN"'/privkey.pem;
  961.    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  962.    ssl_prefer_server_ciphers on;
  963.    ssl_session_cache shared:SSL:10m;
  964.    ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:ECDHE-RSA-AES128-GCM-SHA256:AES256+EECDH:DHE-RSA-AES128-GCM-SHA256:AES256+EDH:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
  965.    
  966.    # See the link below for more SSL information:
  967.    #     https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
  968.    #
  969.    # ssl_dhparam /etc/ssl/certs/dhparam.pem;
  970.    # Add headers to serve security related headers
  971.    add_header Strict-Transport-Security "max-age=15768000; preload;";
  972.    add_header X-Content-Type-Options nosniff;
  973.    add_header X-XSS-Protection "1; mode=block";
  974.    add_header X-Robots-Tag none;
  975.    add_header Content-Security-Policy "frame-ancestors 'self'";
  976.    location / {
  977.        try_files $uri $uri/ /index.php?$query_string;
  978.    }
  979.    location ~ \.php$ {
  980.        fastcgi_split_path_info ^(.+\.php)(/.+)$;
  981.        fastcgi_pass unix:/var/run/php-fpm/pterodactyl.sock;
  982.        fastcgi_index index.php;
  983.        include fastcgi_params;
  984.        fastcgi_param PHP_VALUE "upload_max_filesize = 100M \n post_max_size=100M";
  985.        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  986.        fastcgi_param HTTP_PROXY "";
  987.        fastcgi_intercept_errors off;
  988.        fastcgi_buffer_size 16k;
  989.        fastcgi_buffers 4 16k;
  990.        fastcgi_connect_timeout 300;
  991.        fastcgi_send_timeout 300;
  992.        fastcgi_read_timeout 300;
  993.        include /etc/nginx/fastcgi_params;
  994.    }
  995.    location ~ /\.ht {
  996.        deny all;
  997.    }
  998. ' | sudo -E tee /etc/nginx/conf.d/pterodactyl.conf >/dev/null 2>&1
  999.     service nginx restart
  1000.     chown -R nginx:nginx $(pwd)
  1001.     semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/pterodactyl/storage(/.*)?"
  1002.     restorecon -R /var/www/pterodactyl
  1003. nginx_config_redhat_nossl(){
  1004.     output "Configuring Nginx Webserver"
  1005.    
  1006. echo '
  1007. server_tokens off;
  1008. set_real_ip_from 103.21.244.0/22;
  1009. set_real_ip_from 103.22.200.0/22;
  1010. set_real_ip_from 103.31.4.0/22;
  1011. set_real_ip_from 104.16.0.0/12;
  1012. set_real_ip_from 108.162.192.0/18;
  1013. set_real_ip_from 131.0.72.0/22;
  1014. set_real_ip_from 141.101.64.0/18;
  1015. set_real_ip_from 162.158.0.0/15;
  1016. set_real_ip_from 172.64.0.0/13;
  1017. set_real_ip_from 173.245.48.0/20;
  1018. set_real_ip_from 188.114.96.0/20;
  1019. set_real_ip_from 190.93.240.0/20;
  1020. set_real_ip_from 197.234.240.0/22;
  1021. set_real_ip_from 198.41.128.0/17;
  1022. set_real_ip_from 2400:cb00::/32;
  1023. set_real_ip_from 2606:4700::/32;
  1024. set_real_ip_from 2803:f800::/32;
  1025. set_real_ip_from 2405:b500::/32;
  1026. set_real_ip_from 2405:8100::/32;
  1027. set_real_ip_from 2c0f:f248::/32;
  1028. set_real_ip_from 2a06:98c0::/29;
  1029. real_ip_header X-Forwarded-For;
  1030. server {
  1031.    listen 80 default_server;
  1032.    server_name _;
  1033.    root /var/www/pterodactyl/public;
  1034.    index index.php;
  1035.    access_log /var/log/nginx/pterodactyl.app-access.log;
  1036.    error_log  /var/log/nginx/pterodactyl.app-error.log error;
  1037.    # allow larger file uploads and longer script runtimes
  1038.    client_max_body_size 100m;
  1039.    client_body_timeout 120s;
  1040.    
  1041.    sendfile off;
  1042.    location / {
  1043.        try_files $uri $uri/ /index.php?$query_string;
  1044.    }
  1045.    location ~ \.php$ {
  1046.        fastcgi_split_path_info ^(.+\.php)(/.+)$;
  1047.        fastcgi_pass unix:/var/run/php-fpm/pterodactyl.sock;
  1048.        fastcgi_index index.php;
  1049.        include fastcgi_params;
  1050.        fastcgi_param PHP_VALUE "upload_max_filesize = 100M \n post_max_size=100M";
  1051.        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  1052.        fastcgi_param HTTP_PROXY "";
  1053.        fastcgi_intercept_errors off;
  1054.        fastcgi_buffer_size 16k;
  1055.        fastcgi_buffers 4 16k;
  1056.        fastcgi_connect_timeout 300;
  1057.        fastcgi_send_timeout 300;
  1058.        fastcgi_read_timeout 300;
  1059.        include /etc/nginx/fastcgi_params;
  1060.    }
  1061.    location ~ /\.ht {
  1062.        deny all;
  1063.    }
  1064. ' | sudo -E tee /etc/nginx/conf.d/pterodactyl.conf >/dev/null 2>&1
  1065.     service nginx restart
  1066.     chown -R nginx:nginx $(pwd)
  1067.     semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/pterodactyl/storage(/.*)?"
  1068.     restorecon -R /var/www/pterodactyl
  1069. apache_config_redhat() {
  1070.     output "Configuring Apache2"
  1071. echo '
  1072. <VirtualHost *:80>
  1073.  ServerName '"$FQDN"'
  1074.  RewriteEngine On
  1075.  RewriteCond %{HTTPS} !=on
  1076.  RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
  1077. </VirtualHost>
  1078. <VirtualHost *:443>
  1079.  ServerName '"$FQDN"'
  1080.  DocumentRoot "/var/www/pterodactyl/public"
  1081.  AllowEncodedSlashes On
  1082.  <Directory "/var/www/pterodactyl/public">
  1083.    AllowOverride all
  1084.  </Directory>
  1085.  SSLEngine on
  1086.  SSLCertificateFile /etc/letsencrypt/live/'"$FQDN"'/fullchain.pem
  1087.  SSLCertificateKeyFile /etc/letsencrypt/live/'"$FQDN"'/privkey.pem
  1088. </VirtualHost>
  1089. ' | sudo -E tee /etc/httpd/conf.d/pterodactyl.conf >/dev/null 2>&1
  1090.     service httpd restart
  1091. php_config(){
  1092.     output "Configuring PHP socket."
  1093.     bash -c 'cat > /etc/php-fpm.d/www-pterodactyl.conf' <<-'EOF'
  1094. [pterodactyl]
  1095. user = nginx
  1096. group = nginx
  1097. listen = /var/run/php-fpm/pterodactyl.sock
  1098. listen.owner = nginx
  1099. listen.group = nginx
  1100. listen.mode = 0750
  1101. pm = ondemand
  1102. pm.max_children = 9
  1103. pm.process_idle_timeout = 10s
  1104. pm.max_requests = 200
  1105.     systemctl restart php-fpm
  1106. webserver_config(){
  1107.     if  [ "$lsb_dist" =  "ubuntu" ] || [ "$lsb_dist" =  "debian" ]; then
  1108.         if [ "$webserver" = "1" ]; then
  1109.             nginx_config
  1110.         elif [ "$webserver" = "2" ]; then
  1111.             apache_config
  1112.         fi
  1113.     elif  [ "$lsb_dist" =  "fedora" ] ||  [ "$lsb_dist" =  "centos" ] ||  [ "$lsb_dist" =  "rhel" ]; then
  1114.         if [ "$webserver" = "1" ]; then
  1115.             php_config
  1116.             nginx_config_redhat
  1117.         elif [ "$webserver" = "2" ]; then
  1118.             apache_config_redhat
  1119.         fi
  1120.     fi
  1121. setup_pterodactyl(){
  1122.     install_dependencies
  1123.     install_pterodactyl
  1124.     ssl_certs
  1125.     webserver_config
  1126.     theme
  1127. install_daemon() {
  1128.     cd /root
  1129.     output "Installing Pterodactyl Daemon dependencies."
  1130.     if  [ "$lsb_dist" =  "ubuntu" ] ||  [ "$lsb_dist" =  "debian" ]; then
  1131.         apt-get -y install curl tar unzip
  1132.     elif  [ "$lsb_dist" =  "fedora" ] ||  [ "$lsb_dist" =  "centos" ] ||  [ "$lsb_dist" =  "rhel" ]; then
  1133.         yum -y install curl tar unzip
  1134.     fi
  1135.     if [ "$lsb_dist" =  "ubuntu" ] && [ "$dist_version" = "19.04" ]; then
  1136.         apt -y install docker.io
  1137.     else
  1138.         output "Installing Docker"
  1139.         curl -sSL https://get.docker.com/ | CHANNEL=stable bash
  1140.     fi
  1141.    
  1142.     service docker start
  1143.     systemctl enable docker
  1144.     output "Enabling Swap support for Docker & Installing NodeJS."
  1145.     sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="[^"]*/& swapaccount=1/' /etc/default/grub
  1146.     if  [ "$lsb_dist" =  "ubuntu" ] ||  [ "$lsb_dist" =  "debian" ]; then
  1147.         sudo update-grub
  1148.         curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
  1149.             if [ "$lsb_dist" =  "ubuntu" ] && [ "$dist_version" = "19.04" ]; then
  1150.                 apt -y install nodejs make gcc g++
  1151.             elif [ "$lsb_dist" =  "debian" ] && [ "$dist_version" = "10" ]; then
  1152.                 apt -y install nodejs make gcc g++
  1153.             else
  1154.                 apt -y install nodejs make gcc g++ node-gyp
  1155.             fi
  1156.         apt-get -y update
  1157.         apt-get -y upgrade
  1158.         apt-get -y autoremove
  1159.         apt-get -y autoclean
  1160.     elif  [ "$lsb_dist" =  "fedora" ] ||  [ "$lsb_dist" =  "centos" ] ||  [ "$lsb_dist" =  "rhel" ]; then
  1161.         grub2-mkconfig -o "$(readlink /etc/grub2.conf)"
  1162.         curl --silent --location https://rpm.nodesource.com/setup_10.x | sudo bash -
  1163.         yum -y install nodejs gcc-c++ make
  1164.         yum -y upgrade
  1165.         yum -y autoremove
  1166.         yum -y clean packages
  1167.         semanage permissive -a httpd_t
  1168.     fi
  1169.     output "Installing the Pterodactyl Daemon."
  1170.     mkdir -p /srv/daemon /srv/daemon-data
  1171.     cd /srv/daemon
  1172.     curl -L https://github.com/pterodactyl/daemon/releases/download/v0.6.12/daemon.tar.gz | tar --strip-components=1 -xzv
  1173.     npm install --only=production
  1174.     bash -c 'cat > /etc/systemd/system/wings.service' <<-'EOF'
  1175. [Unit]
  1176. Description=Pterodactyl Wings Daemon
  1177. After=docker.service
  1178. [Service]
  1179. User=root
  1180. #Group=some_group
  1181. WorkingDirectory=/srv/daemon
  1182. LimitNOFILE=4096
  1183. PIDFile=/var/run/wings/daemon.pid
  1184. ExecStart=/usr/bin/node /srv/daemon/src/index.js
  1185. Restart=on-failure
  1186. StartLimitInterval=600
  1187. [Install]
  1188. WantedBy=multi-user.target
  1189.     systemctl daemon-reload
  1190.     systemctl enable wings
  1191.     if [ "$lsb_dist" =  "debian" ] && [ "$dist_version" = "8" ]; then
  1192.         kernel_modifications_d8
  1193.     fi
  1194.     output "Daemon installation is nearly complete, Please go to the panel and get your 'Auto deploy' command in the node configuration tab."
  1195.     output "Paste your auto deploy command below: "
  1196.     read AUTODEPLOY
  1197.     ${AUTODEPLOY}
  1198.     service wings start
  1199. upgrade_daemon(){
  1200.     cd /srv/daemon
  1201.     service wings stop
  1202.     curl -L https://github.com/pterodactyl/daemon/releases/download/v0.6.12/daemon.tar.gz | tar --strip-components=1 -xzv
  1203.     npm install -g npm
  1204.     npm install --only=production
  1205.     service wings restart
  1206.     output "Your daemon has been updated to version 0.6.12."
  1207.     output "npm has been updated to the latest version."
  1208. install_standalone_sftp(){
  1209.     cd /srv/daemon
  1210.     if [ $(cat /srv/daemon/config/core.json | jq -r '.sftp.enabled') == "null" ]; then
  1211.         output "Updating config to enable sftp-server."
  1212.         cat /srv/daemon/config/core.json | jq '.sftp.enabled |= false' > /tmp/core
  1213.         cat /tmp/core > /srv/daemon/config/core.json
  1214.         rm -rf /tmp/core
  1215.     elif [ $(cat /srv/daemon/config/core.json | jq -r '.sftp.enabled') == "false" ]; then
  1216.        output "Config already set up for golang sftp server."
  1217.     else
  1218.        output "You may have purposly set the sftp to true and that will fail."
  1219.     fi
  1220.     service wings restart
  1221.     output "Installing standalone SFTP server."
  1222.     curl -Lo sftp-server https://github.com/pterodactyl/sftp-server/releases/download/v1.0.4/sftp-server
  1223.     chmod +x sftp-server
  1224.     bash -c 'cat > /etc/systemd/system/pterosftp.service' <<-'EOF'
  1225. [Unit]
  1226. Description=Pterodactyl Standalone SFTP Server
  1227. After=wings.service
  1228. [Service]
  1229. User=root
  1230. WorkingDirectory=/srv/daemon
  1231. LimitNOFILE=4096
  1232. PIDFile=/var/run/wings/sftp.pid
  1233. ExecStart=/srv/daemon/sftp-server
  1234. Restart=on-failure
  1235. StartLimitInterval=600
  1236. [Install]
  1237. WantedBy=multi-user.target
  1238.     systemctl enable pterosftp
  1239.     service pterosftp restart
  1240. upgrade_standalone_sftp(){
  1241.     output "Turning off the standalone SFTP server."
  1242.     service pterosftp stop
  1243.     curl -Lo sftp-server https://github.com/pterodactyl/sftp-server/releases/download/v1.0.4/sftp-server
  1244.     chmod +x sftp-server
  1245.     service pterosftp start
  1246.     output "Your standalone SFTP server has been updated to v1.0.4"
  1247. install_mobile(){
  1248.     cd /var/www/pterodactyl
  1249.     composer config repositories.cloud composer https://packages.pterodactyl.cloud
  1250.     composer require friendsofphp/php-cs-fixer 2.15.1 --dev
  1251.     composer require pterodactyl/mobile-addon --update-no-dev --optimize-autoloader
  1252.     php artisan migrate --force
  1253. install_phpmyadmin(){
  1254.     output "Installing phpMyAdmin."
  1255.     cd /var/www/pterodactyl/public
  1256.     rm -rf phpmyadmin
  1257.     wget https://files.phpmyadmin.net/phpMyAdmin/4.9.0.1/phpMyAdmin-4.9.0.1-all-languages.zip
  1258.     unzip phpMyAdmin-4.9.1-all-languages.zip
  1259.     mv phpMyAdmin-4.9.1-all-languages phpmyadmin
  1260.     rm -rf phpMyAdmin-4.9.1-all-languages.zip
  1261.     cd /var/www/pterodactyl/public/phpmyadmin
  1262.     SERVER_IP=$(curl -s http://checkip.amazonaws.com)
  1263.     BOWFISH=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 34 | head -n 1`
  1264.     bash -c 'cat > /var/www/pterodactyl/public/phpmyadmin/config.inc.php' <<EOF
  1265. <?php
  1266. /* Servers configuration */
  1267. \$i = 0;
  1268. /* Server: MariaDB [1] */
  1269. \$i++;
  1270. \$cfg['Servers'][\$i]['verbose'] = 'MariaDB';
  1271. \$cfg['Servers'][\$i]['host'] = '${SERVER_IP}';
  1272. \$cfg['Servers'][\$i]['port'] = '';
  1273. \$cfg['Servers'][\$i]['socket'] = '';
  1274. \$cfg['Servers'][\$i]['auth_type'] = 'cookie';
  1275. \$cfg['Servers'][\$i]['user'] = 'root';
  1276. \$cfg['Servers'][\$i]['password'] = '';
  1277. /* End of servers configuration */
  1278. \$cfg['blowfish_secret'] = '${BOWFISH}';
  1279. \$cfg['DefaultLang'] = 'en';
  1280. \$cfg['ServerDefault'] = 1;
  1281. \$cfg['UploadDir'] = '';
  1282. \$cfg['SaveDir'] = '';
  1283. \$cfg['CaptchaLoginPublicKey'] = '6LcJcjwUAAAAAO_Xqjrtj9wWufUpYRnK6BW8lnfn';
  1284. \$cfg['CaptchaLoginPrivateKey'] = '6LcJcjwUAAAAALOcDJqAEYKTDhwELCkzUkNDQ0J5'
  1285. ?>    
  1286.     output "Installation completed."
  1287.     if [ "$lsb_dist" =  "ubuntu" ] || [ "$lsb_dist" =  "debian" ]; then
  1288.         chown -R www-data:www-data * /var/www/pterodactyl
  1289.     elif [ "$lsb_dist" =  "fedora" ] || [ "$lsb_dist" =  "centos" ] ||  [ "$lsb_dist" =  "rhel" ]; then
  1290.         chown -R apache:apache * /var/www/pterodactyl
  1291.         chown -R nginx:nginx * /var/www/pterodactyl
  1292.         semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/pterodactyl/storage(/.*)?"
  1293.         restorecon -R /var/www/pterodactyl
  1294.     fi
  1295. kernel_modifications_d8(){
  1296.     output "Modifying Grub."
  1297.     sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="[^"]*/& cgroup_enable=memory/' /etc/default/grub  
  1298.     output "Adding backport repositories."
  1299.     echo deb http://http.debian.net/debian jessie-backports main > /etc/apt/sources.list.d/jessie-backports.list
  1300.     echo deb http://http.debian.net/debian jessie-backports main contrib non-free > /etc/apt/sources.list.d/jessie-backports.list
  1301.     output "Updating Server Packages."
  1302.     apt-get -y update
  1303.     apt-get -y upgrade
  1304.     apt-get -y autoremove
  1305.     apt-get -y autoclean
  1306.     output"Installing new kernel"
  1307.     apt install -t jessie-backports linux-image-4.9.0-0.bpo.7-amd64
  1308.     output "Modifying Docker."
  1309.     sed -i 's,/usr/bin/dockerd,/usr/bin/dockerd --storage-driver=overlay2,g' /lib/systemd/system/docker.service
  1310.     systemctl daemon-reload
  1311.     service docker start
  1312. ssl_certs(){
  1313.     output "Installing LetsEncrypt and creating an SSL certificate."
  1314.     cd /root
  1315.     if  [ "$lsb_dist" =  "ubuntu" ] || [ "$lsb_dist" =  "debian" ]; then
  1316.         if [ "$lsb_dist" =  "debian" ] && [ "$dist_version" = "8" ]; then
  1317.             wget https://dl.eff.org/certbot-auto
  1318.             chmod a+x certbot-auto
  1319.         else
  1320.             apt-get -y install certbot
  1321.         fi
  1322.     elif [ "$lsb_dist" =  "fedora" ] || [ "$lsb_dist" =  "centos" ] ||  [ "$lsb_dist" =  "rhel" ]; then
  1323.         yum -y install certbot
  1324.     fi
  1325.     if [ "$webserver" = "1" ]; then
  1326.         service nginx stop
  1327.     elif [ "$webserver" = "2" ]; then
  1328.         if  [ "$lsb_dist" =  "ubuntu" ] || [ "$lsb_dist" =  "debian" ]; then
  1329.             service apache2 stop
  1330.         elif [ "$lsb_dist" =  "fedora" ] || [ "$lsb_dist" =  "centos" ] ||  [ "$lsb_dist" =  "rhel" ]; then
  1331.             service httpd stop
  1332.         fi
  1333.     fi
  1334.     if [ "$lsb_dist" =  "debian" ] && [ "$dist_version" = "8" ]; then
  1335.         ./certbot-auto certonly --standalone --email "$email" --agree-tos -d "$FQDN" --non-interactive
  1336.     else
  1337.         certbot certonly --standalone --email "$email" --agree-tos -d "$FQDN" --non-interactive
  1338.     fi
  1339.     if [ "$installoption" = "2" ]; then
  1340.         if  [ "$lsb_dist" =  "ubuntu" ] || [ "$lsb_dist" =  "debian" ]; then
  1341.             ufw deny 80
  1342.         elif [ "$lsb_dist" =  "fedora" ] || [ "$lsb_dist" =  "centos" ] ||  [ "$lsb_dist" =  "rhel" ]; then
  1343.             firewall-cmd --permanent --remove-port=80/tcp
  1344.             firewall-cmd --reload
  1345.         fi
  1346.     else
  1347.         if [ "$webserver" = "1" ]; then
  1348.             service nginx restart
  1349.         elif [ "$webserver" = "2" ]; then
  1350.             if  [ "$lsb_dist" =  "ubuntu" ] || [ "$lsb_dist" =  "debian" ]; then
  1351.                 service apache2 restart
  1352.             elif [ "$lsb_dist" =  "fedora" ] || [ "$lsb_dist" =  "centos" ] ||  [ "$lsb_dist" =  "rhel" ]; then
  1353.                 service httpd restart
  1354.             fi
  1355.         fi
  1356.     fi
  1357.     if [ "$lsb_dist" =  "debian" ] && [ "$dist_version" = "8" ]; then
  1358.         apt -y install cronie
  1359.         if [ "$installoption" = "1" ]; then
  1360.             if [ "$webserver" = "1" ]; then
  1361.                 (crontab -l ; echo "0 0,12 * * * ./certbot-auto renew --pre-hook "service nginx stop" --post-hook "service nginx restart" >> /dev/null 2>&1")| crontab -
  1362.             elif [ "$webserver" = "2" ]; then
  1363.                 (crontab -l ; echo "0 0,12 * * * ./certbot-auto renew --pre-hook "service apache2 stop" --post-hook "service apache2 restart" >> /dev/null 2>&1")| crontab -
  1364.             fi
  1365.         elif [ "$installoption" = "2" ]; then
  1366.             (crontab -l ; echo "0 0,12 * * * ./certbot-auto 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 -
  1367.         elif [ "$installoption" = "3" ]; then
  1368.             if [ "$webserver" = "1" ]; then
  1369.                 (crontab -l ; echo "0 0,12 * * * ./certbot-auto 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 -
  1370.             elif [ "$webserver" = "2" ]; then
  1371.                 (crontab -l ; echo "0 0,12 * * * ./certbot-auto 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 -
  1372.             fi
  1373.         fi            
  1374.     elif [ "$lsb_dist" =  "debian" ] || [ "$lsb_dist" =  "ubuntu" ]; then
  1375.         apt -y install cronie
  1376.         if [ "$installoption" = "1" ]; then
  1377.             if [ "$webserver" = "1" ]; then
  1378.                 (crontab -l ; echo "0 0,12 * * * certbot renew --pre-hook "service nginx stop" --post-hook "service nginx restart" >> /dev/null 2>&1")| crontab -
  1379.             elif [ "$webserver" = "2" ]; then
  1380.                 (crontab -l ; echo "0 0,12 * * * certbot renew --pre-hook "service apache2 stop" --post-hook "service apache2 restart" >> /dev/null 2>&1")| crontab -
  1381.             fi
  1382.         elif [ "$installoption" = "2" ]; then
  1383.             (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 -
  1384.         elif [ "$installoption" = "3" ]; then
  1385.             if [ "$webserver" = "1" ]; then
  1386.                 (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 -
  1387.             elif [ "$webserver" = "2" ]; then
  1388.                 (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 -
  1389.             fi
  1390.         fi    
  1391.     elif [ "$lsb_dist" =  "fedora" ] || [ "$lsb_dist" =  "centos" ] || [ "$lsb_dist" =  "rhel" ]; then
  1392.         yum -y install cronie
  1393.         if [ "$installoption" = "1" ]; then
  1394.             if [ "$webserver" = "1" ]; then
  1395.                 (crontab -l ; echo "0 0,12 * * * certbot renew --pre-hook "service nginx stop" --post-hook "service nginx restart" >> /dev/null 2>&1")| crontab -
  1396.             elif [ "$webserver" = "2" ]; then
  1397.                 (crontab -l ; echo "0 0,12 * * * certbot renew --pre-hook "service httpd stop" --post-hook "service httpd restart" >> /dev/null 2>&1")| crontab -
  1398.             fi
  1399.         elif [ "$installoption" = "2" ]; then
  1400.             (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 -
  1401.         elif [ "$installoption" = "3" ]; then
  1402.             if [ "$webserver" = "1" ]; then
  1403.                 (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 -
  1404.             elif [ "$webserver" = "2" ]; then
  1405.                 (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 -
  1406.             fi
  1407.         fi    
  1408.     fi
  1409.     service cron restart
  1410. javapipe_kernel(){
  1411.     output "Apply JavaPipe's kernel configurations? (https://javapipe.com/blog/iptables-ddos-protection/)"
  1412.     output "[1] Yes. (Recommended for RHEL/CentOS 7)"
  1413.     output "[2] No."
  1414.     read javapipe
  1415.     case $javapipe in
  1416.         1)  bash -c 'cat > /etc/sysctl.conf' <<-'EOF'
  1417. kernel.printk = 4 4 1 7
  1418. kernel.panic = 10
  1419. kernel.sysrq = 0
  1420. kernel.shmmax = 4294967296
  1421. kernel.shmall = 4194304
  1422. kernel.core_uses_pid = 1
  1423. kernel.msgmnb = 65536
  1424. kernel.msgmax = 65536
  1425. vm.swappiness = 20
  1426. vm.dirty_ratio = 80
  1427. vm.dirty_background_ratio = 5
  1428. fs.file-max = 2097152
  1429. net.core.netdev_max_backlog = 262144
  1430. net.core.rmem_default = 31457280
  1431. net.core.rmem_max = 67108864
  1432. net.core.wmem_default = 31457280
  1433. net.core.wmem_max = 67108864
  1434. net.core.somaxconn = 65535
  1435. net.core.optmem_max = 25165824
  1436. net.ipv4.neigh.default.gc_thresh1 = 4096
  1437. net.ipv4.neigh.default.gc_thresh2 = 8192
  1438. net.ipv4.neigh.default.gc_thresh3 = 16384
  1439. net.ipv4.neigh.default.gc_interval = 5
  1440. net.ipv4.neigh.default.gc_stale_time = 120
  1441. net.netfilter.nf_conntrack_max = 10000000
  1442. net.netfilter.nf_conntrack_tcp_loose = 0
  1443. net.netfilter.nf_conntrack_tcp_timeout_established = 1800
  1444. net.netfilter.nf_conntrack_tcp_timeout_close = 10
  1445. net.netfilter.nf_conntrack_tcp_timeout_close_wait = 10
  1446. net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 20
  1447. net.netfilter.nf_conntrack_tcp_timeout_last_ack = 20
  1448. net.netfilter.nf_conntrack_tcp_timeout_syn_recv = 20
  1449. net.netfilter.nf_conntrack_tcp_timeout_syn_sent = 20
  1450. net.netfilter.nf_conntrack_tcp_timeout_time_wait = 10
  1451. net.ipv4.tcp_slow_start_after_idle = 0
  1452. net.ipv4.ip_local_port_range = 1024 65000
  1453. net.ipv4.ip_no_pmtu_disc = 1
  1454. net.ipv4.route.flush = 1
  1455. net.ipv4.route.max_size = 8048576
  1456. net.ipv4.icmp_echo_ignore_broadcasts = 1
  1457. net.ipv4.icmp_ignore_bogus_error_responses = 1
  1458. net.ipv4.tcp_congestion_control = htcp
  1459. net.ipv4.tcp_mem = 65536 131072 262144
  1460. net.ipv4.udp_mem = 65536 131072 262144
  1461. net.ipv4.tcp_rmem = 4096 87380 33554432
  1462. net.ipv4.udp_rmem_min = 16384
  1463. net.ipv4.tcp_wmem = 4096 87380 33554432
  1464. net.ipv4.udp_wmem_min = 16384
  1465. net.ipv4.tcp_max_tw_buckets = 1440000
  1466. net.ipv4.tcp_tw_recycle = 0
  1467. net.ipv4.tcp_tw_reuse = 1
  1468. net.ipv4.tcp_max_orphans = 400000
  1469. net.ipv4.tcp_window_scaling = 1
  1470. net.ipv4.tcp_rfc1337 = 1
  1471. net.ipv4.tcp_syncookies = 1
  1472. net.ipv4.tcp_synack_retries = 1
  1473. net.ipv4.tcp_syn_retries = 2
  1474. net.ipv4.tcp_max_syn_backlog = 16384
  1475. net.ipv4.tcp_timestamps = 1
  1476. net.ipv4.tcp_sack = 1
  1477. net.ipv4.tcp_fack = 1
  1478. net.ipv4.tcp_ecn = 2
  1479. net.ipv4.tcp_fin_timeout = 10
  1480. net.ipv4.tcp_keepalive_time = 600
  1481. net.ipv4.tcp_keepalive_intvl = 60
  1482. net.ipv4.tcp_keepalive_probes = 10
  1483. net.ipv4.tcp_no_metrics_save = 1
  1484. net.ipv4.ip_forward = 0
  1485. net.ipv4.conf.all.accept_redirects = 0
  1486. net.ipv4.conf.all.send_redirects = 0
  1487. net.ipv4.conf.all.accept_source_route = 0
  1488. net.ipv4.conf.all.rp_filter = 1
  1489.             sysctl -p
  1490.             ;;
  1491.         2)  output "Skipping..."
  1492.             ;;
  1493.         * ) output "You did not enter a valid selection."
  1494.             javapipe_kernel
  1495.     esac    
  1496. firewall(){
  1497.     /sbin/iptables -t mangle -A PREROUTING -m conntrack --ctstate INVALID -j DROP
  1498.     /sbin/iptables -t mangle -A PREROUTING -p tcp ! --syn -m conntrack --ctstate NEW -j DROP
  1499.     /sbin/iptables -t mangle -A PREROUTING -p tcp -m conntrack --ctstate NEW -m tcpmss ! --mss 536:65535 -j DROP
  1500.     /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j DROP
  1501.     /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags FIN,SYN FIN,SYN -j DROP
  1502.     /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
  1503.     /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags FIN,RST FIN,RST -j DROP
  1504.     /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags FIN,ACK FIN -j DROP
  1505.     /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ACK,URG URG -j DROP
  1506.     /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ACK,FIN FIN -j DROP
  1507.     /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ACK,PSH PSH -j DROP
  1508.     /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ALL ALL -j DROP
  1509.     /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ALL NONE -j DROP
  1510.     /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ALL FIN,PSH,URG -j DROP
  1511.     /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ALL SYN,FIN,PSH,URG -j DROP
  1512.     /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
  1513.     /sbin/iptables -t mangle -A PREROUTING -f -j DROP
  1514.     /sbin/iptables -N port-scanning
  1515.     /sbin/iptables -A port-scanning -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s --limit-burst 2 -j RETURN
  1516.     /sbin/iptables -A port-scanning -j DROP
  1517.     (crontab -l ; echo "@reboot /sbin/iptables -t mangle -A PREROUTING -m conntrack --ctstate INVALID -j DROP >> /dev/null 2>&1")| crontab -
  1518.     (crontab -l ; echo "@reboot /sbin/iptables -t mangle -A PREROUTING -p tcp ! --syn -m conntrack --ctstate NEW -j DROP >> /dev/null 2>&1")| crontab -
  1519.     (crontab -l ; echo "@reboot /sbin/iptables -t mangle -A PREROUTING -p tcp -m conntrack --ctstate NEW -m tcpmss ! --mss 536:65535 -j DROP >> /dev/null 2>&1")| crontab -
  1520.     (crontab -l ; echo "@reboot /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j DROP >> /dev/null 2>&1")| crontab -
  1521.     (crontab -l ; echo "@reboot /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags FIN,SYN FIN,SYN -j DROP >> /dev/null 2>&1")| crontab -
  1522.     (crontab -l ; echo "@reboot /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags SYN,RST SYN,RST -j DROP >> /dev/null 2>&1")| crontab -    
  1523.     (crontab -l ; echo "@reboot /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags FIN,RST FIN,RST -j DROP >> /dev/null 2>&1")| crontab -
  1524.     (crontab -l ; echo "@reboot /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags FIN,ACK FIN -j DROP >> /dev/null 2>&1")| crontab -
  1525.     (crontab -l ; echo "@reboot /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ACK,URG URG -j DROP >> /dev/null 2>&1")| crontab -
  1526.     (crontab -l ; echo "@reboot /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ACK,FIN FIN -j DROP >> /dev/null 2>&1")| crontab -
  1527.     (crontab -l ; echo "@reboot /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ACK,PSH PSH -j DROP >> /dev/null 2>&1")| crontab -
  1528.     (crontab -l ; echo "@reboot /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ALL ALL -j DROP >> /dev/null 2>&1")| crontab -
  1529.     (crontab -l ; echo "@reboot /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ALL NONE -j DROP >> /dev/null 2>&1")| crontab -
  1530.     (crontab -l ; echo "@reboot /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ALL FIN,PSH,URG -j DROP >> /dev/null 2>&1")| crontab -
  1531.     (crontab -l ; echo "@reboot /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ALL SYN,FIN,PSH,URG -j DROP >> /dev/null 2>&1")| crontab -
  1532.     (crontab -l ; echo "@reboot /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP >> /dev/null 2>&1")| crontab -
  1533.     (crontab -l ; echo "@reboot /sbin/iptables -t mangle -A PREROUTING -f -j DROP >> /dev/null 2>&1")| crontab -
  1534.     (crontab -l ; echo "@reboot /sbin/iptables -N port-scanning >> /dev/null 2>&1")| crontab -
  1535.     (crontab -l ; echo "@reboot /sbin/iptables -A port-scanning -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s --limit-burst 2 -j RETURN >> /dev/null 2>&1")| crontab -
  1536.     (crontab -l ; echo "@reboot /sbin/iptables -A port-scanning -j DROP >> /dev/null 2>&1")| crontab -
  1537.    
  1538.     block_icmp
  1539.     javapipe_kernel
  1540.     output "Setting up Fail2Ban"
  1541.     if [ "$lsb_dist" =  "ubuntu" ] || [ "$lsb_dist" =  "debian" ]; then
  1542.         apt -y install fail2ban
  1543.     elif [ "$lsb_dist" =  "centos" ] || [ "$lsb_dist" =  "fedora" ] ||  [ "$lsb_dist" =  "rhel" ]; then
  1544.         yum -y install fail2ban
  1545.     fi
  1546.     systemctl enable fail2ban
  1547.     bash -c 'cat > /etc/fail2ban/jail.local' <<-'EOF'
  1548. [DEFAULT]
  1549. # Ban hosts for ten hours:
  1550. bantime = 36000
  1551. # Override /etc/fail2ban/jail.d/00-firewalld.conf:
  1552. banaction = iptables-multiport
  1553. [sshd]
  1554. enabled = true
  1555.     service fail2ban restart
  1556.     output "Configuring your firewall."
  1557.     if [ "$lsb_dist" =  "ubuntu" ] || [ "$lsb_dist" =  "debian" ]; then
  1558.         apt-get -y install ufw
  1559.         ufw allow 22
  1560.         if [ "$installoption" = "1" ]; then
  1561.             ufw allow 80
  1562.             ufw allow 443
  1563.             ufw allow 3306
  1564.         elif [ "$installoption" = "2" ]; then
  1565.             ufw allow 80
  1566.             ufw allow 8080
  1567.             ufw allow 2022
  1568.         elif [ "$installoption" = "3" ]; then
  1569.             ufw allow 80
  1570.             ufw allow 443
  1571.             ufw allow 8080
  1572.             ufw allow 2022
  1573.             ufw allow 3306
  1574.         fi
  1575.         yes |ufw enable
  1576.     elif [ "$lsb_dist" =  "centos" ] || [ "$lsb_dist" =  "fedora" ] ||  [ "$lsb_dist" =  "rhel" ]; then
  1577.         yum -y install firewalld
  1578.         systemctl enable firewalld
  1579.         systemctl start firewalld
  1580.         if [ "$installoption" = "1" ]; then
  1581.             firewall-cmd --add-service=http --permanent
  1582.             firewall-cmd --add-service=https --permanent
  1583.             firewall-cmd --add-service=mysql --permanent
  1584.         elif [ "$installoption" = "2" ]; then
  1585.             firewall-cmd --permanent --add-port=80/tcp
  1586.             firewall-cmd --permanent --add-port=2022/tcp
  1587.             firewall-cmd --permanent --add-port=8080/tcp
  1588.         elif [ "$installoption" = "3" ]; then
  1589.             firewall-cmd --add-service=http --permanent
  1590.             firewall-cmd --add-service=https --permanent
  1591.             firewall-cmd --permanent --add-port=2022/tcp
  1592.             firewall-cmd --permanent --add-port=8080/tcp
  1593.             firewall-cmd --add-service=mysql --permanent
  1594.         fi
  1595.         firewall-cmd --reload
  1596.     fi
  1597. block_icmp(){
  1598.     output "Block ICMP (Ping) Packets?"
  1599.     output "You should choose [1] if you are not using a monitoring system and [2] otherwise."
  1600.     output "[1] Yes."
  1601.     output "[2] No."
  1602.     read icmp
  1603.     case $icmp in
  1604.         1 ) /sbin/iptables -t mangle -A PREROUTING -p icmp -j DROP
  1605.             (crontab -l ; echo "@reboot /sbin/iptables -t mangle -A PREROUTING -p icmp -j DROP >> /dev/null 2>&1")| crontab -
  1606.             ;;
  1607.         2 ) output "Skipping rule..."
  1608.             ;;
  1609.         * ) output "You did not enter a valid selection."
  1610.             block_icmp
  1611.     esac    
  1612. mariadb_root_reset(){
  1613.     rootpassword=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`    
  1614.     Q1="SET PASSWORD FOR root@localhost = PASSWORD('$rootpassword');"
  1615.     Q2="FLUSH PRIVILEGES;"
  1616.     SQL="${Q1}${Q2}"
  1617.     mysql mysql -e "$SQL"
  1618.     output "Your MariaDB root password is $rootpassword"
  1619. database_host_reset(){
  1620.     SERVER_IP=$(curl -s http://checkip.amazonaws.com)
  1621.     adminpassword=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`
  1622.     Q1="SET PASSWORD FOR 'admin'@'$SERVER_IP' = PASSWORD('$adminpassword');"
  1623.     Q2="FLUSH PRIVILEGES;"
  1624.     SQL="${Q1}${Q2}"
  1625.     mysql mysql -e "$SQL"
  1626.     output "New database host information:"
  1627.     output "Host: $SERVER_IP"
  1628.     output "Port: 3306"
  1629.     output "User: admin"
  1630.     output "Password: $adminpassword"
  1631. broadcast(){
  1632.     if [ "$installoption" = "1" ] || [ "$installoption" = "3" ]; then
  1633.         output "###############################################################"
  1634.         output "MARIADB/MySQL INFORMATION"
  1635.         output ""
  1636.         output "Your MariaDB/MySQL root password is $rootpassword"
  1637.         output ""
  1638.         output "Create your MariaDB/MySQL host with the following information:"
  1639.         output "Host: $SERVER_IP"
  1640.         output "Port: 3306"
  1641.         output "User: admin"
  1642.         output "Password: $adminpassword"
  1643.         output "###############################################################"
  1644.         output ""
  1645.     fi
  1646.     output "###############################################################"
  1647.     output "FIREWALL INFORMATION"
  1648.     output ""
  1649.     output "All unnecessary ports are blocked by default."
  1650.     if [ "$lsb_dist" =  "ubuntu" ] || [ "$lsb_dist" =  "debian" ]; then
  1651.         output "Use 'ufw allow <port>' to enable your desired ports"
  1652.     elif [ "$lsb_dist" =  "fedora" ] || [ "$lsb_dist" =  "centos" ] ||  [ "$lsb_dist" =  "rhel" ]; then
  1653.         output "Use 'firewall-cmd --permanent --add-port=<port>/tcp' to enable your desired ports."
  1654.     fi
  1655.     output "###############################################################"
  1656.     output ""
  1657.     if [ "$installoption" = "2" ] || [ "$installoption" = "3" ]; then
  1658.         if [ "$lsb_dist" =  "debian" ] && [ "$dist_version" = "8" ]; then
  1659.             output "Please restart the server daemon to apply the necessary kernel changes on Debian 8."
  1660.         fi
  1661.     fi
  1662.                          
  1663. #Execution
  1664. preflight
  1665. install_options
  1666. case $installoption in
  1667.     1)  webserver_options
  1668.         theme_options
  1669.         database_options
  1670.         repositories_setup
  1671.         required_infos
  1672.         firewall
  1673.         setup_pterodactyl
  1674.         broadcast
  1675.         ;;
  1676.     2)  repositories_setup
  1677.         required_infos
  1678.         firewall
  1679.         ssl_certs
  1680.         install_daemon
  1681.         broadcast
  1682.         ;;
  1683.     3)  webserver_options
  1684.         theme_options
  1685.         database_options
  1686.         repositories_setup
  1687.         required_infos
  1688.         firewall
  1689.         setup_pterodactyl
  1690.         install_daemon
  1691.         broadcast
  1692.         ;;
  1693.     4)  install_standalone_sftp
  1694.         ;;
  1695.     5)  theme_options
  1696.         upgrade_pterodactyl
  1697.         theme
  1698.         ;;
  1699.     6)  upgrade_daemon
  1700.         ;;
  1701.     7)  theme_options
  1702.         upgrade_pterodactyl
  1703.         theme
  1704.         upgrade_daemon
  1705.         ;;
  1706.     8)  upgrade_standalone_sftp
  1707.         ;;
  1708.     9)  install_mobile
  1709.         ;;
  1710.     10) cd /var/www/pterodactyl
  1711.         composer update pterodactyl/mobile-addon
  1712.         ;;
  1713.     11) install_phpmyadmin
  1714.         ;;
  1715.     12)  theme_options
  1716.         if [ "$themeoption" = "1" ]; then
  1717.             upgrade_pterodactyl
  1718.         fi
  1719.         theme
  1720.         ;;
  1721.     13) mariadb_root_reset
  1722.         ;;
  1723.     14) database_host_reset
  1724.         ;;
  1725. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement