This repository has been archived by the owner on Sep 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathbackup.sh
161 lines (137 loc) · 3.71 KB
/
backup.sh
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
#!/bin/bash
set -e
########################################################
#
# Pterodactyl-AutoThemes Installation
#
# Created and maintained by Ferks-FK
#
# Protected by GPL 3.0 License
#
########################################################
#### Fixed Variables ####
SUPPORT_LINK="https://discord.gg/buDBbSGJmQ"
#### Update Variables ####
update_variables() {
INFORMATIONS="/var/log/Pterodactyl-AutoThemes-informations"
DET="$PTERO/public/themes/pterodactyl/css/admin.css"
ZING="$PTERO/resources/scripts/components/SidePanel.tsx"
if [ -f "${INFORMATIONS}/background.txt" ]; then BACKGROUND="$(cat "${INFORMATIONS}/background.txt")"; fi
}
print_brake() {
for ((n = 0; n < $1; n++)); do
echo -n "#"
done
echo ""
}
print() {
echo ""
echo -e "* ${GREEN}$1${RESET}"
echo ""
}
print_warning() {
echo ""
echo -e "* ${YELLOW}WARNING${RESET}: $1"
echo ""
}
print_error() {
echo ""
echo -e "* ${RED}ERROR${RESET}: $1"
echo ""
}
hyperlink() {
echo -e "\e]8;;${1}\a${1}\e]8;;\a"
}
GREEN="\e[0;92m"
YELLOW="\033[1;33m"
RESET="\e[0m"
RED='\033[0;31m'
#### 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
}
#### Deletes all files installed by the script ####
delete_files() {
#### THEMES DRACULA, ENOLA AND TWILIGHT ####
if [ -f "$DET" ]; then
rm -rf "$DET"
rm -rf "$PTERO/resources/scripts/user.css"
fi
#### THEMES DRACULA, ENOLA AND TWILIGHT ####
#### THEME ZINGTHEME ####
if [ -f "$ZING" ]; then
rm -rf "$ZING"
rm -rf "$PTERO/resources/scripts/components/server/files/FileViewer.tsx"
fi
#### THEME ZINGTHEME ####
#### BACKGROUND VIDEO ####
if [ -f "$PTERO/public/$BACKGROUND" ]; then
rm -rf "$PTERO/public/$BACKGROUND"
rm -rf "$PTERO/resources/scripts/user.css"
rm -rf "$INFORMATIONS"
fi
#### BACKGROUND VIDEO ####
}
#### Restore Backup ####
restore() {
print "Checking for a backup..."
if [ -d "$PTERO/PanelBackup[Auto-Themes]" ]; then
cd "$PTERO/PanelBackup[Auto-Themes]"
tar -xzvf "$PTERO/PanelBackup[Auto-Themes]/PanelBackup[Auto-Themes].tar.gz"
rm -rf "$PTERO/PanelBackup[Auto-Themes]/PanelBackup[Auto-Themes].tar.gz"
cp -r -- * .env "$PTERO"
rm -rf "$PTERO/PanelBackup[Auto-Themes]"
else
print_error "There was no backup to restore, Aborting..."
exit 1
fi
}
bye() {
print_brake 50
echo
echo -e "${GREEN}* Backup restored successfully!"
echo -e "* Thank you for using this script."
echo -e "* Support group: ${YELLOW}$(hyperlink "$SUPPORT_LINK")${RESET}"
echo
print_brake 50
}
#### Exec Script ####
find_pterodactyl
if [ "$PTERO_INSTALL" == true ]; then
print "Installation of the panel found, continuing the backup..."
delete_files
restore
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"
echo "$MANUAL_DIR" >> "$INFORMATIONS/custom_directory.txt"
update_variables
delete_files
restore
bye
else
print_error "The directory you entered does not exist."
find_pterodactyl
fi
fi