318
##########################################################################
319
# Description: Creates an rc file exporting environment variables to a
320
# script_path local to the charm's installed directory.
321
# Any charm scripts run outside the juju hook environment can source this
322
# scriptrc to obtain updated config information necessary to perform health
323
# checks or service changes
326
# An array of '=' delimited ENV_VAR:value combinations to export.
327
# If optional script_path key is not provided in the array, script_path
328
# defaults to scripts/scriptrc
329
##########################################################################
330
function save_script_rc {
331
if [ ! -n "$JUJU_UNIT_NAME" ]; then
332
echo "Error: Missing JUJU_UNIT_NAME environment variable"
335
# our default unit_path
336
unit_path="/var/lib/juju/units/${JUJU_UNIT_NAME/\//-}/charm/scripts/scriptrc"
338
tmp_rc="/tmp/${JUJU_UNIT_NAME/\//-}rc"
340
echo "#!/bin/bash" > $tmp_rc
341
for env_var in "${@}"
343
if `echo $env_var | grep -q script_path`; then
344
# well then we need to reset the new unit-local script path
345
unit_path="/var/lib/juju/units/${JUJU_UNIT_NAME/\//-}/charm/${env_var/script_path=/}"
347
echo "export $env_var" >> $tmp_rc
351
mv $tmp_rc $unit_path
318
355
HAPROXY_CFG=/etc/haproxy/haproxy.cfg
319
356
HAPROXY_DEFAULT=/etc/default/haproxy