github.com/masterhung0112/hk_server/v5@v5.0.0-20220302090640-ec71aef15e1c/scripts/download_mmctl_release.sh (about)

     1  #!/usr/bin/env bash
     2  # $1 - version to download
     3  
     4  if [[ "$OS" = "Windows_NT" ]]
     5  then
     6    PLATFORM="Windows"
     7  else
     8    PLATFORM=$(uname)
     9  fi
    10  
    11  if [[ ! -z "$1" ]];
    12  then
    13    OVERRIDE_OS=$1
    14  fi
    15  
    16  BIN_PATH=${2:-bin}
    17  
    18  # strip whitespace
    19  THIS_BRANCH=$(git rev-parse --abbrev-ref HEAD)
    20  if [[ "$THIS_BRANCH" =~ 'release-'[0-9] ]];
    21  then
    22    RELEASE_TO_DOWNLOAD="$THIS_BRANCH"
    23  else
    24    RELEASE_TO_DOWNLOAD=master
    25  fi
    26  
    27  echo "Downloading prepackaged binary: https://releases.mattermost.com/mmctl/$RELEASE_TO_DOWNLOAD";
    28  
    29  # When packaging we need to download different platforms
    30  # Values need to match the case statement below
    31  if [[ ! -z "$OVERRIDE_OS" ]];
    32  then
    33    PLATFORM="$OVERRIDE_OS"
    34  fi
    35  
    36  case "$PLATFORM" in
    37  
    38  Linux)
    39    MMCTL_FILE="linux_amd64.tar" && curl -f -O -L https://releases.mattermost.com/mmctl/"$RELEASE_TO_DOWNLOAD"/"$MMCTL_FILE" && tar -xvf "$MMCTL_FILE" -C "$BIN_PATH" && rm "$MMCTL_FILE";
    40    ;;
    41  
    42  Darwin)
    43    MMCTL_FILE="darwin_amd64.tar" && curl -f -O -L https://releases.mattermost.com/mmctl/"$RELEASE_TO_DOWNLOAD"/"$MMCTL_FILE" && tar -xvf "$MMCTL_FILE" -C "$BIN_PATH" && rm "$MMCTL_FILE";
    44    ;;
    45  
    46  Windows)
    47    MMCTL_FILE="windows_amd64.zip" && curl -f -O -L https://releases.mattermost.com/mmctl/"$RELEASE_TO_DOWNLOAD"/"$MMCTL_FILE" && unzip -o "$MMCTL_FILE" -d "$BIN_PATH" && rm "$MMCTL_FILE";
    48    ;;
    49  
    50  *)
    51    echo "error downloading mmctl: can't detect OS";
    52    ;;
    53  
    54  esac