ceph/qa/qa_scripts/openstack/fix_conf_file.sh
Alan Somers 821511bd32 openstack: Fix shebangs on openstack scripts
Many of the files in qa/qa_scripts/openstack had incorrect shebang
lines: the bang was missing.  This means that those scripts would
execute using the calling user's login shell, which is doubtless not
what the author intended.  Now they'll always use bash.

Two scripts do not need shebangs, because they contain only library
functions and don't execute anything.  I removed their shebangs.

Signed-off-by: Alan Somers <asomers@gmail.com>
2017-07-24 17:33:02 -06:00

29 lines
999 B
Bash
Executable File

source ./copy_func.sh
#
# Take a templated file, modify a local copy, and write it to the
# remote site.
#
# Usage: fix_conf_file <remote-site> <file-name> <remote-location> [<rbd-secret>]
# <remote-site> -- site where we want this modified file stored.
# <file-name> -- name of the remote file.
# <remote-location> -- directory where the file will be stored
# <rbd-secret> -- (optional) rbd_secret used by libvirt
#
function fix_conf_file() {
if [[ $# < 3 ]]; then
echo 'fix_conf_file: Too few parameters'
exit 1
fi
openstack_node_local=${1}
cp files/${2}.template.conf ${2}.conf
hostname=`ssh $openstack_node_local hostname`
inet4addr=`ssh $openstack_node_local hostname -i`
sed -i s/VARHOSTNAME/$hostname/g ${2}.conf
sed -i s/VARINET4ADDR/$inet4addr/g ${2}.conf
if [[ $# == 4 ]]; then
sed -i s/RBDSECRET/${4}/g ${2}.conf
fi
copy_file ${2}.conf $openstack_node_local ${3} 0644 "root:root"
rm ${2}.conf
}