github.com/haalcala/mattermost-server-change-repo@v0.0.0-20210713015153-16753fbeee5f/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  RELEASE_TO_DOWNLOAD="release-5.33"
    28  
    29  echo "Downloading prepackaged binary: https://releases.mattermost.com/mmctl/$RELEASE_TO_DOWNLOAD";
    30  
    31  # When packaging we need to download different platforms
    32  # Values need to match the case statement below
    33  if [[ ! -z "$OVERRIDE_OS" ]];
    34  then
    35    PLATFORM="$OVERRIDE_OS"
    36  fi
    37  
    38  case "$PLATFORM" in
    39  
    40  Linux)
    41    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";
    42    ;;
    43  
    44  Darwin)
    45    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";
    46    ;;
    47  
    48  Windows)
    49    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";
    50    ;;
    51  
    52  *)
    53    echo "error downloading mmctl: can't detect OS";
    54    ;;
    55  
    56  esac