diff options
author | Angus Salkeld <asalkeld@redhat.com> | 2013-08-29 12:05:37 +1000 |
---|---|---|
committer | Angus Salkeld <asalkeld@redhat.com> | 2013-09-02 10:43:21 +1000 |
commit | ae28bf4c89a69f854eb4556fb584f0d4f92526ad (patch) | |
tree | 06e1d5a458f74cc6c0bfd2c5777b4cded35d3596 /install.sh | |
parent | 752da8e0c1b22709fcbbbe906efb48dbf2217510 (diff) | |
download | heat-ae28bf4c89a69f854eb4556fb584f0d4f92526ad.tar.gz |
Remove references to the multiple config files
Only refer to heat.conf in the docs and scripts.
For install.sh copy the iniset() function from devstack
to assist in setting some semi-sane defaults.
Change-Id: I933891e35103c003f1272bc89c7b42d2ad76697b
Diffstat (limited to 'install.sh')
-rwxr-xr-x | install.sh | 73 |
1 files changed, 60 insertions, 13 deletions
diff --git a/install.sh b/install.sh index efe1fac5b..40dfefae4 100755 --- a/install.sh +++ b/install.sh @@ -35,16 +35,60 @@ detect_rabbit() { return 1 } -sed_if_rabbit() { - DEFAULT_RABBIT_PASSWORD="guest" +# Determinate is the given option present in the INI file +# ini_has_option config-file section option +function ini_has_option() { + local file=$1 + local section=$2 + local option=$3 + local line + line=$(sed -ne "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ p; }" "$file") + [ -n "$line" ] +} + +# Set an option in an INI file +# iniset config-file section option value +function iniset() { + local file=$1 + local section=$2 + local option=$3 + local value=$4 + if ! grep -q "^\[$section\]" "$file"; then + # Add section at the end + echo -e "\n[$section]" >>"$file" + fi + if ! ini_has_option "$file" "$section" "$option"; then + # Add it + sed -i -e "/^\[$section\]/ a\\ +$option = $value +" "$file" + else + # Replace it + sed -i -e "/^\[$section\]/,/^\[.*\]/ s|^\($option[ \t]*=[ \t]*\).*$|\1$value|" "$file" + fi +} + +basic_configuration() { conf_path=$1 if echo $conf_path | grep ".conf$" >/dev/null 2>&1 then - if detect_rabbit + iniset $target DEFAULT auth_encryption_key `hexdump -n 16 -v -e '/1 "%02x"' /dev/random` + iniset $target DEFAULT db_backend heat.db.sqlalchemy.api + iniset $target DEFAULT sql_connection "mysql://heat:heat@localhost/heat" + + BRIDGE_IP=127.0.0.1 + iniset $target DEFAULT heat_metadata_server_url "http://${BRIDGE_IP}:8000/" + iniset $target DEFAULT heat_waitcondition_server_url "http://${BRIDGE_IP}:8000/v1/waitcondition/" + iniset $target DEFAULT heat_watch_server_url "http://${BRIDGE_IP}:8003/" + + if detect_rabbit then echo "rabbitmq detected, configuring $conf_path for rabbit" >&2 - sed -i "/^rpc_backend\b/ s/impl_qpid/impl_kombu/" $conf_path - sed -i "/^rpc_backend/a rabbit_password=$DEFAULT_RABBIT_PASSWORD" $conf_path + iniset $conf_path DEFAULT rpc_backend heat.openstack.common.rpc.impl_kombu + iniset $conf_path DEFAULT rabbit_password guest + else + echo "qpid detected, configuring $conf_path for qpid" >&2 + iniset $conf_path DEFAULT rpc_backend heat.openstack.common.rpc.impl_qpid fi fi } @@ -55,19 +99,22 @@ install_dir() { for fn in $(ls $dir); do f=$dir/$fn + target=$prefix/$f + if [ $fn = 'heat.conf.sample' ]; then + target=$prefix/$dir/heat.conf + fi if [ -d $f ]; then - [ -d $prefix/$f ] || install -d $prefix/$f + [ -d $target ] || install -d $target install_dir $f $prefix - elif [ -f $prefix/$f ]; then - echo "NOT replacing existing config file $prefix/$f" >&2 - diff -u $prefix/$f $f + elif [ -f $target ]; then + echo "NOT replacing existing config file $target" >&2 + diff -u $target $f else echo "Installing $fn in $prefix/$dir" >&2 - install -m 664 $f $prefix/$dir - if [ $fn = 'heat-engine.conf' ]; then - sed -i "s/%ENCRYPTION_KEY%/`hexdump -n 16 -v -e '/1 "%02x"' /dev/random`/" $prefix/$f + install -m 664 $f $target + if [ $fn = 'heat.conf.sample' ]; then + basic_configuration $target fi - sed_if_rabbit $prefix/$f fi done } |