Skip to content

Commit 8fc0a4b

Browse files
committed
Fix error
1 parent ff9a202 commit 8fc0a4b

File tree

1 file changed

+49
-43
lines changed

1 file changed

+49
-43
lines changed

backup.sh

Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,45 @@ if [ -f "${INFORMATIONS}/background.txt" ]; then
2727
fi
2828
}
2929

30-
3130
print_brake() {
3231
for ((n = 0; n < $1; n++)); do
3332
echo -n "#"
3433
done
3534
echo ""
3635
}
3736

37+
print() {
38+
echo ""
39+
echo -e "* ${GREEN}$1${RESET}"
40+
echo ""
41+
}
3842

39-
hyperlink() {
40-
echo -e "\e]8;;${1}\a${1}\e]8;;\a"
43+
print_warning() {
44+
echo ""
45+
echo -e "* ${YELLOW}WARNING${RESET}: $1"
46+
echo ""
4147
}
4248

49+
print_error() {
50+
echo ""
51+
echo -e "* ${RED}ERROR${RESET}: $1"
52+
echo ""
53+
}
4354

44-
#### Colors ####
55+
hyperlink() {
56+
echo -e "\e]8;;${1}\a${1}\e]8;;\a"
57+
}
4558

4659
GREEN="\e[0;92m"
4760
YELLOW="\033[1;33m"
48-
reset="\e[0m"
49-
red='\033[0;31m'
61+
RESET="\e[0m"
62+
RED='\033[0;31m'
5063

5164
#### Find where pterodactyl is installed ####
5265

5366
find_pterodactyl() {
54-
echo
55-
print_brake 47
56-
echo -e "* ${GREEN}Looking for your pterodactyl installation...${reset}"
57-
print_brake 47
58-
echo
67+
print "Looking for your pterodactyl installation..."
68+
5969
sleep 2
6070
if [ -d "/var/www/pterodactyl" ]; then
6171
PTERO_INSTALL=true
@@ -73,85 +83,81 @@ fi
7383
update_variables
7484
}
7585

76-
7786
#### Deletes all files installed by the script ####
7887

7988
delete_files() {
8089
#### THEMES DRACULA, ENOLA AND TWILIGHT ####
8190
if [ -f "$DET" ]; then
82-
rm -r "$DET"
83-
rm -r "$PTERO/resources/scritps/user.css"
91+
rm -rf "$DET"
92+
rm -rf "$PTERO/resources/scripts/user.css"
8493
fi
8594
#### THEMES DRACULA, ENOLA AND TWILIGHT ####
8695

8796
#### THEME ZINGTHEME ####
8897
if [ -f "$ZING" ]; then
89-
rm -r "$ZING"
90-
rm -r "$PTERO/resources/scripts/components/server/files/FileViewer.tsx"
98+
rm -rf "$ZING"
99+
rm -rf "$PTERO/resources/scripts/components/server/files/FileViewer.tsx"
91100
fi
92101
#### THEME ZINGTHEME ####
93102

94103
#### BACKGROUND VIDEO ####
95104
if [ -f "$PTERO/public/$BACKGROUND" ]; then
96105
cd "$PTERO/public" && rm -r "$BACKGROUND"
97-
rm -r "$PTERO/resources/scripts/user.css"
98-
rm -r "$INFORMATIONS"
106+
rm -rf "$PTERO/resources/scripts/user.css"
107+
rm -rf "$INFORMATIONS"
99108
fi
100109
#### BACKGROUND VIDEO ####
101110
}
102111

103-
104112
#### Restore Backup ####
105113

106114
restore() {
107-
echo
108-
print_brake 35
109-
echo -e "* ${GREEN}Checking for a backup...${reset}"
110-
print_brake 35
111-
echo
115+
print "Checking for a backup..."
116+
112117
if [ -d "$PTERO/PanelBackup[Auto-Themes]" ]; then
113118
cd "$PTERO/PanelBackup[Auto-Themes]"
114119
tar -xzvf "PanelBackup[Auto-Themes].tar.gz"
115120
rm -R "PanelBackup[Auto-Themes].tar.gz"
116121
cp -r -- * .env "$PTERO"
117-
rm -r "$PTERO/PanelBackup[Auto-Themes]"
122+
rm -rf "$PTERO/PanelBackup[Auto-Themes]"
118123
else
119-
print_brake 45
120-
echo -e "* ${red}There was no backup to restore, Aborting...${reset}"
121-
print_brake 45
122-
echo
124+
print_error "There was no backup to restore, Aborting..."
123125
exit 1
124126
fi
125127
}
126128

127-
128129
bye() {
129130
print_brake 50
130131
echo
131132
echo -e "${GREEN}* Backup restored successfully!"
132133
echo -e "* Thank you for using this script."
133-
echo -e "* Support group: ${YELLOW}$(hyperlink "$SUPPORT_LINK")${reset}"
134+
echo -e "* Support group: ${YELLOW}$(hyperlink "$SUPPORT_LINK")${RESET}"
134135
echo
135136
print_brake 50
136137
}
137138

138-
139139
#### Exec Script ####
140140
find_pterodactyl
141141
if [ "$PTERO_INSTALL" == true ]; then
142-
echo
143-
print_brake 60
144-
echo -e "* ${GREEN}Installation of the panel found, continuing the backup...${reset}"
145-
print_brake 60
146-
echo
142+
print "Installation of the panel found, continuing the backup..."
147143
delete_files
148144
restore
149145
bye
150146
elif [ "$PTERO_INSTALL" == false ]; then
151-
echo
152-
print_brake 66
153-
echo -e "* ${red}The installation of your panel could not be located, aborting...${reset}"
154-
print_brake 66
155-
echo
156-
exit 1
147+
print_warning "The installation of your panel could not be located."
148+
echo -e "* ${GREEN}EXAMPLE${RESET}: ${YELLOW}/var/www/mypanel${RESET}"
149+
echo -ne "* Enter the pterodactyl installation directory manually: "
150+
read -r MANUAL_DIR
151+
if [ -d "$MANUAL_DIR" ]; then
152+
print "Directory has been found!"
153+
PTERO="$MANUAL_DIR"
154+
echo "$MANUAL_DIR" >> "$INFORMATIONS/custom_directory.txt"
155+
update_variables
156+
delete_files
157+
restore
158+
bye
159+
else
160+
print_error "The directory you entered does not exist."
161+
find_pterodactyl
162+
fi
157163
fi

0 commit comments

Comments
 (0)