agave-install-deploy.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/usr/bin/env bash
  2. #
  3. # Convenience script to easily deploy a software update to a testnet
  4. #
  5. set -e
  6. SOLANA_ROOT="$(cd "$(dirname "$0")"/..; pwd)"
  7. maybeKeypair=
  8. while [[ ${1:0:2} = -- ]]; do
  9. if [[ $1 = --keypair && -n $2 ]]; then
  10. maybeKeypair="$1 $2"
  11. shift 2
  12. else
  13. echo "Error: Unknown option: $1"
  14. exit 1
  15. fi
  16. done
  17. URL=$1
  18. TAG=$2
  19. OS=${3:-linux}
  20. if [[ -z $URL || -z $TAG ]]; then
  21. echo "Usage: $0 [stable|localhost|RPC URL] [edge|beta|release tag] [linux|osx|windows]"
  22. exit 0
  23. fi
  24. if [[ ! -f update_manifest_keypair.json ]]; then
  25. "$SOLANA_ROOT"/scripts/agave-install-update-manifest-keypair.sh "$OS"
  26. fi
  27. case "$OS" in
  28. osx)
  29. TARGET=x86_64-apple-darwin
  30. ;;
  31. linux)
  32. TARGET=x86_64-unknown-linux-gnu
  33. ;;
  34. windows)
  35. TARGET=x86_64-pc-windows-msvc
  36. ;;
  37. *)
  38. TARGET=unknown-unknown-unknown
  39. ;;
  40. esac
  41. case $URL in
  42. stable)
  43. URL=http://api.devnet.solana.com
  44. ;;
  45. localhost)
  46. URL=http://localhost:8899
  47. ;;
  48. *)
  49. ;;
  50. esac
  51. case $TAG in
  52. edge|beta)
  53. DOWNLOAD_URL=https://release.anza.xyz/"$TAG"/solana-release-$TARGET.tar.bz2
  54. ;;
  55. *)
  56. DOWNLOAD_URL=https://github.com/anza-xyz/agave/releases/download/"$TAG"/solana-release-$TARGET.tar.bz2
  57. ;;
  58. esac
  59. # Prefer possible `cargo build` binaries over PATH binaries
  60. PATH="$SOLANA_ROOT"/target/debug:$PATH
  61. set -x
  62. # shellcheck disable=SC2086 # Don't want to double quote $maybeKeypair
  63. balance=$(solana $maybeKeypair --url "$URL" balance --lamports)
  64. if [[ $balance = "0 lamports" ]]; then
  65. # shellcheck disable=SC2086 # Don't want to double quote $maybeKeypair
  66. solana $maybeKeypair --url "$URL" airdrop 0.000000042
  67. fi
  68. # shellcheck disable=SC2086 # Don't want to double quote $maybeKeypair
  69. agave-install deploy $maybeKeypair --url "$URL" "$DOWNLOAD_URL" update_manifest_keypair.json