github.com/wata727/tflint@v0.12.2-0.20191013070026-96dd0d36f385/install_linux.sh (about)

     1  #!/bin/bash -e
     2  
     3  processor=$(uname -m)
     4  
     5  if [ "$processor" == "x86_64" ]; then
     6    arch="amd64"
     7  else
     8    arch="386"
     9  fi
    10  
    11  case "$(uname -s)" in
    12    Darwin*)
    13      os="darwin_${arch}"
    14      ;;
    15    MINGW64*)
    16      os="windows_${arch}"
    17      ;;
    18    MSYS_NT*)
    19      os="windows_${arch}"
    20      ;;
    21    *)
    22      os="linux_${arch}"
    23      ;;
    24  esac
    25  
    26  echo "os=$os"
    27  
    28  echo -e "\n\n===================================================="
    29  
    30  get_latest_release() {
    31    curl --silent "https://api.github.com/repos/wata727/tflint/releases/latest" | # Get latest release from GitHub api
    32      grep '"tag_name":' |                                            # Get tag line
    33      sed -E 's/.*"([^"]+)".*/\1/'                                    # Pluck JSON value
    34  }
    35  
    36  echo "Looking up the latest version ..."
    37  latest_version=$(get_latest_release)
    38  echo "Downloading latest version of tflint which is $latest_version"
    39  curl -L -o /tmp/tflint.zip "https://github.com/wata727/tflint/releases/download/${latest_version}/tflint_${os}.zip"
    40  retVal=$?
    41  if [ $retVal -ne 0 ]; then
    42    echo "Failed to download tflint_${os}.zip"
    43    exit $retVal
    44  else
    45    echo "Download was successfully"
    46  fi
    47  
    48  echo -e "\n\n===================================================="
    49  echo "Unpacking /tmp/tflint.zip ..."
    50  unzip -u /tmp/tflint.zip -d /tmp/
    51  echo "Installing /tmp/tflint to /usr/local/bin..."
    52  sudo mkdir -p /usr/local/bin
    53  sudo install -b -C -v /tmp/tflint /usr/local/bin/
    54  retVal=$?
    55  if [ $retVal -ne 0 ]; then
    56    echo "Failed to install tflint"
    57    exit $retVal
    58  else
    59    echo "tflint installed at /usr/local/bin/ successfully"
    60  fi
    61  
    62  echo -e "\n\n===================================================="
    63  echo "Current tflint version"
    64  tflint -v
    65  
    66  
    67  
    68