#!/bin/bash

set -euo pipefail

v=RELEASE.2021-01-05T05-03-58Z
basedir=$(dirname $0)

mc="$basedir/.mc/mc.$v"

mkdir -p "$(dirname $mc)"

if [[ ! -x $mc ]]
then
  wget -O "$mc" https://dl.min.io/client/mc/release/linux-amd64/archive/mc.$v
  chmod +x "$mc"
  ln -s mc.$v "$basedir/.mc/mc"
fi

exec "$basedir/.mc/mc" "${@}"