~hopem/charms/trusty/openstack-dashboard/lp1518975

« back to all changes in this revision

Viewing changes to hooks/lib/openstack-common

  • Committer: Chad Smith
  • Date: 2013-02-26 17:26:20 UTC
  • mto: (17.1.9 openstack-dashboard)
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: chad.smith@canonical.com-20130226172620-xy5chdbikgac0x2c
-add health_checks.d, add_to_cluster and remove_from_cluster scripts
-create a bash save_script_rc function which creates a local scriptrc file
 comparable to our python-based function

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