Files
dotfiles/env/.local/scripts/hpa

36 lines
997 B
Bash
Executable File

#!/usr/bin/env bash
set -e
set -o nounset
set -o pipefail
# A wrapper script to run swift-hpa in a docker container and
# mount the correct volumes, etc.
#
# Make sure to run 'hpa-init' first on this machine to setup
# dependencies, if you have not done so already.
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
. "$SCRIPTS/utils/hpa/hpa.env"
############################## MAIN ##############################
last_pull="0"
if [[ -f "$HPA_CONFIG_DIR/.lastpull" ]]; then
last_pull=$(cat "$HPA_CONFIG_DIR/.lastpull")
fi
curr=$(date +%s)
diff=$((curr - last_pull))
if [[ $HPA_AUTO_PULL == "1" ]] && [[ $diff -gt "$HPA_AUTO_PULL_INTERVAL" ]]; then
. "$SCRIPTS/hpa-pull" "$HPA_AUTO_PULL_OPTS"
fi
podman run --rm --interactive --tty \
--volume "$HPA_DATA_DIR/template":/template \
--volume "$HPA_DATA_DIR/playbook":/playbook \
--volume "$HPA_CONFIG_DIR":/config/hpa \
--volume "$HPA_CONSULTS_DIR":/consults \
--secret "$HPA_VAULT_SECRET_KEY" \
"$HPA_DOCKER_IMAGE:$HPA_DOCKER_TAG" "$@"