|
| 1 | +#!/bin/bash |
| 2 | +# Pulls latest pre-built node binary from GitHub |
| 3 | + |
| 4 | +#stop on errors |
| 5 | +set -e |
| 6 | + |
| 7 | +#helper function to check for presence of required commands, and install if missing |
| 8 | +check_reqs_deb () { |
| 9 | + if ! command -v curl &> /dev/null |
| 10 | + then |
| 11 | + echo "curl could not be found, will install..." |
| 12 | + apt-get install curl -y |
| 13 | + fi |
| 14 | +} |
| 15 | +check_reqs_rhel () { |
| 16 | + if ! command -v curl &> /dev/null |
| 17 | + then |
| 18 | + echo "curl could not be found, will install..." |
| 19 | + dnf install curl -y |
| 20 | + fi |
| 21 | + if ! command -v wget &> /dev/null |
| 22 | + then |
| 23 | + echo "wget could not be found, will install..." |
| 24 | + dnf install wget -y |
| 25 | + fi |
| 26 | + if ! command -v dig &> /dev/null |
| 27 | + then |
| 28 | + echo "dig could not be found, will install..." |
| 29 | + dnf install bind-utils -y |
| 30 | + fi |
| 31 | + if ! command -v semanage &> /dev/null |
| 32 | + then |
| 33 | + echo "semanage could not be found, will install..." |
| 34 | + dnf install policycoreutils-python-utils -y |
| 35 | + fi |
| 36 | + if ! command -v restorecon &> /dev/null |
| 37 | + then |
| 38 | + echo "restorecon could not be found, will install..." |
| 39 | + dnf install policycoreutils -y |
| 40 | + fi |
| 41 | +} |
| 42 | +# Helper function to get OS Type |
| 43 | +getOsType () { |
| 44 | + which yum 1>/dev/null 2>&1 && { echo "RHEL"; return; } |
| 45 | + which zypper 1>/dev/null 2>&1 && { echo "openSUSE"; return; } |
| 46 | + which apt-get 1>/dev/null 2>&1 && { echo "Debian"; return; } |
| 47 | +} |
| 48 | + |
| 49 | +# Installing necessary system dependencies for AvalacheGO |
| 50 | +osType=$(getOsType) |
| 51 | +if [ "$osType" = "Debian" ]; then |
| 52 | + check_reqs_deb |
| 53 | +elif [ "$osType" = "RHEL" ]; then |
| 54 | + check_reqs_rhel |
| 55 | +else |
| 56 | + #sorry, don't know you. |
| 57 | + echo "Unsupported linux flavour/distribution: $osType" |
| 58 | + echo "Exiting." |
| 59 | + exit |
| 60 | +fi |
| 61 | + |
| 62 | +# Define architecture |
| 63 | +foundArch="$(uname -m)" |
| 64 | + |
| 65 | +if [ "$foundArch" = "aarch64" ]; then |
| 66 | + getArch="arm64" #we're running on arm arch (probably RasPi) |
| 67 | + echo "Found arm64 architecture..." |
| 68 | +elif [ "$foundArch" = "x86_64" ]; then |
| 69 | + getArch="amd64" #we're running on intel/amd |
| 70 | + echo "Found amd64 architecture..." |
| 71 | +elif [ "$foundArch" = "arm64" ]; then |
| 72 | + getArch="arm64" #we're running on intel/amd |
| 73 | + echo "Found arm64 architecture..." |
| 74 | +else |
| 75 | + #sorry, don't know you. |
| 76 | + echo "Unsupported architecture: $foundArch!" |
| 77 | + echo "Exiting." |
| 78 | + exit |
| 79 | +fi |
| 80 | + |
| 81 | +# Import environment variables |
| 82 | +source ./versions.sh |
| 83 | + |
| 84 | +# Download AvalancheGo binary |
| 85 | +curl -LJ -o avalanchego.tar.gz "https://github.com/ava-labs/avalanchego/releases/download/$AVALANCHEGO_VERSION/avalanchego-linux-$getArch-$AVALANCHEGO_VERSION.tar.gz" |
| 86 | +tar -xzf avalanchego.tar.gz --wildcards '*/avalanchego' --strip-components=1 -C /avalanchego |
| 87 | +rm avalanchego.tar.gz |
0 commit comments