Skip to content

Instantly share code, notes, and snippets.

@morika-t
Forked from drnic/nats.sh
Last active August 29, 2015 14:23
Show Gist options
  • Save morika-t/f8b79f53373c684c3020 to your computer and use it in GitHub Desktop.
Save morika-t/f8b79f53373c684c3020 to your computer and use it in GitHub Desktop.
#!/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