Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.69 KB | None | 0 0
  1. #!/bin/bash
  2. set -e
  3.  
  4. DEFAULT_INSTALL_PATH="/var/www/html/pterodactyl"
  5.  
  6. GITHUB_REPO="https://github.com/Pterodactyl/Panel"
  7.  
  8. reset='\033[0m'
  9. black='\033[0;30m'
  10. red='\033[0;31m'
  11. green='\033[0;32m'
  12. yellow='\033[0;33m'
  13. blue='\033[0;34m'
  14. purple='\033[0;35m'
  15. cyan='\033[0;36m'
  16. white='\033[0;37m'
  17.  
  18. LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' "$GITHUB_REPO/releases/latest")
  19. PANEL_VERSION=$(echo $LATEST_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
  20. MARIA_RELEASE=$(apt show mariadb-server| grep Version| awk {'print $2'})
  21. MARIA_VERSION=$(echo $MARIA_RELEASE | awk {'print $1'})
  22.  
  23. config_ppa() {
  24. apt -y install software-properties-common
  25. add-apt-repository -y ppa:ondrej/php
  26. apt update
  27. }
  28.  
  29. install_mariadb() {
  30. if ! type mysql >/dev/null 2>&1; then
  31. apt update
  32. if [ "$MARIA_VERSION" -lt '10' ]; then
  33. echo "MariaDB version in repository doesnt meets the requirements (version: $MARIA_RELEASE)"
  34. fi
  35. echo "Installing MariaDB Server version $MARIA_RELEASE"
  36. apt -y install mariadb-server
  37. fi
  38. }
  39.  
  40. install_deps() {
  41. echo "OK!"
  42.  
  43. }
  44.  
  45. install_panel() {
  46. clear
  47. echo "Installing Pterodactyl Panel..."
  48. echo -n "Installation path [$DEFAULT_INSTALL_PATH]: "
  49. read INSTALL_PATH
  50. INSTALL_PATH=${INSTALL_PATH:-$DEFAULT_INSTALL_PATH}
  51. echo -n "Enter URL (not including http(s)://) [$(hostname)]: "
  52. read FQDN
  53. FQDN=${FQDN:-$(hostname)}
  54. echo -n "Enter Email (for SSL): "
  55. read EMAIL
  56. echo -ne "
  57. Email: ${white}${EMAIL}${reset}
  58. URL: ${white}https://${FQDN}/${reset}
  59. Install path: ${white}${INSTALL_PATH}${reset}
  60. Are the settings above correct [Y/n]? "
  61. read RESPONSE
  62. RESPONSE=${RESPONSE:-y}
  63. if [[ "$RESPONSE" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
  64. if [ -d "$INSTALL_PATH" ]; then
  65. echo -ne "${red}${INSTALL_PATH} already exists, do you want to overwrite [y/N]?${reset} "
  66. override=${override:-n}
  67. read override
  68. if [[ "$override" =~ ^([nN][oO]|[nN])+$ ]]; then
  69. echo "Stopping script"
  70. exit 1
  71. fi
  72. fi
  73. mkdir -p "$INSTALL_PATH"
  74. curl -Lo "$INSTALL_PATH/pterodactyl.tar.gz" "$GITHUB_REPO/archive/$PANEL_VERSION.tar.gz"
  75. tar --strip-components=1 -xzvf "$INSTALL_PATH/pterodactyl.tar.gz" -C "$INSTALL_PATH"
  76. chmod -R 755 "$INSTALL_PATH/storage" "$INSTALL_PATH/bootstrap/cache"
  77. curl "https://raw.githubusercontent.com/tenten8401/Pterodactyl-Installer/master/templates/Caddyfile" | sed "s/__FQDN__/$FQDN/g; s/__EMAIL__/$EMAIL/g; s/__INSTALL_PATH__/$INSTALL_PATH/g" > /etc/caddy/Caddyfile
  78. rm -f "$INSTALL_PATH/pterodactyl.tar.gz"
  79. cp "$INSTALL_PATH/.env.example" "$INSTALL_PATH/.env"
  80. cd "$INSTALL_PATH"
  81. curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
  82. composer install --no-dev
  83. php artisan key:generate --force
  84. php artisan pterodactyl:env
  85. php artisan pterodactyl:mail
  86. php artisan migrate
  87. else
  88. install_panel
  89. fi
  90. }
  91.  
  92. #config_database() {
  93. # TODO: Do stuff here
  94. #}
  95.  
  96. #install_daemon() {
  97. # TODO: Do stuff here too
  98. #}
  99.  
  100. clear
  101.  
  102. echo -e "
  103. Welcome to the Pterodactyl Auto-Installer for Ubuntu.
  104. This was made for a FRESH install of Ubuntu Server 16.04,
  105. and you may run into issues if you aren't using a fresh install.
  106. Please select what you would like to from the list below:
  107.  
  108. ${red}BE SURE TO MAKE A MYSQL DATABASE & USER BEFORE PROCEEDING.
  109. See https://docs.pterodactyl.io/docs/setting-up-mysql${reset}
  110.  
  111. [1] Install Dependencies
  112. [2] Install Only Panel
  113. [3] Install Only Daemon
  114. [4] Install MariaDB
  115. [5] Full Install (Deps + Panel + Daemon + MariaDB)
  116. [0] Quit
  117. "
  118.  
  119. dispatch() {
  120. echo -n "Enter Selection: "
  121. read software
  122.  
  123. case $software in
  124. 1)
  125. clear
  126. config_ppa
  127. install_deps
  128. ;;
  129. 2 )
  130. clear
  131. config_ppa
  132. install_deps
  133. install_mariadb
  134. install_panel
  135. ;;
  136. 3 )
  137. clear
  138. config_ppa
  139. install_deps
  140. install_daemon
  141. ;;
  142. 4 )
  143. clear
  144. config_ppa
  145. install_mariadb
  146. ;;
  147. 5 )
  148. clear
  149. config_ppa
  150. install_deps
  151. install_mariadb
  152. install_caddy
  153. install_panel
  154. install_daemon
  155. ;;
  156. 0 )
  157. exit 0
  158. ;;
  159. * )
  160. clear
  161. echo "${red}Invalid selection."
  162. dispatch
  163. ;;
  164. esac
  165. }
  166. dispatch
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement