diff --git a/artifacts/install.sh b/artifacts/install.sh index f5436278..5caa68cd 100755 --- a/artifacts/install.sh +++ b/artifacts/install.sh @@ -35,10 +35,18 @@ main() { fi if ! check_cmd terraform; then terraform_url="https://releases.hashicorp.com/terraform/${cur_terraform_ver}/terraform_${cur_terraform_ver}_${ostype}_${cputype}.zip" - ensure downloader "$terraform_url" "$HOME/.darknode/bin/terraform.zip" - ensure unzip -qq "$HOME/.darknode/bin/terraform.zip" -d "$HOME/.darknode/bin" - ensure chmod +x "$HOME/.darknode/bin/terraform" - rm "$HOME/.darknode/bin/terraform.zip" + + # The official terraform download page doesn't have bins for apple silicon before v1.0.0 + # so we have to build ourselves and upload to the cli release + if [ "$ostype" = 'darwin' -a "$cputype" = 'arm64' ];then + terraform_url="https://www.github.com/renproject/darknode-cli/releases/download/3.1.0/terraform_darwin_arm64" + ensure downloader "$terraform_url" "$HOME/.darknode/bin/terraform" + else + ensure downloader "$terraform_url" "$HOME/.darknode/bin/terraform.zip" + ensure unzip -qq "$HOME/.darknode/bin/terraform.zip" -d "$HOME/.darknode/bin" + ensure chmod +x "$HOME/.darknode/bin/terraform" + rm "$HOME/.darknode/bin/terraform.zip" + fi fi progressBar 50 100 @@ -98,13 +106,15 @@ prerequisites() { requiredPatch="$(echo $1 | cut -d. -f3)" if [ "$major" -lt "$requiredMajor" ]; then - err "Please upgrade your terraform to version above $min_terraform_ver" - fi - if [ "$minor" -lt "$requiredMinor" ]; then - err "Please upgrade your terraform to version above $min_terraform_ver" - fi - if [ "$patch" -lt "$requiredPatch" ]; then - err "Please upgrade your terraform to version above $min_terraform_ver" + echo "Please upgrade your terraform to version above $min_terraform_ver" + elif [ "$major" -eq "$requiredMajor" ]; then + if [ "$minor" -lt "$requiredMinor" ]; then + echo "Please upgrade your terraform to version above $min_terraform_ver" + elif [ "$minor" -eq "$requiredMinor" ]; then + if [ "$patch" -lt "$requiredPatch" ]; then + echo "Please upgrade your terraform to version above $min_terraform_ver" + fi + fi fi fi } @@ -118,7 +128,7 @@ check_architecture() { : elif [ "$ostype" = 'linux' -a "$cputype" = 'aarch64' ]; then : - elif [ "$ostype" = 'darwin' -a "$cputype" = 'x86_64' ]; then + elif [ "$ostype" = 'darwin' ]; then if [ "$cputype" = 'x86_64' ]; then : elif [ "$cputype" = 'arm64' ]; then @@ -141,6 +151,9 @@ check_architecture() { 11.*) # We assume Big Sur will be OK for now ;; + 12.*) + # We assume Monterey will be OK for now + ;; *) # Unknown product version, warn and continue echo "Warning: Detected unknown macOS major version: $(sw_vers -productVersion)" @@ -209,14 +222,12 @@ ensure() { downloader() { if check_cmd curl; then if ! check_help_for curl --proto --tlsv1.2; then - echo "Warning: Not forcing TLS v1.2, this is potentially less secure" curl --silent --show-error --fail --location "$1" --output "$2" else curl --proto '=https' --tlsv1.2 --silent --show-error --fail --location "$1" --output "$2" fi elif check_cmd wget; then if ! check_help_for wget --https-only --secure-protocol; then - echo "Warning: Not forcing TLS v1.2, this is potentially less secure" wget "$1" -O "$2" else wget --https-only --secure-protocol=TLSv1_2 "$1" -O "$2" diff --git a/artifacts/update.sh b/artifacts/update.sh index cc6b9b8a..a074ec6f 100755 --- a/artifacts/update.sh +++ b/artifacts/update.sh @@ -23,13 +23,15 @@ main(){ requiredMinor="$(echo $min_terraform_ver | cut -d. -f2)" requiredPatch="$(echo $min_terraform_ver | cut -d. -f3)" if [ "$major" -lt "$requiredMajor" ]; then - err "Please upgrade your terraform to version above $min_terraform_ver" - fi - if [ "$minor" -lt "$requiredMinor" ]; then - err "Please upgrade your terraform to version above $min_terraform_ver" - fi - if [ "$patch" -lt "$requiredPatch" ]; then - err "Please upgrade your terraform to version above $min_terraform_ver" + echo "Please upgrade your terraform to version above $min_terraform_ver" + elif [ "$major" -eq "$requiredMajor" ]; then + if [ "$minor" -lt "$requiredMinor" ]; then + echo "Please upgrade your terraform to version above $min_terraform_ver" + elif [ "$minor" -eq "$requiredMinor" ]; then + if [ "$patch" -lt "$requiredPatch" ]; then + echo "Please upgrade your terraform to version above $min_terraform_ver" + fi + fi fi else install_terraform $cur_terraform_ver @@ -37,7 +39,7 @@ main(){ progressBar 40 100 # Update the binary - current=$(darknode --version | grep "darknode-cli version" | cut -d ' ' -f 3) + current=$(darknode --version | grep "Darknode CLI version" | cut -d ' ' -f 4) latest=$(get_latest_release "renproject/darknode-cli") vercomp $current $latest if [ "$?" -eq "2" ]; then @@ -87,14 +89,12 @@ check_cmd() { downloader() { if check_cmd curl; then if ! check_help_for curl --proto --tlsv1.2; then - echo "Warning: Not forcing TLS v1.2, this is potentially less secure" curl --silent --show-error --fail --location "$1" --output "$2" else curl --proto '=https' --tlsv1.2 --silent --show-error --fail --location "$1" --output "$2" fi elif check_cmd wget; then if ! check_help_for wget --https-only --secure-protocol; then - echo "Warning: Not forcing TLS v1.2, this is potentially less secure" wget "$1" -O "$2" else wget --https-only --secure-protocol=TLSv1_2 "$1" -O "$2" @@ -140,36 +140,31 @@ get_latest_release() { sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value } -# source : https://stackoverflow.com/questions/4023830/how-to-compare-two-strings-in-dot-separated-version-format-in-bash vercomp () { if [[ $1 == $2 ]] then return 0 fi - local IFS=. - local i ver1=($1) ver2=($2) - # fill empty fields in ver1 with zeros - for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)) - do - ver1[i]=0 - done - for ((i=0; i<${#ver1[@]}; i++)) - do - if [[ -z ${ver2[i]} ]] - then - # fill empty fields in ver2 with zeros - ver2[i]=0 - fi - if ((10#${ver1[i]} > 10#${ver2[i]})) - then - return 1 + major1="$(echo $1 | cut -d. -f1)" + minor1="$(echo $1 | cut -d. -f2)" + patch1="$(echo $1 | cut -d. -f3)" + major2="$(echo $2 | cut -d. -f1)" + minor2="$(echo $2 | cut -d. -f2)" + patch2="$(echo $2 | cut -d. -f3)" + + if [ "$major1" -lt "$major2" ]; then + return 2 + elif [ "$major1" -eq "$major2" ]; then + if [ "$minor1" -lt "$minor2" ]; then + return 2 + elif [ "$minor1" -eq "$minor2" ]; then + if [ "$patch1" -lt "$patch2" ]; then + return 2 fi - if ((10#${ver1[i]} < 10#${ver2[i]})) - then - return 2 - fi - done - return 0 + fi + fi + + return 1 } # Source: https://github.com/fearside/ProgressBar diff --git a/cmd/down.go b/cmd/down.go index 06688c44..b7018d84 100644 --- a/cmd/down.go +++ b/cmd/down.go @@ -282,4 +282,4 @@ func nodeStatus(name string) (status, error) { return notRefunded, nil } return nilStatus, nil -} +} \ No newline at end of file diff --git a/go.mod b/go.mod index f171207c..3875c411 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,6 @@ require ( github.com/jbenet/go-base58 v0.0.0-20150317085156-6237cf65f3a6 github.com/karalabe/usb v0.0.0-20211005121534-4c5740d64559 // indirect github.com/kr/text v0.2.0 // indirect - github.com/mattn/go-colorable v0.1.8 // indirect github.com/multiformats/go-multiaddr v0.1.1 github.com/multiformats/go-multihash v0.0.8 github.com/olekukonko/tablewriter v0.0.5 // indirect diff --git a/go.sum b/go.sum index dd0f543d..8b7f8e5a 100644 --- a/go.sum +++ b/go.sum @@ -241,9 +241,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw= github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= -github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=