#!/bin/bash
# Setup the salt minion to use a local master, for use
# in a default node
# © 2016, Multapplied Networks, Inc.

options=':qn'
while getopts $options option ; do
    case $option in
        q  )    quiet=1 ;;  # Silence all output
        n  )    noconfirm=1 ;;  # Don't ask for confirmation
        \? )    echo "Unknown option"; exit 1 ;;
    esac
done

if [[ ! ${noconfirm} -eq 1 ]] ; then
    echo "This will reset the salt-minion to a default configuration. This can be undone by running 'nodeconfig'."
    read -p "Are you sure? (y/N) " confirm
    case ${confirm} in
        [Yy]* ) ;;
        [Nn]* ) exit ;;
        *     ) exit ;;
    esac
fi

mkdir --parents /etc/salt/minion.d/
echo "file_client: local" > "/etc/salt/minion.d/bonding.conf"

if [[ ! ${quiet} -eq 1 ]] ; then
	echo "Run 'service salt-minion restart' to run in default mode"
fi
