Skip to content

Commit

Permalink
Merge pull request #99 from renproject/release/3.1.1
Browse files Browse the repository at this point in the history
Release/3.1.1
  • Loading branch information
tok-kkk committed Nov 25, 2021
2 parents 688e43a + d5392cd commit 5c773d6
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 52 deletions.
39 changes: 25 additions & 14 deletions artifacts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
}
Expand All @@ -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
Expand All @@ -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)"
Expand Down Expand Up @@ -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"
Expand Down
63 changes: 29 additions & 34 deletions artifacts/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,23 @@ 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
fi
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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/down.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,4 @@ func nodeStatus(name string) (status, error) {
return notRefunded, nil
}
return nilStatus, nil
}
}
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 5c773d6

Please sign in to comment.