#!/usr/bin/env bash

PATH=.:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:`dirname $0`

user=`whoami`
sudo='sudo'
if [ $user = 'root' ]; then
  sudo=''
fi

$sudo curl <%= node['dcos-grid']['dcos_cli_release_url'] %> -o /usr/local/bin/dcos && 
$sudo chmod +x /usr/local/bin/dcos && 
$sudo dcos config set core.dcos_url https://<%= node['dcos-grid']['bootstrap']['config']['master_list'][0] %>

# old way
#mkdir -p dcos && cd dcos && 
#curl -O https://downloads.dcos.io/dcos-cli/install.sh && 
#bash ./install.sh . https://<%= node['dcos-grid']['bootstrap']['config']['master_list'][0] %> && 
#source ./bin/env-setup
