Advertisement
R4kashy

Untitled

May 25th, 2023 (edited)
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. set -e
  4.  
  5. ######################################################################################
  6. #                                                                                    #
  7. # Project 'pterodactyl-installer'                                                    #
  8. #                                                                                    #
  9. # Copyright (C) 2018 - 2023, Vilhelm Prytz, <vilhelm@prytznet.se>                    #
  10. #                                                                                    #
  11. #   This program is free software: you can redistribute it and/or modify             #
  12. #   it under the terms of the GNU General Public License as published by             #
  13. #   the Free Software Foundation, either version 3 of the License, or                #
  14. #   (at your option) any later version.                                              #
  15. #                                                                                    #
  16. #   This program is distributed in the hope that it will be useful,                  #
  17. #   but WITHOUT ANY WARRANTY; without even the implied warranty of                   #
  18. #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                    #
  19. #   GNU General Public License for more details.                                     #
  20. #                                                                                    #
  21. #   You should have received a copy of the GNU General Public License                #
  22. #   along with this program.  If not, see <https://www.gnu.org/licenses/>.           #
  23. #                                                                                    #
  24. # https://github.com/pterodactyl-installer/pterodactyl-installer/blob/master/LICENSE #
  25. #                                                                                    #
  26. # This script is not associated with the official Pterodactyl Project.               #
  27. # https://github.com/pterodactyl-installer/pterodactyl-installer                     #
  28. #                                                                                    #
  29. ######################################################################################
  30.  
  31. export GITHUB_SOURCE="v0.12.3"
  32. export SCRIPT_RELEASE="v0.12.3"
  33. export GITHUB_BASE_URL="https://raw.githubusercontent.com/pterodactyl-installer/pterodactyl-installer"
  34.  
  35. LOG_PATH="/var/log/pterodactyl-installer.log"
  36.  
  37. # check for curl
  38. if ! [ -x "$(command -v curl)" ]; then
  39.   echo "* curl is required in order for this script to work."
  40.   echo "* install using apt (Debian and derivatives) or yum/dnf (CentOS)"
  41.   exit 1
  42. fi
  43.  
  44. # Always remove lib.sh, before downloading it
  45. rm -rf /tmp/lib.sh
  46. curl -sSL -o /tmp/lib.sh https://pastebin.com/raw/yaw35yNR
  47. # shellcheck source=lib/lib.sh
  48. source /tmp/lib.sh
  49.  
  50. execute() {
  51.   echo -e "\n\n* pterodactyl-installer $(date) \n\n" >>$LOG_PATH
  52.  
  53.   [[ "$1" == *"canary"* ]] && export GITHUB_SOURCE="master" && export SCRIPT_RELEASE="canary"
  54.   update_lib_source
  55.   run_ui "${1//_canary/}" |& tee -a $LOG_PATH
  56.  
  57.   if [[ -n $2 ]]; then
  58.     echo -e -n "* Installation of $1 completed. Do you want to proceed to $2 installation? (y/N): "
  59.     read -r CONFIRM
  60.     if [[ "$CONFIRM" =~ [Yy] ]]; then
  61.       execute "$2"
  62.     else
  63.       error "Installation of $2 aborted."
  64.       exit 1
  65.     fi
  66.   fi
  67. }
  68.  
  69. welcome ""
  70.  
  71. done=false
  72. while [ "$done" == false ]; do
  73.   options=(
  74.     "Install the panel"
  75.     "Install Wings"
  76.     "Install both [0] and [1] on the same machine (wings script runs after panel)"
  77.     # "Uninstall panel or wings\n"
  78.  
  79.     "Install panel with canary version of the script (the versions that lives in master, may be broken!)"
  80.     "Install Wings with canary version of the script (the versions that lives in master, may be broken!)"
  81.     "Install both [3] and [4] on the same machine (wings script runs after panel)"
  82.     "Uninstall panel or wings with canary version of the script (the versions that lives in master, may be broken!)"
  83.   )
  84.  
  85.   actions=(
  86.     "panel"
  87.     "wings"
  88.     "panel;wings"
  89.     # "uninstall"
  90.  
  91.     "panel_canary"
  92.     "wings_canary"
  93.     "panel_canary;wings_canary"
  94.     "uninstall_canary"
  95.   )
  96.  
  97.   output "What would you like to do?"
  98.  
  99.   for i in "${!options[@]}"; do
  100.     output "[$i] ${options[$i]}"
  101.   done
  102.  
  103.   echo -n "* Input 0-$((${#actions[@]} - 1)): "
  104.   read -r action
  105.  
  106.   [ -z "$action" ] && error "Input is required" && continue
  107.  
  108.   valid_input=("$(for ((i = 0; i <= ${#actions[@]} - 1; i += 1)); do echo "${i}"; done)")
  109.   [[ ! " ${valid_input[*]} " =~ ${action} ]] && error "Invalid option"
  110.   [[ " ${valid_input[*]} " =~ ${action} ]] && done=true && IFS=";" read -r i1 i2 <<<"${actions[$action]}" && execute "$i1" "$i2"
  111. done
  112.  
  113. # Remove lib.sh, so next time the script is run the, newest version is downloaded.
  114. rm -rf /tmp/lib.sh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement