#!/bin/bash

set -e

echo -n 'Version number: '; read version
echo -n 'SUSE licence code: '; read licence_code
echo -n 'Customer code (three-letter acronym): '; read customer_code
echo -n 'SmartAIM username: '; read username
echo -n 'Password: '; read -s password; echo

# Download installation script and apply permissions
curl --location --fail --silent --show-error --output /root/install.sh --user "${username}:${password}" "https://subversion.smartaim.nl/svn/smart/tags/v${version}/install/install.sh"
chmod 744 /root/install.sh

# Execute installation script
/root/install.sh "${username}" "${password}" "${username}" "${password}" "${customer_code,,}" "${licence_code}" '1' '' "tags/v${version}" "${version}"

# Execute setup script
/root/setup.sh "${username}" "${password}" "tags/v${version}"

# Delete scripts
rm /root/setup.sh
rm /root/install.sh
rm /root/start.sh
