-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| *.tar.gz | ||
| cf-terraformer_*/ | ||
| linux/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 0.24.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| 54bf06b294448eef5f4e7d1844752c6829def3034751988296ed940dff0499ec cf-terraforming_0.24.0_darwin_amd64.tar.gz | ||
| 28fd5021c6f3492bb355e29486cbecd87dbd8b4a09a5ae4eeb3357b3ac4d1322 cf-terraforming_0.24.0_darwin_arm64.tar.gz | ||
| 722a972a7a574cde6a5b42403649bca233c890d9b084114dca5763ac4d40eb70 cf-terraforming_0.24.0_linux_386.tar.gz | ||
| 35eb5c975f5c3ed7e7b822d665bb5cd533a1804d92625d4d62163ff3eaf12b49 cf-terraforming_0.24.0_linux_amd64.tar.gz | ||
| 0a974ed3617e2193d130341ea0b91c12788eed717165427b6b42f0350adf505b cf-terraforming_0.24.0_linux_arm64.tar.gz | ||
| 3d2eb3d926e2d4ec3394752dde6440da0c18a7508c983c1c82a988c1f0e102da cf-terraforming_0.24.0_windows_386.tar.gz | ||
| 0b0e7735d941777b82911a278af6584fa66ce54e5f9ed3b895c6a10419cdf306 cf-terraforming_0.24.0_windows_amd64.tar.gz | ||
| b2a56569a67d7b2cfbf5ae27104495c6cff99260e07e90755e20bb6fdc0a7b4e cf-terraforming_0.24.0_windows_arm64.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| #!/bin/bash | ||
|
|
||
| THIS_VERSION="1.1.0" | ||
| THIS=$(basename $0) | ||
|
|
||
| ARG=$1 | ||
| OS=$2 | ||
|
|
||
| # https://github.com/cloudflare/cf-terraforming/releases/download/v0.24.0/cf-terraforming_0.24.0_linux_amd64.tar.gz | ||
|
|
||
| REPONAME="cloudflare" | ||
| BINNAME="cf-terraforming" | ||
| BINEXTENSION="" | ||
| PROGNAME="cf-terraforming" | ||
| if [ -z "$OS" ] | ||
| then | ||
| OS="linux" | ||
| fi | ||
| if [[ "$OS" != "linux" ]] && [[ "$OS" != "windows" ]] && [[ "$OS" != "darwin" ]] | ||
| then | ||
| echo "* invalid $OS, exiting" | ||
| exit 1 | ||
| fi | ||
|
|
||
| PLATFORM="amd64" | ||
| URL="https://github.com/$REPONAME/$BINNAME/releases/download/v%%VERSION%%/${PROGNAME}_%%VERSION%%_${OS}_${PLATFORM}.tar.gz" | ||
| SHA256_URL="https://github.com/$REPONAME/$BINNAME/releases/download/v%%VERSION%%/checksums.txt" | ||
|
|
||
| if [ -z $VERSION ] | ||
| then | ||
| version=$(cat VERSION) | ||
| fi | ||
| v_major=$(echo $version| awk -F\. '{print $1 "." $2}') | ||
| v_minor=$(echo $version| awk -F\. '{print $3}') | ||
| v_minor_next=$(( $v_minor + 1 )) | ||
| version_next="${v_major}.${v_minor_next}" | ||
|
|
||
| if [[ $ARG == "current" ]] | ||
| then | ||
| version_next=$version | ||
| fi | ||
|
|
||
| S_URL=$(echo $SHA256_URL | sed -e "s/%%VERSION%%/$version_next/g") | ||
| sfile=$(basename $S_URL) | ||
| if [ ! -r "$sfile" ] | ||
| then | ||
| echo "* downloading SHA256sum for $version_next" | ||
| curl -L -s -f -k "$S_URL" -o $sfile 2> /dev/null | ||
| fi | ||
|
|
||
| if [[ -z $ARG ]] || [[ $ARG == "get" ]] || [[ $ARG == "current" ]] | ||
| then | ||
| T_URL=$(echo $URL | sed -e "s/%%VERSION%%/$version_next/g") | ||
| file=$(basename $T_URL) | ||
| echo "* old $version, attempting next version $version_next" | ||
| curl -L -s -f -k "$T_URL" -o $file 2> /dev/null | ||
| status=$? | ||
|
|
||
| GT_URL=$(echo $GPG_URL | sed -e "s/%%VERSION%%/$version_next/g") | ||
| if [ ! -z "$GT_URL" ] | ||
| then | ||
| gfile=$(basename $GT_URL) | ||
| echo "* old $version, attempting next version $version_next gpgsig" | ||
| curl -L -s -f -k "$GT_URL" -o $gfile 2> /dev/null | ||
| gstatus=$? | ||
| else | ||
| gstatus=0 | ||
| fi | ||
|
|
||
| if [ $status == 0 ] | ||
| then | ||
| # cp $file ${BINNAME}_${version_next}${BINEXTENSION} | ||
| # chmod 700 $file | ||
| # chmod 700 ${BINNAME}_${version_next}${BINEXTENSION} | ||
| test -d $OS/$version_next || mkdir -p $OS/$version_next | ||
| # unzip $file -d $OS/$version_next/ | ||
| tar -xzf $file --directory $OS/$version_next/ | ||
|
|
||
| echo $version_next > VERSION | ||
| echo "* downloaded new version $version_next" | ||
| echo "* install new version with:" | ||
| echo " ./$THIS install" | ||
| else | ||
| T_URL=$(echo $URL | sed -e "s/%%VERSION%%/$version/g") | ||
| echo "* version $version is current" | ||
| file=$(basename $T_URL) | ||
| if [ ! -r $file ] | ||
| then | ||
| echo "* downloading current version $version" | ||
| curl -L -s -f -k "$T_URL" -o $file 2> /dev/null | ||
| status=$? | ||
|
|
||
| echo "* downloading current version $version gpgsig" | ||
| curl -L -s -f -k "$GT_URL" -o $gfile 2> /dev/null | ||
| gstatus=$? | ||
|
|
||
| if [ $status == 0 ] | ||
| then | ||
| # cp $file ${BINNAME}_${version}${BINEXTENSION} | ||
| test -d $version || mkdir -p $version | ||
| # unzip $file -d $version/ | ||
| tar -xzf $file --directory $version/ | ||
| else | ||
| echo "x unable to download ${BINNAME}_${version}${BINEXTENSION} status=$status" | ||
| exit $status | ||
| fi | ||
| fi | ||
| fi | ||
| fi | ||
|
|
||
| if [[ $ARG == "install" ]] && [[ "$OS" == "linux" ]] | ||
| then | ||
| whichbin=$(which $PROGNAME 2> /dev/null) | ||
| if [ ! -z $whichbin ] | ||
| then | ||
| BINDIR=$(dirname $whichbin) | ||
| elif [ -z $BINDIR ] | ||
| then | ||
| echo "x unable to locate current $BINNAME binary, use BINDIR=path to install" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "* installing $PROGNAME $version into $BINDIR" | ||
| umask 022 | ||
| cp ${OS}/$version/${PROGNAME} $BINDIR/${PROGNAME}_$version && ln -sf ${PROGNAME}_${version} $BINDIR/$PROGNAME | ||
| chmod 755 $BINDIR/${PROGNAME}_${version} | ||
| fi |