Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1153 : improve offline capability #1364

Merged
merged 6 commits into from
Jan 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions scripts/src/main/resources/scripts/functions
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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}"
Expand All @@ -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
diiinesh marked this conversation as resolved.
Show resolved Hide resolved
doUpdateUrls
if [ "$isOnline" = 0 ]
then
doUpdateUrls
fi
if [ -z "${version}" ]
then
version=$(doGetLatestSoftwareVersion "${software}")
Expand Down Expand Up @@ -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 ]
diiinesh marked this conversation as resolved.
Show resolved Hide resolved
then
doDownload "${url}" "${download_dir}" "${software}" "${version}" "${edition}" "${os}" "${arch}" "${ext}" "${target_filename}"
doDebug "Received download file ${DOWNLOAD_FILENAME} with file name ${target_filename}"
Expand Down