~brad-marshall/charms/trusty/glance/add-nrpe-checks

« back to all changes in this revision

Viewing changes to hooks/lib/openstack-common

  • Committer: Jerry Seutter
  • Date: 2013-03-01 18:37:23 UTC
  • mto: (29.2.13 ha)
  • mto: This revision was merged to the branch mainline in revision 33.
  • Revision ID: jerry.seutter@canonical.com-20130301183723-crlqa3vfzcj8x6ku
Adding health scripts to glance charm.

Show diffs side-by-side

added added

removed removed

Lines of Context:
315
315
  return 0
316
316
}
317
317
 
 
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
 
324
#
 
325
# Parameters: 
 
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"
 
333
     exit 1
 
334
  fi
 
335
  # our default unit_path
 
336
  unit_path="/var/lib/juju/units/${JUJU_UNIT_NAME/\//-}/charm/scripts/scriptrc"
 
337
  echo $unit_path
 
338
  tmp_rc="/tmp/${JUJU_UNIT_NAME/\//-}rc"
 
339
 
 
340
  echo "#!/bin/bash" > $tmp_rc
 
341
  for env_var in "${@}"
 
342
  do
 
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=/}"
 
346
    else
 
347
       echo "export $env_var" >> $tmp_rc
 
348
    fi 
 
349
  done
 
350
  chmod 755 $tmp_rc
 
351
  mv $tmp_rc $unit_path
 
352
}
 
353
 
 
354
 
318
355
HAPROXY_CFG=/etc/haproxy/haproxy.cfg
319
356
HAPROXY_DEFAULT=/etc/default/haproxy
320
357