#!/bin/bash

echo "Running post install."

salt_return=1

until [ $salt_return -eq 0 ]; do
        echo "Waiting for the Salt Master to accept our key..."
        salt-call test.ping && salt_return=0 || salt_return=1; sleep 10
        echo ""
done

echo "Applying highstate."
salt-call -ldebug state.apply

echo "Disabling post-install.service."
systemctl disable post-install.service

echo "Completed, rebooting in 5 seconds..."
sleep 5;
# reboot