github.com/ETCDEVTeam/janus@v0.2.4-0.20180611132348-f6c8fba730fa/get-windows.sh (about) 1 #!/bin/sh 2 3 # Sources cited: 4 # - https://raw.githubusercontent.com/goreleaser/get/master/get 5 6 # Use: 7 # 8 # Install janus executable to system PATH. 9 # 10 # curl -sL https://raw.githubusercontent.com/ETCDEVTeam/janus/master/get.sh | bash 11 # export PATH=$PATH:$PWD/janusbin 12 13 set -e 14 15 TAR_FILE="/tmp/janus.zip" 16 TAR_FILE_SIG="/tmp/janus.zip.sig" 17 ISAAC_GPG_FILE="/tmp/isaac-gpg.txt" 18 ISAAC_GPG_URL="https://raw.githubusercontent.com/ethereumproject/volunteer/7a78a94307d67a0b20e418568b7bccac83c3d143/Volunteer-Public-Keys/isaac.ardis%40gmail.com" 19 DOWNLOAD_URL="https://github.com/ETCDEVTeam/janus/releases/download" 20 test -z "$TMPDIR" && TMPDIR="$(mktemp -d)" 21 22 # Hardcode to override appveyor system names. (ie MSYS_*blah_wahtever) 23 WINDOWS_EXT="Windows_x86_64.zip" 24 25 last_version() { 26 # The new and improved sans-GithubAPI-rate-limited curler. 27 # https://github.com/goreleaser/goreleaser/issues/157 28 curl -sL -o /dev/null -w %{url_effective} https://github.com/ETCDEVTeam/janus/releases/latest | rev | cut -f1 -d'/'| rev 29 } 30 31 download() { 32 test -z "$VERSION" && VERSION="$(last_version)" 33 test -z "$VERSION" && { 34 echo "Unable to get janus version." >&2 35 exit 1 36 } 37 echo "Version: $VERSION" 38 rm -f "$TAR_FILE" 39 download_target="$DOWNLOAD_URL/$VERSION/janus_${VERSION}_$WINDOWS_EXT" 40 echo "Downloading Janus: $download_target" 41 curl -s -L -o "$TAR_FILE" \ 42 "$download_target" 43 44 # Get and verify signature. 45 rm -f "$TAR_FILE_SIG" 46 sig_target="$DOWNLOAD_URL/$VERSION/janus_${VERSION}_$WINDOWS_EXT.sig" 47 echo "Downloading signature: $sig_target" 48 curl -s -L -o "$TAR_FILE_SIG" \ 49 "$sig_target" 50 51 # Ensure our newly downloaded files exists. 52 if ! [ -f "$TAR_FILE" ]; then 53 echo "Tar file not found." 54 exit 1 55 fi 56 if ! [ -f "$TAR_FILE_SIG" ]; then 57 echo "Tar sig file not found." 58 exit 1 59 fi 60 } 61 62 verify() { 63 # Verify signature if gpg is available. 64 if command -v gpg 2> /dev/null; then 65 echo "Downloading Isaac's key file: $ISAAC_GPG_URL" 66 curl -s -L -o "$ISAAC_GPG_FILE" \ 67 "$ISAAC_GPG_URL" 68 69 gpg --import "$ISAAC_GPG_FILE" 70 gpg --verify "$TAR_FILE_SIG" "$TAR_FILE" 71 fi 72 } 73 74 install() { 75 echo "Extracting janus..." 76 7z e "$TAR_FILE" janus.exe -y 77 78 echo "Moving 'janus' binary to ./janusbin/janus" 79 mkdir janusbin 80 mv janus.exe janusbin/ 81 82 echo "Please ensure janus is added to PATH." 83 echo "Use:" 84 echo " - export PATH=$PATH:$PWD/janusbin" 85 } 86 87 download 88 verify 89 install