Skip to content

Instantly share code, notes, and snippets.

@drnic
Created June 17, 2015 14:46
Show Gist options
  • Save drnic/42e27e846f9ef7919599 to your computer and use it in GitHub Desktop.
Save drnic/42e27e846f9ef7919599 to your computer and use it in GitHub Desktop.
Target current BOSH's current CF manifest and run nats CLI on its nats configuration
#!/bin/bash
# Assumes using nats CLI from https://github.com/soutenniza/nats/releases
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd $DIR/..
bosh_target=$(cat .bosh_config | yaml2json | jq -r ".target")
manifest=$(cat .bosh_config | yaml2json | jq -r ".deployment[\"$bosh_target\"]")
mbus=$(cat $manifest | yaml2json | jq -r '.properties.nats | "nats://\(.user):\(.password)@\(.address):\(.port)"')
command=$1; shift
if [[ "${command}X" == "X" ]]; then
echo "USAGE: ./bin/nats.sh [pub|sub] ARGS"
exit 1
fi
nats $command -s $mbus $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment