#!/bin/bash
# Check first argument
if ! echo "$1" | egrep -q '^(gp|swp|audit)$'
then
 echo -e '\e[31;5mError\e[0m'
 echo -e "Usage:\n$0 { gp | swp | audit }"
 exit 1
fi

# Update cache
salt-call state.apply gpupdate.build -c /srv/salt/standalone/config pillar='{"verbose": True, "force": True}'

# Run GP Update
salt-call state.apply gpupdate.$1 -c /srv/salt/standalone/config/ pillar='{"force": True,"verbose": True}'

