diff --git a/src/_cli_common_utilities.sh b/src/_cli_common_utilities.sh index 940577f..d33549f 100644 --- a/src/_cli_common_utilities.sh +++ b/src/_cli_common_utilities.sh @@ -81,3 +81,14 @@ function _load_static() { export SYSTEM_REQUIREMENTS=`cat "$staticFilesDir/system-requirements.json"` fi } + +function os_check() { + OS_NAME=$(grep '^NAME' /etc/os-release | cut -d '=' -f2) + OS_VERSION=$(grep '^VERSION_ID' /etc/os-release | cut -d '=' -f2) + color_always="--color=always" + if echo "$OS_NAME" | grep -q "Red"; then + if echo "$OS_VERSION" | grep -q "7"; then + color_always="" + fi + fi +} diff --git a/src/_configure_plextrac.sh b/src/_configure_plextrac.sh index 86c01ae..e77122f 100644 --- a/src/_configure_plextrac.sh +++ b/src/_configure_plextrac.sh @@ -63,7 +63,8 @@ PLEXTRAC_BACKUP_PATH="${PLEXTRAC_BACKUP_PATH:-$PLEXTRAC_HOME/backups}" if [ $(echo "$mergedEnv" | md5sum | awk '{print $1}') = $(md5sum "${PLEXTRAC_HOME}/.env" | awk '{print $1}') ]; then log "No change required"; else - envDiff="`diff -Nurb --color=always "${PLEXTRAC_HOME}/.env" <(echo "$mergedEnv") || true`" + os_check + envDiff="`diff -Nurb "$color_always" "${PLEXTRAC_HOME}/.env" <(echo "$mergedEnv") || true`" info "Detected pending changes to ${PLEXTRAC_HOME}/.env:" log "${envDiff}" if get_user_approval; then diff --git a/src/_migrate.sh b/src/_migrate.sh index 065cc01..e43c7de 100644 --- a/src/_migrate.sh +++ b/src/_migrate.sh @@ -152,7 +152,8 @@ function checkExistingConfigForOverrides() { decodedComposeFile=$(base64 -d <<<$DOCKER_COMPOSE_ENCODED) #diff -N --unified=2 --color=always --label existing --label "updated" $targetComposeFile <(echo "$decodedComposeFile") || return 0 - diff --unified --color=always --show-function-line='^\s\{2\}\w\+' \ + os_check + diff --unified "$color_always" --show-function-line='^\s\{2\}\w\+' \ <($dcCMD config --no-interpolate) \ <(docker compose -f - <<< "${decodedComposeFile}" -f ${composeOverrideFile} config --no-interpolate) || return 0 return 1 diff --git a/src/_setup_packages.sh b/src/_setup_packages.sh index f290d24..ea92143 100644 --- a/src/_setup_packages.sh +++ b/src/_setup_packages.sh @@ -18,10 +18,15 @@ function system_packages__refresh_package_lists() { function system_packages__do_system_upgrade() { info "Updating OS packages, this make take some time!" nobest="--nobest" - if [ "$(grep '^NAME' /etc/os-release | cut -d '=' -f2 | grep CentOS)" ]; then + os_check + if echo "$OS_NAME" | grep -q 'CentOS'; then nobest="" - elif [ "$(grep '^NAME' /etc/os-release | cut -d '=' -f2 | grep Hat)" ]; then - nobest="--nobest" + elif echo "$OS_NAME" | grep -q 'Hat'; then + if echo "$OS_VERSION" | grep -v '7'; then + nobest="--nobest" + else + nobest="" + fi fi debug "$(grep '^NAME' /etc/os-release | cut -d '=' -f2 | tr -d '"')" system_packages__refresh_package_lists diff --git a/src/_version_check.sh b/src/_version_check.sh index 920b1ad..66f6ddb 100644 --- a/src/_version_check.sh +++ b/src/_version_check.sh @@ -103,6 +103,7 @@ function version_check() { debug "Looking for Running version $running_ver or Breaking version $breaking_ver" while [ $page -lt 600 ] do + upstream_tags+=(`wget --header="Authorization: JWT "${JWT_TOKEN} -O - "https://hub.docker.com/v2/repositories/plextrac/plextracapi/tags/?page=$page&page_size=1000" -q | jq -r .results[].name | grep -E '(^[0-9]\.[0-9]*$)' || true`) # Get the available versions from DockerHub and save to array if [[ $(echo "${upstream_tags[@]}" | grep "$running_ver" || true) ]] then @@ -110,12 +111,10 @@ function version_check() { elif [[ $(echo "${upstream_tags[@]}" | grep "$breaking_ver" || true) ]] then debug "Found breaking version $breaking_ver"; break; - else - upstream_tags+=(`wget --header="Authorization: JWT "${JWT_TOKEN} -O - "https://hub.docker.com/v2/repositories/plextrac/plextracapi/tags/?page=$page&page_size=1000" -q | jq -r .results[].name | grep -E '(^[0-9]\.[0-9]*$)' || true`) fi page=$[$page+1] done - + # Remove the running version from the Upgrade path for i in "${!upstream_tags[@]}" do @@ -125,11 +124,16 @@ function version_check() { unset 'upstream_tags[i]' fi done + new_array=() for i in "${!upstream_tags[@]}"; do new_array+=( "${upstream_tags[i]}" ) done - upstream_tags=("${new_array[@]}") - unset new_array + if "${#new_array[@]}" > 0; then + upstream_tags=("${new_array[@]}") + unset new_array + else + upstream_tags=("") + fi # This grabs the first element in the version sorted list which should always be the highest version available on DockerHub; this should match stable's version" if [[ -n "${upstream_tags[*]}" ]]; then debug "Setting latest upstream version var to array first index" @@ -140,11 +144,14 @@ function version_check() { # Set Contiguous updates to false here to ensure that since the app is on latest version, it still attempts to pull patch version updates contiguous_update=false fi - # Sort the upstream tags weve chosen as the upgrade path - IFS=$'\n' upgrade_path=($(sort -V <<<"${upstream_tags[*]}")) - # Reset IFS to default value - IFS=$' \t\n' - + if "${upstream_tags[@]}" != ""; then + # Sort the upstream tags weve chosen as the upgrade path + IFS=$'\n' upgrade_path=($(sort -V <<<"${upstream_tags[*]}")) + # Reset IFS to default value + IFS=$' \t\n' + else + upgrade_path=("") + fi debug "------------" debug "Listing version information"