forked from Ferks-FK/Pterodactyl-AutoThemes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
260 lines (224 loc) · 5.45 KB
/
build.sh
File metadata and controls
260 lines (224 loc) · 5.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#!/bin/bash
# shellcheck source=/dev/null
set -e
########################################################
#
# Pterodactyl-AutoThemes Installation
#
# Created and maintained by Ferks-FK
#
# Protected by GPL 3.0 License
#
########################################################
#### Variables ####
SCRIPT_VERSION="v0.8.8"
SUPPORT_LINK="https://discord.gg/buDBbSGJmQ"
PTERO="/var/www/pterodactyl"
print_brake() {
for ((n = 0; n < $1; n++)); do
echo -n "#"
done
echo ""
}
hyperlink() {
echo -e "\e]8;;${1}\a${1}\e]8;;\a"
}
#### Colors ####
GREEN="\e[0;92m"
YELLOW="\033[1;33m"
red='\033[0;31m'
reset="\e[0m"
#### OS check ####
check_distro() {
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$(echo "$ID" | awk '{print tolower($0)}')
OS_VER=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
OS=$(lsb_release -si | awk '{print tolower($0)}')
OS_VER=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
. /etc/lsb-release
OS=$(echo "$DISTRIB_ID" | awk '{print tolower($0)}')
OS_VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
OS="debian"
OS_VER=$(cat /etc/debian_version)
elif [ -f /etc/SuSe-release ]; then
OS="SuSE"
OS_VER="?"
elif [ -f /etc/redhat-release ]; then
OS="Red Hat/CentOS"
OS_VER="?"
else
OS=$(uname -s)
OS_VER=$(uname -r)
fi
OS=$(echo "$OS" | awk '{print tolower($0)}')
OS_VER_MAJOR=$(echo "$OS_VER" | cut -d. -f1)
}
#### Find where pterodactyl is installed ####
find_pterodactyl() {
echo
print_brake 47
echo -e "* ${GREEN}Looking for your pterodactyl installation...${reset}"
print_brake 47
echo
sleep 2
if [ -d "/var/www/pterodactyl" ]; then
PTERO_INSTALL=true
PTERO="/var/www/pterodactyl"
elif [ -d "/var/www/panel" ]; then
PTERO_INSTALL=true
PTERO="/var/www/panel"
elif [ -d "/var/www/ptero" ]; then
PTERO_INSTALL=true
PTERO="/var/www/ptero"
else
PTERO_INSTALL=false
fi
}
#### Verify Compatibility ####
compatibility() {
echo
print_brake 57
echo -e "* ${GREEN}Checking if the theme is compatible with your panel...${reset}"
print_brake 57
echo
sleep 2
DIR="$PTERO/config/app.php"
VERSION="1.6.6"
if [ -f "$DIR" ]; then
CODE=$(cat "$DIR" | grep -n ^ | grep ^12: | cut -d: -f2 | cut -c18-23 | sed "s/'//g")
if [ "$VERSION" == "$CODE" ]; then
echo
print_brake 23
echo -e "* ${GREEN}Compatible Version!${reset}"
print_brake 23
echo
else
echo
print_brake 24
echo -e "* ${red}Incompatible Version!${reset}"
print_brake 24
echo
exit 1
fi
else
echo
print_brake 26
echo -e "* ${red}The file doesn't exist!${reset}"
print_brake 26
echo
exit 1
fi
}
#### Install Dependencies ####
dependencies() {
echo
print_brake 30
echo -e "* ${GREEN}Installing dependencies...${reset}"
print_brake 30
echo
case "$OS" in
debian | ubuntu)
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - && apt-get install -y nodejs && sudo apt-get install -y zip
;;
esac
if [ "$OS_VER_MAJOR" == "7" ]; then
curl -sL https://rpm.nodesource.com/setup_14.x | sudo -E bash - && sudo yum install -y nodejs yarn && sudo yum install -y zip
fi
if [ "$OS_VER_MAJOR" == "8" ]; then
curl -sL https://rpm.nodesource.com/setup_14.x | sudo -E bash - && sudo dnf install -y nodejs && sudo dnf install -y zip
fi
}
#### Panel Backup ####
backup() {
echo
print_brake 32
echo -e "* ${GREEN}Performing security backup...${reset}"
print_brake 32
if [ -f "$PTERO/PanelBackup/PanelBackup.zip" ]; then
echo
print_brake 45
echo -e "* ${GREEN}There is already a backup, skipping step...${reset}"
print_brake 45
echo
else
cd "$PTERO"
if [ -d "$PTERO/node_modules" ]; then
rm -r "$PTERO/node_modules"
fi
mkdir -p PanelBackup
zip -r PanelBackup.zip -- * .env
mv PanelBackup.zip PanelBackup
fi
}
#### Download Files ####
download_files() {
echo
print_brake 25
echo -e "* ${GREEN}Downloading files...${reset}"
print_brake 25
echo
cd "$PTERO"
mkdir -p temp
cd temp
curl -sSLo FlancoTheme.tar.gz https://raw.githubusercontent.com/Ferks-FK/Pterodactyl-AutoThemes/${SCRIPT_VERSION}/themes/version1.x/FlancoTheme/FlancoTheme.tar.gz
tar -xzvf FlancoTheme.tar.gz
cd FlancoTheme
cp -rf -- * "$PTERO"
cd "$PTERO"
rm -rf temp
}
#### Panel Production ####
production() {
echo
print_brake 25
echo -e "* ${GREEN}Producing panel...${reset}"
print_brake 25
if [ -d "$PTERO/node_modules" ]; then
cd "$PTERO"
yarn add @emotion/react
yarn build:production
else
npm i -g yarn
cd "$PTERO"
yarn install
yarn add @emotion/react
yarn build:production
fi
}
bye() {
print_brake 50
echo
echo -e "* ${GREEN}The theme ${YELLOW}Flanco Theme${GREEN} was successfully installed."
echo -e "* A security backup of your panel has been created."
echo -e "* Thank you for using this script."
echo -e "* Support group: ${YELLOW}$(hyperlink "$SUPPORT_LINK")${reset}"
echo
print_brake 50
}
#### Exec Script ####
check_distro
find_pterodactyl
if [ "$PTERO_INSTALL" == true ]; then
echo
print_brake 66
echo -e "* ${GREEN}Installation of the panel found, continuing the installation...${reset}"
print_brake 66
echo
compatibility
dependencies
backup
download_files
production
bye
elif [ "$PTERO_INSTALL" == false ]; then
echo
print_brake 66
echo -e "* ${red}The installation of your panel could not be located, aborting...${reset}"
print_brake 66
echo
exit 1
fi