mirror of
https://github.com/mag37/dockcheck.git
synced 2026-04-19 02:47:45 +00:00
reformatting
This commit is contained in:
58
dockcheck.sh
58
dockcheck.sh
@@ -206,35 +206,35 @@ distro_checker() {
|
|||||||
|
|
||||||
# Dependency check + installer function
|
# Dependency check + installer function
|
||||||
dependency_check() {
|
dependency_check() {
|
||||||
AppName="$1"
|
AppName="$1"
|
||||||
AppVar="$2"
|
AppVar="$2"
|
||||||
AppUrl="$3"
|
AppUrl="$3"
|
||||||
if [[ $(command -v $AppName) ]]; then export $AppVar="$AppName" ;
|
if [[ $(command -v $AppName) ]]; then export $AppVar="$AppName" ;
|
||||||
elif [[ -f "$ScriptWorkDir/$AppName" ]]; then export $AppVar="$ScriptWorkDir/$AppName" ;
|
elif [[ -f "$ScriptWorkDir/$AppName" ]]; then export $AppVar="$ScriptWorkDir/$AppName" ;
|
||||||
else
|
else
|
||||||
printf "%s\n" "Required dependency '$AppName' missing, do you want to install it?"
|
printf "%s\n" "Required dependency '$AppName' missing, do you want to install it?"
|
||||||
read -r -p "y: With packagemanager (sudo). / s: Download static binary. y/s/[n] " GetBin
|
read -r -p "y: With packagemanager (sudo). / s: Download static binary. y/s/[n] " GetBin
|
||||||
GetBin=${GetBin:-no} # set default to no if nothing is given
|
GetBin=${GetBin:-no} # set default to no if nothing is given
|
||||||
if [[ "$GetBin" =~ [yYsS] ]] ; then
|
if [[ "$GetBin" =~ [yYsS] ]] ; then
|
||||||
[[ "$GetBin" =~ [yY] ]] && distro_checker
|
[[ "$GetBin" =~ [yY] ]] && distro_checker
|
||||||
if [[ -n "$PkgInstaller" && "$PkgInstaller" != "ERROR" ]] ; then
|
if [[ -n "$PkgInstaller" && "$PkgInstaller" != "ERROR" ]] ; then
|
||||||
[[ $(uname -s) == "Darwin" && "$AppName" == "regctl" ]] && AppName=regclient
|
[[ $(uname -s) == "Darwin" && "$AppName" == "regctl" ]] && AppName=regclient
|
||||||
($PkgInstaller $AppName) ; PkgExitcode="$?"
|
($PkgInstaller $AppName) ; PkgExitcode="$?"
|
||||||
if [[ "$PkgExitcode" == 0 ]] ; then { export $AppVar="$AppName" && printf "\n%b$AppName installed.%b\n" "$c_green" "$c_reset"; }
|
if [[ "$PkgExitcode" == 0 ]] ; then { export $AppVar="$AppName" && printf "\n%b$AppName installed.%b\n" "$c_green" "$c_reset"; }
|
||||||
else printf "\n%bPackagemanager install failed%b, falling back to static binary.\n" "$c_yellow" "$c_reset"
|
else printf "\n%bPackagemanager install failed%b, falling back to static binary.\n" "$c_yellow" "$c_reset"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [[ "$GetBin" =~ [sS] || "$PkgInstaller" == "ERROR" || "$PkgExitcode" != 0 ]] ; then
|
if [[ "$GetBin" =~ [sS] || "$PkgInstaller" == "ERROR" || "$PkgExitcode" != 0 ]] ; then
|
||||||
binary_downloader "$AppName" "$AppUrl"
|
binary_downloader "$AppName" "$AppUrl"
|
||||||
[[ -f "$ScriptWorkDir/$AppName" ]] && { export $AppVar="$ScriptWorkDir/$1" && printf "\n%b$AppName downloaded.%b\n" "$c_green" "$c_reset"; }
|
[[ -f "$ScriptWorkDir/$AppName" ]] && { export $AppVar="$ScriptWorkDir/$1" && printf "\n%b$AppName downloaded.%b\n" "$c_green" "$c_reset"; }
|
||||||
fi
|
fi
|
||||||
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
|
||||||
# Final check if binary is correct
|
# Final check if binary is correct
|
||||||
[[ "$1" == "jq" ]] && VerFlag="--version"
|
[[ "$1" == "jq" ]] && VerFlag="--version"
|
||||||
[[ "$1" == "regctl" ]] && VerFlag="version"
|
[[ "$1" == "regctl" ]] && VerFlag="version"
|
||||||
${!AppVar} $VerFlag &> /dev/null || { printf "%s\n" "$AppName is not working - try to remove it and re-download it, exiting."; exit 1; }
|
${!AppVar} $VerFlag &> /dev/null || { printf "%s\n" "$AppName is not working - try to remove it and re-download it, exiting."; exit 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
dependency_check "regctl" "regbin" "https://github.com/regclient/regclient/releases/latest/download/regctl-linux-TEMP"
|
dependency_check "regctl" "regbin" "https://github.com/regclient/regclient/releases/latest/download/regctl-linux-TEMP"
|
||||||
|
|||||||
Reference in New Issue
Block a user