mirror of
https://github.com/mag37/dockcheck.git
synced 2026-04-21 03:40:39 +00:00
Colorized error messages
This commit is contained in:
+5
-5
@@ -180,7 +180,7 @@ binary_downloader() {
|
|||||||
case "$(uname --machine)" in
|
case "$(uname --machine)" in
|
||||||
x86_64|amd64) architecture="amd64" ;;
|
x86_64|amd64) architecture="amd64" ;;
|
||||||
arm64|aarch64) architecture="arm64";;
|
arm64|aarch64) architecture="arm64";;
|
||||||
*) echo "Architecture not supported, exiting." ; exit 1;;
|
*) printf "\n%bArchitecture not supported, exiting.%b\n" "$c_red" "$c_reset" ; exit 1;;
|
||||||
esac
|
esac
|
||||||
GetUrl="${BinaryUrl/TEMP/"$architecture"}"
|
GetUrl="${BinaryUrl/TEMP/"$architecture"}"
|
||||||
if [[ $(command -v curl) ]]; then curl -L $GetUrl > "$ScriptWorkDir/$BinaryName" ;
|
if [[ $(command -v curl) ]]; then curl -L $GetUrl > "$ScriptWorkDir/$BinaryName" ;
|
||||||
@@ -195,7 +195,7 @@ distro_checker() {
|
|||||||
elif [[ -f /etc/redhat-release ]] ; then PkgInstaller="dnf install"
|
elif [[ -f /etc/redhat-release ]] ; then PkgInstaller="dnf install"
|
||||||
elif [[ -f /etc/SuSE-release ]] ; then PkgInstaller="zypper install"
|
elif [[ -f /etc/SuSE-release ]] ; then PkgInstaller="zypper install"
|
||||||
elif [[ -f /etc/debian_version ]] ; then PkgInstaller="apt-get install"
|
elif [[ -f /etc/debian_version ]] ; then PkgInstaller="apt-get install"
|
||||||
else PkgInstaller="ERROR" ; printf "%s\n" "No distribution could be determined, falling back to static binary."
|
else PkgInstaller="ERROR" ; printf "\n%bNo distribution could be determined%b, falling back to static binary.\n" "$c_yellow" "$c_reset"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,13 +210,13 @@ else
|
|||||||
[[ "$GetJq" =~ [yY] ]] && distro_checker
|
[[ "$GetJq" =~ [yY] ]] && distro_checker
|
||||||
if [[ -n "$PkgInstaller" && "$PkgInstaller" != "ERROR" ]] ; then
|
if [[ -n "$PkgInstaller" && "$PkgInstaller" != "ERROR" ]] ; then
|
||||||
(sudo $PkgInstaller jq) ; PkgExitcode="$?"
|
(sudo $PkgInstaller jq) ; PkgExitcode="$?"
|
||||||
[[ "$PkgExitcode" != 0 ]] && printf "%s\n" "Packagemanager install failed, falling back to static binary."
|
[[ "$PkgExitcode" != 0 ]] && printf "\n%bPackagemanager install failed%b, falling back to static binary.\n" "$c_yellow" "$c_reset"
|
||||||
fi
|
fi
|
||||||
if [[ "$GetJq" =~ [nN] || "$PkgInstaller" == "ERROR" || "$PkgExitcode" != 0 ]] ; then
|
if [[ "$GetJq" =~ [nN] || "$PkgInstaller" == "ERROR" || "$PkgExitcode" != 0 ]] ; then
|
||||||
binary_downloader "jq" "https://github.com/jqlang/jq/releases/latest/download/jq-linux-TEMP"
|
binary_downloader "jq" "https://github.com/jqlang/jq/releases/latest/download/jq-linux-TEMP"
|
||||||
[[ -f "$ScriptWorkDir/jq" ]] && jqbin="$ScriptWorkDir/jq"
|
[[ -f "$ScriptWorkDir/jq" ]] && jqbin="$ScriptWorkDir/jq"
|
||||||
fi
|
fi
|
||||||
else printf "%s\n" "Dependency missing, quitting." ; exit 1 ;
|
else printf "\n%bDependency missing, exiting.%b\n" "$c_red" "$c_reset" ; exit 1 ;
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Final check if binary is correct
|
# Final check if binary is correct
|
||||||
@@ -230,7 +230,7 @@ else
|
|||||||
if [[ "$GetRegctl" =~ [yY] ]] ; then
|
if [[ "$GetRegctl" =~ [yY] ]] ; then
|
||||||
binary_downloader "regctl" "https://github.com/regclient/regclient/releases/latest/download/regctl-linux-TEMP"
|
binary_downloader "regctl" "https://github.com/regclient/regclient/releases/latest/download/regctl-linux-TEMP"
|
||||||
[[ -f "$ScriptWorkDir/regctl" ]] && regbin="$ScriptWorkDir/regctl"
|
[[ -f "$ScriptWorkDir/regctl" ]] && regbin="$ScriptWorkDir/regctl"
|
||||||
else printf "%s\n" "Dependency missing, quitting." ; exit 1 ;
|
else printf "\n%bDependency missing, exiting.%b\n" "$c_red" "$c_reset" ; exit 1 ;
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Final check if binary is correct
|
# Final check if binary is correct
|
||||||
|
|||||||
Reference in New Issue
Block a user