function _get_and_save_secret() { function is_set() { local name="$1" eval "echo \$$name" | grep . > /dev/null } local name="$1" eval "$name=\${$name:-}" if ! is_set $name; then eval "$name=$(security find-generic-password -a $USER -s $name -w 2> /dev/null)" if ! is_set "$name"; then eval "read -s -p 'Enter $name: ' $name" >&2 eval "security add-generic-password -a $USER -s $name -w \$$name" >&2 echo "" >&2 fi fi eval "echo \$$name" } function get_and_save_secret() { _get_and_save_secret "$@" | tail -n 1 } SENSU_API_USER="$(get_and_save_secret SENSU_API_USER)" SENSU_API_PASS="$(get_and_save_secret SENSU_API_PASS)" SLACK_API_TOKEN="$(get_and_save_secret SLACK_API_TOKEN)" echo SENSU_USER=$SENSU_API_USER >&2 echo SENSU_PASS=$SENSU_API_PASS >&2 echo SLACK_TOKEN=$SLACK_API_TOKEN >&2 git submodule update --remote rm -rf alert_configs cp -r AoM_Configs/alert_configs . docker build -t aom:dev . docker rm -f aom docker run \ -e SLACK_API_TOKEN=${SLACK_API_TOKEN} \ -e API_USER=$SENSU_API_USER \ -e API_PASS=$SENSU_API_PASS \ --rm \ -d \ -p 8080:8080 \ --add-host telegraf:10.4.13.53 \ --name aom \ --add-host consul.service.consul:127.0.0.1 \ -h 127.0.0.1 \ aom:dev & until curl localhost:8080/healthcheck; do sleep 1; done docker logs -f aom