-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
95 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
From 8dbd26d746f8812694084e152f5ec79717eb4b44 Mon Sep 17 00:00:00 2001 | ||
From: diiinesh <[email protected]> | ||
Date: Fri, 13 Oct 2023 14:27:05 +0200 | ||
Subject: [PATCH] #1153 - Implemented a check to see whether user is online and | ||
adjusted the conditions for executing the functions doGitPullOrClone, | ||
DoUpdateUrls and doDownload when user is online, otherwise skip these | ||
functions. | ||
|
||
Signed-off-by: diiinesh <[email protected]> | ||
--- | ||
scripts/src/main/resources/scripts/functions | 22 +++++++++++++++++--- | ||
1 file changed, 19 insertions(+), 3 deletions(-) | ||
|
||
diff --git a/scripts/src/main/resources/scripts/functions b/scripts/src/main/resources/scripts/functions | ||
index 5ba30b2..1f5ec6e 100755 | ||
--- a/scripts/src/main/resources/scripts/functions | ||
+++ b/scripts/src/main/resources/scripts/functions | ||
@@ -1257,6 +1257,15 @@ function doGitPullOrClone() { | ||
fi | ||
} | ||
|
||
+# checks network connectivity status | ||
+function checkNetworkStatus() { | ||
+ if curl -s --head --fail https://www.google.com > /dev/null; then | ||
+ return 0 # Online | ||
+ else | ||
+ return 1 # Offline | ||
+ fi | ||
+} | ||
+ | ||
# $1: name of software | ||
# $2: version of software | ||
# $3: optional silent flag ('silent' to suppress output if already up-to-date or empty for version output) | ||
@@ -1279,6 +1288,10 @@ function doInstall() { | ||
local repository="${8}" | ||
local url="${9}" | ||
local target_filename="${10}" | ||
+ | ||
+ checkNetworkStatus | ||
+ local isOnline=$? | ||
+ | ||
if [ -z "${target_path}" ] | ||
then | ||
target_path="${DEVON_IDE_HOME}/software/${software}" | ||
@@ -1291,12 +1304,15 @@ function doInstall() { | ||
doFail "Missing software argument for doInstall: ${*}" | ||
fi | ||
local result=0 | ||
- if [ "${url/.git/}" != "${url}" ] | ||
+ if [ "${url/.git/}" != "${url}" ] && [ "$isOnline" = 0 ] | ||
then | ||
doGitPullOrClone "${target_path}" "${url}" | ||
return | ||
fi | ||
- doUpdateUrls | ||
+ if [ "$isOnline" = 0 ] | ||
+ then | ||
+ doUpdateUrls | ||
+ fi | ||
if [ -z "${version}" ] | ||
then | ||
version=$(doGetLatestSoftwareVersion "${software}") | ||
@@ -1381,7 +1397,7 @@ function doInstall() { | ||
install_path="${DEVON_SOFTWARE_PATH}/${repo}/${software}/${version}" | ||
version_file="${install_path}/.devon.software.version" | ||
fi | ||
- if [ ! -d "${install_path}" ] || [ "${install_path}" == "${target_path}" ] | ||
+ if [ ! -d "${install_path}" ] || [ "${install_path}" == "${target_path}" ] && [ "$isOnline" = 0 ] | ||
then | ||
doDownload "${url}" "${download_dir}" "${software}" "${version}" "${edition}" "${os}" "${arch}" "${ext}" "${target_filename}" | ||
doDebug "Received download file ${DOWNLOAD_FILENAME} with file name ${target_filename}" | ||
-- | ||
2.40.0.windows.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters