Reorganise etc directory for easier installation

This also means that the install script will install bash-completion for
heat.

Change-Id: Ib60346c72ce6277951cb51952e359f97be20a1be
Signed-off-by: Zane Bitter <zbitter@redhat.com>
This commit is contained in:
Zane Bitter 2012-09-07 15:09:54 +02:00
parent a44519774a
commit 55eb1746aa
9 changed files with 42 additions and 28 deletions

View File

@ -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 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
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
./setup.py install >/dev/null
rm -rf build heat.egg-info