Skip to content

Commit 7bf41ce

Browse files
committed
New Theme
1 parent 39273e8 commit 7bf41ce

File tree

4 files changed

+326
-1
lines changed

4 files changed

+326
-1
lines changed

backup.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ SUPPORT_LINK="https://discord.gg/buDBbSGJmQ"
1919
#### Update Variables ####
2020

2121
update_variables() {
22+
INFORMATIONS="/var/log/Pterodactyl-AutoThemes-informations"
2223
DET="$PTERO/resources/scripts/user.css"
2324
ZING="$PTERO/resources/scripts/components/SidePanel.tsx"
25+
if [ -f "${INFORMATIONS}/background.txt" ]; then
26+
BACKGROUND="$(cat "${INFORMATIONS}/background.txt")"
27+
fi
2428
}
2529

2630

@@ -87,6 +91,14 @@ if [ -f "$ZING" ]; then
8791
rm -r "$PTERO/resources/scripts/components/SidePanel.tsx"
8892
fi
8993
#### THEME ZINGTHEME ####
94+
95+
#### BACKGROUND VIDEO ####
96+
if [ -f "$PTERO/public/$BACKGROUND" ]; then
97+
rm -r "$BACKGROUND"
98+
rm -r "$PTERO/resources/scripts/user.css"
99+
rm -r "$INFORMATIONS"
100+
fi
101+
#### BACKGROUND VIDEO ####
90102
}
91103

92104

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ set -e
1212
#
1313
########################################################
1414

15-
SCRIPT_VERSION="v1.1"
15+
SCRIPT_VERSION="v1.3"
1616

1717

