]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Reorganise etc directory for easier installation
authorZane Bitter <zbitter@redhat.com>
Fri, 7 Sep 2012 13:09:54 +0000 (15:09 +0200)
committerZane Bitter <zbitter@redhat.com>
Fri, 7 Sep 2012 13:11:37 +0000 (15:11 +0200)
This also means that the install script will install bash-completion for
heat.

Change-Id: Ib60346c72ce6277951cb51952e359f97be20a1be
Signed-off-by: Zane Bitter <zbitter@redhat.com>
etc/heat/boto.cfg [moved from etc/boto.cfg with 100% similarity]
etc/heat/heat-api-cfn-paste.ini [moved from etc/heat-api-cfn-paste.ini with 100% similarity]
etc/heat/heat-api-cfn.conf [moved from etc/heat-api-cfn.conf with 100% similarity]
etc/heat/heat-api-cloudwatch-paste.ini [moved from etc/heat-api-cloudwatch-paste.ini with 100% similarity]
etc/heat/heat-api-cloudwatch.conf [moved from etc/heat-api-cloudwatch.conf with 100% similarity]
etc/heat/heat-engine.conf [moved from etc/heat-engine.conf with 100% similarity]
etc/heat/heat-metadata-paste.ini [moved from etc/heat-metadata-paste.ini with 100% similarity]
etc/heat/heat-metadata.conf [moved from etc/heat-metadata.conf with 100% similarity]
install.sh

similarity index 100%
rename from etc/boto.cfg
rename to etc/heat/boto.cfg
index 271d370d87eabd2ebc24171bb93db808973aa0ad..cf8aac93802c7b95b0713efc74a09b7351741d1e 100755 (executable)
@@ -5,41 +5,55 @@ if [[ $EUID -ne 0 ]]; then
     exit 1
 fi
 
-CONF_DIR=/etc/heat
+# Install prefix for config files (e.g. "/usr/local").
+# Leave empty to install into /etc
+CONF_PREFIX=""
 LOG_DIR=/var/log/heat
 
-mkdir -p $LOG_DIR
-mkdir -p $CONF_DIR
 
-pushd etc > /dev/null
+install -d $LOG_DIR
+
+
+archive_file() {
+    local f=$1
+
+    if [ -e $CONF_PREFIX/$f ]; then
+        echo "Archiving configuration file $CONF_PREFIX/$f" >&2
+        mv $CONF_PREFIX/$f $CONF_PREFIX/$f.bak
+    fi
+}
 
 # Archive existing heat-api* config files in preparation
 # for change to heat-api-cfn*, and future use of heat-api*
-# the OpenStack API
-for ext in '.conf' '-paste.ini'; do
-    heat_api_file="${CONF_DIR}/heat-api${ext}"
-    if [ -e ${heat_api_file} ]; then
-        echo "archiving configuration file ${heat_api_file}"
-        mv $heat_api_file ${heat_api_file}.bak
-    fi
-done
-
-for f in *
-do
-    if [ -d $f ]; then
-        # ignore directories
-        continue
-    elif [ -f $CONF_DIR/$f ]; then
-        echo "not copying over $CONF_DIR/$f"
-        diff -u $CONF_DIR/$f $f
-    elif [ $f = 'heat-engine.conf' ]; then
-       cat $f | sed s/%ENCRYPTION_KEY%/`hexdump -n 16 -v -e '/1 "%02x"' /dev/random`/ > $CONF_DIR/$f
-    else
-        cp $f $CONF_DIR
-    fi
-done
-popd > /dev/null
+# for the OpenStack API.
+archive_file etc/heat/heat-api.conf
+archive_file etc/heat/heat-api-paste.ini
+
+
+install_dir() {
+    local dir=$1
+    local prefix=$2
+
+    for fn in $(ls $dir); do
+        f=$dir/$fn
+        if [ -d $f ]; then
+            [ -d $prefix/$f ] || install -d $prefix/$f
+            install_dir $f $prefix
+        elif [ -f $prefix/$f ]; then
+            echo "NOT replacing existing config file $prefix/$f" >&2
+            diff -u $prefix/$f $f
+        elif [ $fn = 'heat-engine.conf' ]; then
+            cat $f | sed s/%ENCRYPTION_KEY%/`hexdump -n 16 -v -e '/1 "%02x"' /dev/random`/ > $prefix/$f
+        else
+
+            echo "Installing $fn in $prefix/$dir" >&2
+            install -m 664 $f $prefix/$dir
+        fi
+    done
+}
+
+install_dir etc $CONF_PREFIX
+
 
 ./setup.py install >/dev/null
 rm -rf build heat.egg-info
-