3
# Essex-specific functions
6
# Set a config option in nova.conf or api-paste.ini, depending
7
# Defaults to updating nova.conf
13
local nova_conf=${NOVA_CONF:-/etc/nova/nova.conf}
14
local api_conf=${API_CONF:-/etc/nova/api-paste.ini}
16
[[ -z $key ]] && juju-log "$CHARM set_or_update: value $value missing key" && exit 1
17
[[ -z $value ]] && juju-log "$CHARM set_or_update: key $key missing value" && exit 1
18
[[ -z "$conf_file" ]] && conf_file=$nova_conf
21
"$nova_conf") match="\-\-$key="
25
"$api_conf") match="^$key = "
29
*) error_out "ERROR: set_or_update: Invalid conf_file ($conf_file)"
32
cat $conf_file | grep "$match$value" >/dev/null &&
33
juju-log "$CHARM: $key=$value already in set in $conf_file" \
35
if cat $conf_file | grep "$match" >/dev/null ; then
36
juju-log "$CHARM: Updating $conf_file, $key=$value"
37
sed -i "s|\($pattern\).*|\1$value|" $conf_file
39
juju-log "$CHARM: Setting new option $key=$value in $conf_file"
40
echo "$out$value" >>$conf_file