github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/install.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  shopt -s extglob
     4  set -e
     5  set -o errtrace
     6  set -o errexit
     7  set -o pipefail
     8  
     9  export DEBIAN_FRONTEND="noninteractive"
    10  
    11  # Install latest release of myst for debian/ubuntu/raspbian
    12  #
    13  # Variables:
    14  # - SNAPSHOT (default: false) - set to "true" to install development snapshot
    15  #
    16  
    17  if [[ "$SNAPSHOT" == "true" ]]; then
    18      PPA="ppa:mysteriumnetwork/node-dev"
    19      PPA_URL="http://ppa.launchpad.net/mysteriumnetwork/node-dev/ubuntu"
    20      PPA_FINGER="ECCB6A56B22C536D"
    21  elif [[ "$NETWORK" == "testnet3" ]]; then
    22      PPA="ppa:mysteriumnetwork/node-testnet3"
    23      PPA_URL="http://ppa.launchpad.net/mysteriumnetwork/node-testnet3/ubuntu"
    24      PPA_FINGER="ECCB6A56B22C536D"
    25  else
    26      PPA="ppa:mysteriumnetwork/node"
    27      PPA_URL="http://ppa.launchpad.net/mysteriumnetwork/node/ubuntu"
    28      PPA_FINGER="ECCB6A56B22C536D"
    29  fi
    30  
    31  get_os() {
    32      local __resultvar=$1
    33      local result
    34  
    35      result=$(uname | tr '[:upper:]' '[:lower:]')
    36  
    37      eval $__resultvar="'$result'"
    38  }
    39  
    40  get_linux_distribution() {
    41      local __resultvar=$1
    42      local result
    43  
    44      if [[ -f "/etc/os-release" ]]; then
    45          local id=$(awk -F= '$1=="ID" { print $2 ;}' /etc/os-release)
    46          if [[ -z "$id" ]]; then
    47              id=$(awk -F= '$1=="ID_LIKE" { print $2 ;}' /etc/os-release)
    48          fi
    49  
    50          if [[ "$id" == "debian" ]]; then
    51              if [[ "$(uname -a | grep -c raspberry)" == "1" ]]; then
    52                  id="raspbian"
    53              fi
    54          fi
    55  
    56          result="$id"
    57      else
    58          result="unknown"
    59      fi
    60  
    61      eval $__resultvar="'$result'"
    62  }
    63  
    64  get_version_codename() {
    65      local __resultvar=$1
    66      local result
    67  
    68      if [[ -f "/etc/os-release" ]]; then
    69          local id=$(awk -F= '$1=="VERSION_CODENAME" { print $2 ;}' /etc/os-release)
    70          result="$id"
    71      else
    72          result="unknown"
    73      fi
    74  
    75      eval $__resultvar="'$result'"
    76  }
    77  
    78  
    79  
    80  install_ubuntu() {
    81      apt update
    82  
    83      # add-apt-repository may not be available in Ubuntu server out of the box
    84      apt install -y software-properties-common
    85  
    86      if [[ "$container" != "docker" ]]; then
    87          apt install -y "linux-headers-$(uname -r)"
    88      fi
    89  
    90      # myst
    91      add-apt-repository -y "$PPA"
    92      apt update
    93      apt install -y myst
    94  }
    95  
    96  
    97  install_debian() {
    98      # Wireguard
    99      prepare_sources_list
   100  
   101      if [[ "$container" != "docker" ]]; then
   102          apt update
   103          if [[ "$DISTRO" == "raspbian" ]]; then
   104              apt install -y raspberrypi-kernel-headers
   105          else
   106              apt install -y "linux-headers-$(uname -r)"
   107          fi
   108      fi
   109  
   110      # myst
   111      echo "deb $PPA_URL focal main" > /etc/apt/sources.list.d/mysterium.list
   112      apt-key adv --keyserver keyserver.ubuntu.com --recv-keys "$PPA_FINGER"
   113  
   114      apt update
   115      apt install -y wireguard myst
   116  }
   117  
   118  prepare_sources_list() {
   119      if [[ "$VERSION_CODENAME" == "buster" ]]; then
   120        echo "deb http://deb.debian.org/debian ${VERSION_CODENAME}-backports main" > /etc/apt/sources.list.d/backports.list
   121        apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 04EE7237B7D453EC
   122        apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138
   123      else
   124        echo "deb http://deb.debian.org/debian/ unstable main" > /etc/apt/sources.list.d/unstable.list
   125        echo -e "Package: *\nPin: release a=unstable\nPin-Priority: 90" > /etc/apt/preferences.d/limit-unstable
   126      fi
   127  }
   128  
   129  install() {
   130      case "$DISTRO" in
   131          ubuntu)
   132              install_ubuntu
   133              ;;
   134          *)
   135              install_debian
   136          esac
   137  }
   138  
   139  
   140  echo "### Detecting platform"
   141  get_os OS
   142  get_linux_distribution DISTRO
   143  get_version_codename VERSION_CODENAME
   144  
   145  echo "System info:
   146  OS: $OS
   147  Distribution: $DISTRO
   148  Version codename: $VERSION_CODENAME"
   149  echo "### Detecting platform - done"
   150  
   151  echo "### Installing myst & dependencies"
   152  install
   153  echo "### Installing myst & dependencies - done"
   154  
   155  echo "### Installation complete!"