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
244 lines (215 loc) · 6.1 KB
/
build.sh
File metadata and controls
244 lines (215 loc) · 6.1 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
#!/bin/bash
# shellcheck source=/dev/null
set -e
########################################################
#
# Pterodactyl-AutoThemes Installation
#
# Created and maintained by Ferks-FK
#
# Protected by MIT License
#
########################################################
# Get the latest version before running the script #
get_release() {
curl --silent \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/Ferks-FK/Pterodactyl-AutoThemes/releases/latest |
grep '"tag_name":' |
sed -E 's/.*"([^"]+)".*/\1/'
}
# Fixed Variables #
SCRIPT_VERSION="$(get_release)"
SUPPORT_LINK="https://discord.gg/buDBbSGJmQ"
# Update Variables #
update_variables() {
CONFIG_FILE="$PTERO/config/app.php"
PANEL_VERSION="$(grep "'version'" "$CONFIG_FILE" | cut -c18-25 | sed "s/[',]//g")"
}
# Visual Functions #
print_brake() {
for ((n = 0; n < $1; n++)); do
echo -n "#"
done
echo ""
}
print_warning() {
echo ""
echo -e "* ${YELLOW}WARNING${RESET}: $1"
echo ""
}
print_error() {
echo ""
echo -e "* ${RED}ERROR${RESET}: $1"
echo ""
}
print() {
echo ""
echo -e "* ${GREEN}$1${RESET}"
echo ""
}
hyperlink() {
echo -e "\e]8;;${1}\a${1}\e]8;;\a"
}
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() {
print "Looking for your pterodactyl installation..."
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
# Update the variables after detection of the pterodactyl installation #
update_variables
}
# Verify Compatibility #
compatibility() {
print "Checking if the addon is compatible with your panel..."
sleep 2
if [ "$PANEL_VERSION" == "1.7.0" ] || [ "$PANEL_VERSION" == "1.8.1" ]; then
print "Compatible Version!"
else
print_error "Incompatible Version!"
exit 1
fi
}
# Install Dependencies #
dependencies() {
print "Installing dependencies..."
if node -v &>/dev/null; then
print "The dependencies are already installed, skipping this step..."
else
case "$OS" in
debian | ubuntu)
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - && apt-get install -y nodejs
;;
centos)
[ "$OS_VER_MAJOR" == "7" ] && curl -sL https://rpm.nodesource.com/setup_14.x | sudo -E bash - && sudo yum install -y nodejs yarn
[ "$OS_VER_MAJOR" == "8" ] && curl -sL https://rpm.nodesource.com/setup_14.x | sudo -E bash - && sudo dnf install -y nodejs
;;
esac
fi
}
# Panel Backup #
backup() {
print "Performing security backup..."
if [ -d "$PTERO/PanelBackup[Auto-Themes]" ]; then
print "There is already a backup, skipping step..."
else
cd $PTERO
if [ -d "$PTERO/node_modules" ]; then
tar -czvf "PanelBackup[Auto-Themes].tar.gz" --exclude "node_modules" -- * .env
mkdir -p "$PTERO/PanelBackup[Auto-Themes]"
mv "$PTERO/PanelBackup[Auto-Themes].tar.gz" "$PTERO/PanelBackup[Auto-Themes]"
else
tar -czvf "PanelBackup[Auto-Themes].tar.gz" -- * .env
mkdir -p "$PTERO/PanelBackup[Auto-Themes]"
mv "$PTERO/PanelBackup[Auto-Themes].tar.gz" "$PTERO/PanelBackup[Auto-Themes]"
fi
fi
}
# Download Files #
download_files() {
print "Downloading files..."
mkdir -p $PTERO/temp
curl -sSLo $PTERO/temp/FlancoTheme.tar.gz https://raw.githubusercontent.com/Ferks-FK/Pterodactyl-AutoThemes/"${SCRIPT_VERSION}"/themes/version1.x/FlancoTheme/FlancoTheme.tar.gz
tar -xzvf $PTERO/temp/FlancoTheme.tar.gz -C $PTERO/temp
cp -rf -- $PTERO/temp/FlancoTheme/* $PTERO
rm -rf $PTERO/temp
}
# Panel Production #
production() {
print "Producing panel..."
print_warning "This process takes a few minutes, please do not cancel it."
if [ -d "$PTERO/node_modules" ]; then
yarn --cwd $PTERO add @emotion/react
yarn --cwd $PTERO build:production
else
npm i -g yarn
yarn --cwd $PTERO install
yarn --cwd $PTERO add @emotion/react
yarn --cwd $PTERO 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
print "Installation of the panel found, continuing the installation..."
compatibility
dependencies
backup
download_files
production
bye
elif [ "$PTERO_INSTALL" == false ]; then
print_warning "The installation of your panel could not be located."
echo -e "* ${GREEN}EXAMPLE${RESET}: ${YELLOW}/var/www/mypanel${RESET}"
echo -ne "* Enter the pterodactyl installation directory manually: "
read -r MANUAL_DIR
if [ -d "$MANUAL_DIR" ]; then
print "Directory has been found!"
PTERO="$MANUAL_DIR"
update_variables
compatibility
dependencies
backup
download_files
production
bye
else
print_error "The directory you entered does not exist."
find_pterodactyl
fi
fi