download-sandstorm-node.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/bash
  2. echo "=== GETTING NEWEST NODE FROM SANDSTORM FORK OF NODE ==="
  3. echo "=== SOURCE: https://github.com/sandstorm-io/node ==="
  4. # From https://github.com/sandstorm-io/sandstorm/blob/master/branch.conf
  5. SANDSTORM_BRANCH_NUMBER=0
  6. # From https://github.com/sandstorm-io/sandstorm/blob/master/release.sh
  7. SANDSTORM_CHANNEL=dev
  8. SANDSTORM_LAST_BUILD=$(curl -fs https://install.sandstorm.io/$SANDSTORM_CHANNEL)
  9. echo "=== LATEST SANDSTORM RELEASE: ${SANDSTORM_LAST_BUILD}==="
  10. if (( SANDSTORM_LAST_BUILD / 1000 > SANDSTORM_BRANCH_NUMBER )); then
  11. echo "SANDSTORM BRANCH ERROR: $CHANNEL has already moved past this branch!" >&2
  12. echo " I refuse to replace it with an older branch." >&2
  13. exit 1
  14. fi
  15. BASE_BUILD=$(( BRANCH_NUMBER * 1000 ))
  16. BUILD=$(( BASE_BUILD > LAST_BUILD ? BASE_BUILD : LAST_BUILD + 1 ))
  17. BUILD_MINOR="$(( $BUILD % 1000 ))"
  18. DISPLAY_VERSION="${BRANCH_NUMBER}.${BUILD_MINOR}"
  19. TAG_NAME="v${DISPLAY_VERSION}"
  20. SIGNING_KEY_ID=160D2D577518B58D94C9800B63F227499DA8CCBD
  21. TARBALL=sandstorm-$SANDSTORM_LAST_BUILD.tar.xz
  22. NODE_EXE=sandstorm-$SANDSTORM_LAST_BUILD/bin/node
  23. echo "=== DOWNLOADING SANDSTORM GPG KEYS TO VERIFY SANDSTORM RELEASE ==="
  24. # Do verification in custom GPG workspace
  25. # https://docs.sandstorm.io/en/latest/install/#option-3-pgp-verified-install
  26. export GNUPGHOME=$(mktemp -d)
  27. curl https://raw.githubusercontent.com/sandstorm-io/sandstorm/master/keys/release-keyring.gpg | \
  28. gpg --import
  29. wget https://raw.githubusercontent.com/sandstorm-io/sandstorm/master/keys/release-certificate.kentonv.sig
  30. gpg --decrypt release-certificate.kentonv.sig
  31. echo "=== DOWNLOADING SANDSTORM RELEASE FROM https://dl.sandstorm.io/${TARBALL} ==="
  32. wget https://dl.sandstorm.io/$TARBALL
  33. echo "=== DOWNLOADING SIGNATURE FOR SANDSTORM RELEASE FROM https://dl.sandstorm.io/${TARBALL}.sig ==="
  34. wget https://dl.sandstorm.io/$TARBALL.sig
  35. echo "=== VERIFYING SIGNATURE OF SANDSTORM RELEASE ==="
  36. gpg --verify $TARBALL.sig $TARBALL
  37. if [ $? -eq 0 ]
  38. then
  39. echo "=== ALL IS WELL. GOOD SIGNATURE IN SANDSTORM. ==="
  40. else
  41. echo "=== PROBLEM WITH SANDSTORM SIGNATURE. ==="
  42. exit 1
  43. fi
  44. echo "=== EXTRACTING NODE FROM SANDSTORM RELEASE TARBALL ==="
  45. # --strip 2 removes path of 2 subdirectories
  46. tar -xf $TARBALL $NODE_EXE --strip=2
  47. echo "=== REMOVING SANDSTORM RELEASE TARBALL AND SIGNATURE ==="
  48. rm $TARBALL $TARBALL.sig release-certificate.kentonv.si*