Skip to content
Snippets Groups Projects
Select Git revision
  • 1.6
  • dev default protected
  • release/1.9.1 protected
  • pini-1.8-docker
  • pini-sync-onlypeers
  • duniter-v2s-issue-123-industrialize-releases
  • feature/build-aarch64-nodejs16
  • release/1.8 protected
  • pini-docker
  • ci_tags
  • fix/1448/1.8/txs_not_stored
  • feature/node-20
  • fix/1441/node_summary_with_storage
  • fix/1442/improve_bma_tx_history
  • feature/wotwizard-1.8
  • release/1.9 protected
  • 1.7 protected
  • feature/docker-set-latest protected
  • feature/fast-docker-build-1.8.4
  • fast-docker-build protected
  • feature/dump-distance
  • v1.8.7 protected
  • v1.8.7-rc4 protected
  • v1.8.7-rc3 protected
  • v1.8.7-rc2 protected
  • v1.8.7-rc1 protected
  • v1.8.6 protected
  • v1.7.23 protected
  • v1.8.5 protected
  • v1.8.4 protected
  • v1.8.3 protected
  • v1.8.2 protected
  • v1.8.1 protected
  • v1.8.0 protected
  • v1.8.0-rc1 protected
  • v1.8.0-beta5 protected
  • v1.8.0-beta4 protected
  • v1.8.0-beta3 protected
  • v1.8.0-beta2 protected
  • v1.8.0-beta protected
  • v1.7.21 protected
41 results

Protocol.md

Blame
  • install.sh 2.13 KiB
    #!/bin/bash
    
    { # this ensures the entire script is downloaded #
    
    is_installed() {
      type "$1" > /dev/null 2>&1
    }
    
    CESIUM_DIR=${1:-$(pwd)/cesium}
    
    latest_version() {
      echo "v1.7.13" # lastest
    }
    
    api_release_url() {
      echo "https://api.github.com/repos/duniter/cesium/releases/tags/$(latest_version)"
    }
    
    download() {
      if is_installed "curl"; then
        curl -qkL $*
      elif is_installed "wget"; then
        # Emulate curl with wget
        ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \
                               -e 's/-L //' \
                               -e 's/-I /--server-response /' \
                               -e 's/-s /-q /' \
                               -e 's/-o /-O /' \
                               -e 's/-C - /-c /')
        wget $ARGS
      fi
    }
    
    install_from_github() {
    
      local RELEASE=$(curl -XGET -i "$(api_release_url)")
      local CESIUM_URL=$(echo "$RELEASE" | grep -P '"browser_download_url": "[^"]+' | grep -oP "https://[a-zA-Z0-9/.-]+-web.zip" | head -n 1)
      local CESIUM_ARCHIVE="$CESIUM_DIR/cesium.zip"
    
      if [ ! -d "$CESIUM_DIR" ]; then
        mkdir -p "$CESIUM_DIR"
      elif [ -f "$CESIUM_ARCHIVE" ]; then
        echo "WARNING: Deleting existing archive [$CESIUM_ARCHIVE]"
        rm "$CESIUM_ARCHIVE"
      fi
    
      echo "Downloading [$CESIUM_URL]"
      download "$CESIUM_URL" -o "$CESIUM_ARCHIVE" || {
        echo >&2 "Failed to download '$CESIUM_URL'"
        return 4
      }
    
      echo "Unarchiving to $CESIUM_DIR"
      unzip -o "$CESIUM_ARCHIVE" -d "$CESIUM_DIR"
      rm "$CESIUM_ARCHIVE"
    
      echo "Cesium successfully installed at $CESIUM_DIR"
    }
    
    do_install() {
    
      if ! is_installed "curl" && ! is_installed "wget"; then
        echo "=> Neither 'curl' nor 'wget' is available. Please install one of them."
        exit 1
      fi
    
      if ! is_installed "unzip"; then
        echo "=> 'unzip' is not available. You will likely need to install the 'unzip' package."
        exit 1
      fi
    
      install_from_github
    }
    
    #
    # Unsets the various functions defined
    # during the execution of the install script
    #
    reset() {
      unset -f reset is_installed latest_version api_release_url download install_from_github do_install
    }
    
    [ "_$CESIUM_ENV" = "_testing" ] || do_install "$1"
    
    } # this ensures the entire script is downloaded #