mirror of
https://github.com/mag37/dockcheck.git
synced 2026-04-21 03:40:39 +00:00
rewrote regctl download
This commit is contained in:
+18
-7
@@ -196,9 +196,10 @@ binary_downloader() {
|
|||||||
|
|
||||||
distro_checker() {
|
distro_checker() {
|
||||||
if [[ -f /etc/arch-release ]] ; then PkgInstaller="pacman -S"
|
if [[ -f /etc/arch-release ]] ; then PkgInstaller="pacman -S"
|
||||||
elif [[ -f /etc/redhat-release ]] ; then PkgInstaller="dnf install"
|
elif [[ -f /etc/redhat-release ]] ; then PkgInstaller="sudo dnf install"
|
||||||
elif [[ -f /etc/SuSE-release ]] ; then PkgInstaller="zypper install"
|
elif [[ -f /etc/SuSE-release ]] ; then PkgInstaller="sudo zypper install"
|
||||||
elif [[ -f /etc/debian_version ]] ; then PkgInstaller="apt-get install"
|
elif [[ -f /etc/debian_version ]] ; then PkgInstaller="sudo apt-get install"
|
||||||
|
elif [[ $(uname -s) == "Darwin" ]] ; then PkgInstaller="brew install"
|
||||||
else PkgInstaller="ERROR" ; printf "\n%bNo distribution could be determined%b, falling back to static binary.\n" "$c_yellow" "$c_reset"
|
else PkgInstaller="ERROR" ; printf "\n%bNo distribution could be determined%b, falling back to static binary.\n" "$c_yellow" "$c_reset"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -213,10 +214,10 @@ else
|
|||||||
if [[ "$GetJq" =~ [yYsS] ]] ; then
|
if [[ "$GetJq" =~ [yYsS] ]] ; then
|
||||||
[[ "$GetJq" =~ [yY] ]] && distro_checker
|
[[ "$GetJq" =~ [yY] ]] && distro_checker
|
||||||
if [[ -n "$PkgInstaller" && "$PkgInstaller" != "ERROR" ]] ; then
|
if [[ -n "$PkgInstaller" && "$PkgInstaller" != "ERROR" ]] ; then
|
||||||
(sudo $PkgInstaller jq) ; PkgExitcode="$?"
|
($PkgInstaller jq) ; PkgExitcode="$?"
|
||||||
[[ "$PkgExitcode" == 0 ]] && jqbin="jq" || printf "\n%bPackagemanager install failed%b, falling back to static binary.\n" "$c_yellow" "$c_reset"
|
[[ "$PkgExitcode" == 0 ]] && jqbin="jq" || 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" =~ [sS] || "$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
|
||||||
@@ -232,8 +233,18 @@ elif [[ -f "$ScriptWorkDir/regctl" ]]; then regbin="$ScriptWorkDir/regctl" ;
|
|||||||
else
|
else
|
||||||
read -r -p "Required dependency 'regctl' missing, do you want it downloaded? y/[n] " GetRegctl
|
read -r -p "Required dependency 'regctl' missing, do you want it downloaded? y/[n] " GetRegctl
|
||||||
if [[ "$GetRegctl" =~ [yY] ]] ; then
|
if [[ "$GetRegctl" =~ [yY] ]] ; then
|
||||||
binary_downloader "regctl" "https://github.com/regclient/regclient/releases/latest/download/regctl-linux-TEMP"
|
if [[ $(uname -s) == "Darwin" ]]; then
|
||||||
[[ -f "$ScriptWorkDir/regctl" ]] && regbin="$ScriptWorkDir/regctl"
|
echo "Detected macOS, Installing regclient using Homebrew."
|
||||||
|
distro_checker
|
||||||
|
if [[ -n "$PkgInstaller" && "$PkgInstaller" != "ERROR" ]] ; then
|
||||||
|
($PkgInstaller regclient) ; PkgExitcode="$?"
|
||||||
|
[[ "$PkgExitcode" == 0 ]] && regbin="regclient" || printf "\n%bPackagemanager install failed%b, falling back to static binary.\n" "$c_yellow" "$c_reset"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
GetRegctl="S"
|
||||||
|
if [[ "$GetRegct" =~ [Ss] || "$PkgInstaller" == "ERROR" || "$PkgExitcode" != 0 ]] ; then
|
||||||
|
binary_downloader "regctl" "https://github.com/regclient/regclient/releases/latest/download/regctl-linux-TEMP"
|
||||||
|
[[ -f "$ScriptWorkDir/regctl" ]] && regbin="$ScriptWorkDir/regctl"
|
||||||
else printf "\n%bDependency missing, exiting.%b\n" "$c_red" "$c_reset" ; exit 1 ;
|
else printf "\n%bDependency missing, exiting.%b\n" "$c_red" "$c_reset" ; exit 1 ;
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user