1818
print_brake() {
5.57 MB
Binary file not shown.
Lines changed: 313 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,313 @@
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 GPL 3.0 License
13+
#
14+
########################################################
15+
16+
#### Fixed Variables ####
17+
18+
SCRIPT_VERSION="v1.3"
19+
SUPPORT_LINK="https://discord.gg/buDBbSGJmQ"
20+
INFORMATIONS="/var/log/Pterodactyl-AutoThemes-informations"
21+
22+
#### Update Variables ####
23+
24+
update_variables() {
25+
CONFIG_FILE="$PTERO/config/app.php"
26+
PANEL_VERSION="$(cat "$CONFIG_FILE" | grep -n ^ | grep ^12: | cut -d: -f2 | cut -c18-23 | sed "s/'//g")"
27+
VIDEO_FILE="$(cd "$PTERO/public" && find . -iname '*.mp4' | tail -1 | sed "s/.\///g")"
28+
}
29+
30+
31+
print_brake() {
32+
for ((n = 0; n < $1; n++)); do
33+
echo -n "#"
34+
done
35+
echo ""
36+
}
37+
38+
print_warning() {
39+
YELLOW="\033[1;33m"
40+
reset="\e[0m"
41+
echo -e "* ${YELLOW}WARNING${reset}: $1"
42+
echo ""
43+
}
44+
45+
hyperlink() {
46+
echo -e "\e]8;;${1}\a${1}\e]8;;\a"
47+
}
48+
49+
50+
#### Colors ####
51+
52+
GREEN="\e[0;92m"
53+
YELLOW="\033[1;33m"
54+
red='\033[0;31m'
55+
reset="\e[0m"
56+
57+
58+
#### OS check ####
59+
60+
check_distro() {
61+
if [ -f /etc/os-release ]; then
62+
. /etc/os-release
63+
OS=$(echo "$ID" | awk '{print tolower($0)}')
64+
OS_VER=$VERSION_ID
65+
elif type lsb_release >/dev/null 2>&1; then
66+
OS=$(lsb_release -si | awk '{print tolower($0)}')
67+
OS_VER=$(lsb_release -sr)
68+
elif [ -f /etc/lsb-release ]; then
69+
. /etc/lsb-release
70+
OS=$(echo "$DISTRIB_ID" | awk '{print tolower($0)}')
71+
OS_VER=$DISTRIB_RELEASE
72+
elif [ -f /etc/debian_version ]; then
73+
OS="debian"
74+
OS_VER=$(cat /etc/debian_version)
75+
elif [ -f /etc/SuSe-release ]; then
76+
OS="SuSE"
77+
OS_VER="?"
78+
elif [ -f /etc/redhat-release ]; then
79+
OS="Red Hat/CentOS"
80+
OS_VER="?"
81+
else
82+
OS=$(uname -s)
83+
OS_VER=$(uname -r)
84+
fi
85+
86+
OS=$(echo "$OS" | awk '{print tolower($0)}')
87+
OS_VER_MAJOR=$(echo "$OS_VER" | cut -d. -f1)
88+
}
89+
90+
#### Find where pterodactyl is installed ####
91+
92+
find_pterodactyl() {
93+
echo
94+
print_brake 47
95+
echo -e "* ${GREEN}Looking for your pterodactyl installation...${reset}"
96+
print_brake 47
97+
echo
98+
sleep 2
99+
if [ -d "/var/www/pterodactyl" ]; then
100+
PTERO_INSTALL=true
101+
PTERO="/var/www/pterodactyl"
102+
elif [ -d "/var/www/panel" ]; then
103+
PTERO_INSTALL=true
104+
PTERO="/var/www/panel"
105+
elif [ -d "/var/www/ptero" ]; then
106+
PTERO_INSTALL=true
107+
PTERO="/var/www/ptero"
108+
else
109+
PTERO_INSTALL=false
110+
fi
111+
# Update the variables after detection of the pterodactyl installation #
112+
update_variables
113+
}
114+
115+
#### Verify Compatibility ####
116+
117+
compatibility() {
118+
echo
119+
print_brake 57
120+
echo -e "* ${GREEN}Checking if the addon is compatible with your panel...${reset}"
121+
print_brake 57
122+
echo
123+
sleep 2
124+
if [ -f "$CONFIG_FILE" ]; then
125+
if [ "$PANEL_VERSION" == "1.6.6" ]; then
126+
echo
127+
print_brake 23
128+
echo -e "* ${GREEN}Compatible Version!${reset}"
129+
print_brake 23
130+
echo
131+
elif [ "$PANEL_VERSION" == "1.7.0" ]; then
132+
echo
133+
print_brake 23
134+
echo -e "* ${GREEN}Compatible Version!${reset}"
135+
print_brake 23
136+
echo
137+
else
138+
echo
139+
print_brake 24
140+
echo -e "* ${red}Incompatible Version!${reset}"
141+
print_brake 24
142+
echo
143+
exit 1
144+
fi
145+
fi
146+
}
147+
148+
149+
#### Install Dependencies ####
150+
151+
dependencies() {
152+
echo
153+
print_brake 30
154+
echo -e "* ${GREEN}Installing dependencies...${reset}"
155+
print_brake 30
156+
echo
157+
case "$OS" in
158+
debian | ubuntu)
159+
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - && apt-get install -y nodejs
160+
;;
161+
centos)
162+
[ "$OS_VER_MAJOR" == "7" ] && curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash - && sudo yum install -y nodejs yarn
163+
[ "$OS_VER_MAJOR" == "8" ] && curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash - && sudo dnf install -y nodejs
164+
;;
165+
esac
166+
}
167+
168+
169+
#### Panel Backup ####
170+
171+
backup() {
172+
echo
173+
print_brake 32
174+
echo -e "* ${GREEN}Performing security backup...${reset}"
175+
print_brake 32
176+
if [ -d "$PTERO/PanelBackup[Auto-Themes]" ]; then
177+
echo
178+
print_brake 45
179+
echo -e "* ${GREEN}There is already a backup, skipping step...${reset}"
180+
print_brake 45
181+
echo
182+
else
183+
cd "$PTERO"
184+
if [ -d "$PTERO/node_modules" ]; then
185+
tar -czvf "PanelBackup[Auto-Themes].tar.gz" --exclude "node_modules" -- * .env
186+
mkdir -p "PanelBackup[Auto-Themes]"
187+
mv "PanelBackup[Auto-Themes].tar.gz" "PanelBackup[Auto-Themes]"
188+
else
189+
tar -czvf "PanelBackup[Auto-Themes].tar.gz" -- * .env
190+
mkdir -p "PanelBackup[Auto-Themes]"
191+
mv "PanelBackup[Auto-Themes].tar.gz" "PanelBackup[Auto-Themes]"
192+
fi
193+
fi
194+
}
195+
196+
197+
#### Download Files ####
198+
199+
download_files() {
200+
echo
201+
print_brake 25
202+
echo -e "* ${GREEN}Downloading files...${reset}"
203+
print_brake 25
204+
echo
205+
cd "$PTERO"
206+
mkdir -p temp
207+
cd temp
208+
curl -sSLo BackgroundVideo.tar.gz https://raw.githubusercontent.com/Ferks-FK/Pterodactyl-AutoThemes/${SCRIPT_VERSION}/themes/version1.x/BackgroundVideo/BackgroundVideo.tar.gz
209+
tar -xzvf BackgroundVideo.tar.gz
210+
cd BackgroundVideo
211+
cp -rf -- * "$PTERO"
212+
cd "$PTERO"
213+
rm -r temp
214+
}
215+
216+
#### Detect if the user has passed your video file in mp4 format ####
217+
218+
detect_video() {
219+
echo
220+
echo -e "* Please open your FTP manager, and upload your video file to the background."
221+
echo -e "* Upload it to ${GREEN}${PTERO}/public${reset}"
222+
echo
223+
print_warning "Your video can have any name, but must be in ${GREEN}.mp4${reset} format."
224+
echo -n -e "* Once you successfully upload the video, press ${GREEN}ENTER${reset} for the script to continue."
225+
read -r
226+
while [ -z "$VIDEO_FILE" ]; do
227+
update_variables
228+
echo
229+
print_warning "Unable to locate your video file, please check that it is in the correct directory."
230+
echo -e "* New check in 5 seconds..."
231+
sleep 5
232+
find . -iname '*.mp4' | tail -1 &>/dev/null
233+
done
234+
echo -n -e "* The file ${GREEN}$VIDEO_FILE${reset} have been found, is that correct? (y/N): "
235+
read -r CHECK_VIDEO
236+
if [[ "$CHECK_VIDEO" =~ [Yy] ]]; then
237+
# Configure #
238+
sed -i "5a\import './user.css';" "$PTERO/resources/scripts/index.tsx"
239+
sed -i -e "s@<VIDEO_NAME>@$VIDEO_FILE@g" "$PTERO/resources/scripts/components/App.tsx"
240+
elif [[ "$CHECK_VIDEO" =~ [Nn] ]]; then
241+
rm -r "$PTERO/public/$VIDEO_FILE"
242+
VIDEO_FILE=""
243+
detect_video
244+
fi
245+
}
246+
247+
#### Write the informations to a file for a safety check of the backup script ####
248+
249+
write_informations() {
250+
mkdir -p "$INFORMATIONS"
251+
# Write the filename to a file for the backup script to proceed later #
252+
echo "$VIDEO_FILE" >> "$INFORMATIONS/background.txt"
253+
}
254+
255+
#### Panel Production ####
256+
257+
production() {
258+
echo
259+
print_brake 25
260+
echo -e "* ${GREEN}Producing panel...${reset}"
261+
print_brake 25
262+
echo
263+
if [ -d "$PTERO/node_modules" ]; then
264+
cd "$PTERO"
265+
yarn add @emotion/react
266+
yarn build:production
267+
else
268+
npm i -g yarn
269+
cd "$PTERO"
270+
yarn install
271+
yarn add @emotion/react
272+
yarn build:production
273+
fi
274+
}
275+
276+
277+
bye() {
278+
print_brake 50
279+
echo
280+
echo -e "${GREEN}* The theme ${YELLOW}Background Video${GREEN} was successfully installed."
281+
echo -e "* A security backup of your panel has been created."
282+
echo -e "* Thank you for using this script."
283+
echo -e "* Support group: ${YELLOW}$(hyperlink "$SUPPORT_LINK")${reset}"
284+
echo
285+
print_brake 50
286+
}
287+
288+
289+
#### Exec Script ####
290+
check_distro
291+
find_pterodactyl
292+
if [ "$PTERO_INSTALL" == true ]; then
293+
echo
294+
print_brake 66
295+
echo -e "* ${GREEN}Installation of the panel found, continuing the installation...${reset}"
296+
print_brake 66
297+
echo
298+
compatibility
299+
dependencies
300+
backup
301+
download_files
302+
detect_video
303+
write_informations
304+
production
305+
bye
306+
elif [ "$PTERO_INSTALL" == false ]; then
307+
echo
308+
print_brake 66
309+
echo -e "* ${red}The installation of your panel could not be located, aborting...${reset}"
310+
print_brake 66
311+
echo
312+
exit 1
313+
fi

0 commit comments

Comments
 (0)