Skip to content

Instantly share code, notes, and snippets.

@marcoceppi
Created April 9, 2013 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcoceppi/5349842 to your computer and use it in GitHub Desktop.
Save marcoceppi/5349842 to your computer and use it in GitHub Desktop.
If you have a relation and configuration option that are complimentary, this is one way to track those.
#!/bin/bash
# Just a common function file to rebuild the configuration
. lib/functions
master_server=`config-get master-server`
# Have the install script create a servers.d directory
# Store all the different values in there
if [ -z $master_server ]; then
rm -f servers.d/config
else
echo "$master_server" > servers.d/config
fi
# This lives in lib/functions - or wherever you want.
update_configuration
#!/bin/bash
update_configuration() {
servers=""
for server in `ls servers.d`; do
$servers="$servers;$server"
done
# Us ch_template_file, sed, or some other means to put that
# variable in to your configuration file.
}
#!/bin/bash
# Just a common function file to rebuild the configuration
. lib/functions
rm -f servers.d/$JUJU_RELATION_ID
# This lives in lib/functions - or wherever you want.
update_configuration
#!/bin/bash
# Just a common function file to rebuild the configuration
. lib/functions
master_server=`relation-get private-address`
if [ -z "$master_server" ]; then
juju-log "Waiting for relation details"
exit 0
fi
# $JUJU_RELATION_ID is unique for each relation. This is
# important for tracking later when you _remove_ a relation.
echo "$master_server" > servers.d/$JUJU_RELATION_ID
# This lives in lib/functions - or wherever you want.
update_configuration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment