Skip to content

Commit 46a6bca

Browse files
committed
fixed issue with update checks
- Fixed issue with checking for updates when there is no response from server
1 parent 6bbac7d commit 46a6bca

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

mysqlbackup-plus.sh

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ fi
129129
# Get the binary locations
130130
MYSQL=$(command -v mysql)
131131
if [ -z "$MYSQL" ]; then
132-
echo "Error: 'mysql' command not found! Please install MySQL or check your PATH."
132+
printf "Error: 'mysql' command not found! Please install MySQL or check your PATH.\n"
133133
exit 1
134134
fi
135135

136136
MYSQLDUMP=$(command -v mysqldump)
137137
if [ -z "$MYSQLDUMP" ]; then
138-
echo "Error: 'mysqldump' command not found! Please install MySQL or check your PATH."
138+
printf "Error: 'mysqldump' command not found! Please install MySQL or check your PATH.\n"
139139
exit 1
140140
fi
141141

@@ -171,16 +171,24 @@ else
171171
printf "\nPlease install curl or wget to check for updates.\n\n"
172172
fi
173173

174-
if [ "$CLIENT_TYPE" = "curl" ]; then
175-
LATEST_VERSION=$("$HTTP_CLIENT" -s --connect-timeout 5 --max-time 5 "$VERSION_URL")
176-
else
177-
LATEST_VERSION=$("$HTTP_CLIENT" -q --connect-timeout=5 --timeout=5 -O - "$VERSION_URL")
178-
fi
174+
# client has curl or wget installed
175+
if [ -n "$CLIENT_TYPE" ]; then
176+
if [ "$CLIENT_TYPE" = "curl" ]; then
177+
LATEST_VERSION=$("$HTTP_CLIENT" -fs --connect-timeout 5 --max-time 5 "$VERSION_URL")
178+
else
179+
LATEST_VERSION=$("$HTTP_CLIENT" -q --connect-timeout=5 --timeout=5 -O - "$VERSION_URL")
180+
fi
179181

180-
if [ "$SCRIPT_VER" != "$LATEST_VERSION" ]; then
181-
printf "\nUpdate available! Latest version: %s\n\n" "$LATEST_VERSION"
182-
else
183-
printf "\nYou are running the latest version.\n\n"
182+
# did we receive a response
183+
if [ -n "$LATEST_VERSION" ]; then
184+
if [ "$SCRIPT_VER" != "$LATEST_VERSION" ]; then
185+
printf "\nUpdate available! Latest version: %s\n\n" "$LATEST_VERSION"
186+
else
187+
printf "\nYou are running the latest version.\n\n"
188+
fi
189+
else
190+
printf "\nCould not retrieve the latest version information from the server.\n\n"
191+
fi
184192
fi
185193

186194
# Analyze and Optimze tables

0 commit comments

Comments
 (0)