1+ #! /bin/bash
2+ # shellcheck source=/dev/null
3+
4+ set -e
5+
6+ # #######################################################
7+ #
8+ # Pterodactyl-AutoThemes Installation
9+ #
10+ # Created and maintained by Ferks-FK
11+ #
12+ # Protected by MIT License
13+ #
14+ # #######################################################
15+
16+ # Get the latest version before running the script #
17+ get_release () {
18+ curl --silent \
19+ -H " Accept: application/vnd.github.v3+json" \
20+ https://api.github.com/repos/Ferks-FK/Pterodactyl-AutoThemes/releases/latest |
21+ grep ' "tag_name":' |
22+ sed -E ' s/.*"([^"]+)".*/\1/'
23+ }
24+
25+ # Fixed Variables #
26+ SCRIPT_VERSION=" $( get_release) "
27+ SUPPORT_LINK=" https://discord.gg/buDBbSGJmQ"
28+
29+ # Update Variables #
30+ update_variables () {
31+ CONFIG_FILE=" $PTERO /config/app.php"
32+ PANEL_VERSION=" $( grep " 'version'" " $CONFIG_FILE " | cut -c18-25 | sed " s/[',]//g" ) "
33+ }
34+
35+ # Visual Functions #
36+ print_brake () {
37+ for (( n = 0 ; n < $1 ; n++ )) ; do
38+ echo -n " #"
39+ done
40+ echo " "
41+ }
42+
43+ print_warning () {
44+ echo " "
45+ echo -e " * ${YELLOW} WARNING${RESET} : $1 "
46+ echo " "
47+ }
48+
49+ print_error () {
50+ echo " "
51+ echo -e " * ${RED} ERROR${RESET} : $1 "
52+ echo " "
53+ }
54+
55+ print () {
56+ echo " "
57+ echo -e " * ${GREEN} $1 ${RESET} "
58+ echo " "
59+ }
60+
61+ hyperlink () {
62+ echo -e " \e]8;;${1} \a${1} \e]8;;\a"
63+ }
64+
65+ GREEN=" \e[0;92m"
66+ YELLOW=" \033[1;33m"
67+ RED=' \033[0;31m'
68+ RESET=" \e[0m"
69+
70+ # OS check #
71+ check_distro () {
72+ if [ -f /etc/os-release ]; then
73+ . /etc/os-release
74+ OS=$( echo " $ID " | awk ' {print tolower($0)}' )
75+ OS_VER=$VERSION_ID
76+ elif type lsb_release > /dev/null 2>&1 ; then
77+ OS=$( lsb_release -si | awk ' {print tolower($0)}' )
78+ OS_VER=$( lsb_release -sr)
79+ elif [ -f /etc/lsb-release ]; then
80+ . /etc/lsb-release
81+ OS=$( echo " $DISTRIB_ID " | awk ' {print tolower($0)}' )
82+ OS_VER=$DISTRIB_RELEASE
83+ elif [ -f /etc/debian_version ]; then
84+ OS=" debian"
85+ OS_VER=$( cat /etc/debian_version)
86+ elif [ -f /etc/SuSe-release ]; then
87+ OS=" SuSE"
88+ OS_VER=" ?"
89+ elif [ -f /etc/redhat-release ]; then
90+ OS=" Red Hat/CentOS"
91+ OS_VER=" ?"
92+ else
93+ OS=$( uname -s)
94+ OS_VER=$( uname -r)
95+ fi
96+
97+ OS=$( echo " $OS " | awk ' {print tolower($0)}' )
98+ OS_VER_MAJOR=$( echo " $OS_VER " | cut -d. -f1)
99+ }
100+
101+ # Find where pterodactyl is installed #
102+ find_pterodactyl () {
103+ print " Looking for your pterodactyl installation..."
104+
105+ sleep 2
106+ if [ -d " /var/www/pterodactyl" ]; then
107+ PTERO_INSTALL=true
108+ PTERO=" /var/www/pterodactyl"
109+ elif [ -d " /var/www/panel" ]; then
110+ PTERO_INSTALL=true
111+ PTERO=" /var/www/panel"
112+ elif [ -d " /var/www/ptero" ]; then
113+ PTERO_INSTALL=true
114+ PTERO=" /var/www/ptero"
115+ else
116+ PTERO_INSTALL=false
117+ fi
118+ # Update the variables after detection of the pterodactyl installation #
119+ update_variables
120+ }
121+
122+ # Verify Compatibility #
123+ compatibility () {
124+ print " Checking if the addon is compatible with your panel..."
125+
126+ sleep 2
127+ if [ " $PANEL_VERSION " == " 1.6.6" ] || [ " $PANEL_VERSION " == " 1.7.0" ]; then
128+ print " Compatible Version!"
129+ else
130+ print_error " Incompatible Version!"
131+ exit 1
132+ fi
133+ }
134+
135+ # Install Dependencies #
136+ dependencies () {
137+ print " Installing dependencies..."
138+
139+ if node -v & > /dev/null; then
140+ print " The dependencies are already installed, skipping this step..."
141+ else
142+ case " $OS " in
143+ debian | ubuntu)
144+ curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - && apt-get install -y nodejs
145+ ;;
146+ centos)
147+ [ " $OS_VER_MAJOR " == " 7" ] && curl -sL https://rpm.nodesource.com/setup_14.x | sudo -E bash - && sudo yum install -y nodejs yarn
148+ [ " $OS_VER_MAJOR " == " 8" ] && curl -sL https://rpm.nodesource.com/setup_14.x | sudo -E bash - && sudo dnf install -y nodejs
149+ ;;
150+ esac
151+ fi
152+ }
153+
154+ # Panel Backup #
155+ backup () {
156+ print " Performing security backup..."
157+
158+ if [ -d " $PTERO /PanelBackup[Auto-Addons]" ]; then
159+ print " There is already a backup, skipping step..."
160+ else
161+ cd $PTERO
162+ if [ -d " $PTERO /node_modules" ]; then
163+ tar -czvf " PanelBackup[Auto-Addons].tar.gz" --exclude " node_modules" -- * .env
164+ mkdir -p " $PTERO /PanelBackup[Auto-Addons]"
165+ mv " $PTERO /PanelBackup[Auto-Addons].tar.gz" " $PTERO /PanelBackup[Auto-Addons]"
166+ else
167+ tar -czvf " PanelBackup[Auto-Addons].tar.gz" -- * .env
168+ mkdir -p " $PTERO /PanelBackup[Auto-Addons]"
169+ mv " $PTERO /PanelBackup[Auto-Addons].tar.gz" " $PTERO /PanelBackup[Auto-Addons]"
170+ fi
171+ fi
172+ }
173+
174+ # Download Files #
175+ download_files () {
176+ print " Downloading files..."
177+
178+ mkdir -p $PTERO /temp
179+ curl -sSLo $PTERO /temp/AnimatedGraphics.tar.gz https://raw.githubusercontent.com/Ferks-FK/Pterodactyl-AutoThemes/" ${SCRIPT_VERSION} " /themes/version1.x/AnimatedGraphics/AnimatedGraphics.tar.gz
180+ tar -xzvf $PTERO /temp/AnimatedGraphics.tar.gz -C $PTERO /temp
181+ cp -rf -- $PTERO /temp/AnimatedGraphics/* $PTERO
182+ rm -rf $PTERO /temp
183+ }
184+
185+ # Panel Production #
186+ production () {
187+ print " Producing panel..."
188+ print_warning " This process takes a few minutes, please do not cancel it."
189+
190+ if [ -d " $PTERO /node_modules" ]; then
191+ yarn --cwd $PTERO build:production
192+ else
193+ npm i -g yarn
194+ yarn --cwd $PTERO install
195+ yarn --cwd $PTERO build:production
196+ fi
197+ }
198+
199+ bye () {
200+ print_brake 50
201+ echo
202+ echo -e " ${GREEN} * The theme ${YELLOW} Animated Graphics${GREEN} was successfully installed."
203+ echo -e " * A security backup of your panel has been created."
204+ echo -e " * Thank you for using this script."
205+ echo -e " * Support group: ${YELLOW} $( hyperlink " $SUPPORT_LINK " ) ${RESET} "
206+ echo
207+ print_brake 50
208+ }
209+
210+ # Exec Script #
211+ check_distro
212+ find_pterodactyl
213+ if [ " $PTERO_INSTALL " == true ]; then
214+ print " Installation of the panel found, continuing the installation..."
215+
216+ compatibility
217+ dependencies
218+ backup
219+ download_files
220+ production
221+ bye
222+ elif [ " $PTERO_INSTALL " == false ]; then
223+ print_warning " The installation of your panel could not be located."
224+ echo -e " * ${GREEN} EXAMPLE${RESET} : ${YELLOW} /var/www/mypanel${RESET} "
225+ echo -ne " * Enter the pterodactyl installation directory manually: "
226+ read -r MANUAL_DIR
227+ if [ -d " $MANUAL_DIR " ]; then
228+ print " Directory has been found!"
229+ PTERO=" $MANUAL_DIR "
230+ echo " $MANUAL_DIR " >> " $INFORMATIONS /custom_directory.txt"
231+ update_variables
232+ compatibility
233+ dependencies
234+ backup
235+ download_files
236+ production
237+ bye
238+ else
239+ print_error " The directory you entered does not exist."
240+ find_pterodactyl
241+ fi
242+ fi
0 commit comments