#!/bin/bash

set -e

if [ $# -ne 1 ] ; then
    echo "usage; <prog> version"
    echo "e.g., ./update-installer.sh 2.1"
    echo ""
    exit 1
fi

mkdir -p $1
cd $1

rm -f hopsworks-installer.sh
wget https://raw.githubusercontent.com/logicalclocks/karamel-chef/$1/hopsworks-installer.sh
chmod +x hopsworks-installer.sh
rm -f hopsworks-cloud-installer.sh
wget https://raw.githubusercontent.com/logicalclocks/karamel-chef/$1/cloud/hopsworks-cloud-installer.sh
chmod +x hopsworks-cloud-installer.sh
cd ..

rm -f latest
ln -s $1 latest

echo "Done."

exit 0
