MT#8763 allow multiple config directories on templates not only "/etc"

Change-Id: I1c8fc5fd45a0c34ba7542ddc6ce24793bd568cb5
changes/88/88/2
Victor Seva 12 years ago
parent 6c74dde2bf
commit 5ed308c1a0

@ -11,13 +11,13 @@ CONSTANTS_CONFIG="${NGCPCTL_MAIN}/constants.yml"
NETWORK_CONFIG="${NGCPCTL_MAIN}/network.yml"
EXTRA_CONFIG_DIR="${NGCPCTL_MAIN}/config.d/"
# configuration files that should be managed
# configuration dirs that should be managed
CONFIG_POOL='/etc'
# location of templates
TEMPLATE_POOL="${NGCPCTL_MAIN}/templates/${CONFIG_POOL}"
TEMPLATE_POOL_BASE="${NGCPCTL_MAIN}/templates"
# location of service definitions
SERVICES_POOL="${NGCPCTL_MAIN}/templates/${CONFIG_POOL}"
SERVICES_POOL_BASE="${NGCPCTL_MAIN}/templates"
## END OF FILE #################################################################

@ -75,8 +75,8 @@ elif ! [ -r "$NETWORK_CONFIG" ] ; then
exit 1
fi
if ! [ -d "$TEMPLATE_POOL" ] ; then
log_error "No template directory (${TEMPLATE_POOL}) found - exiting."
if ! [ -d "$TEMPLATE_POOL_BASE" ] ; then
log_error "No template directory (${TEMPLATE_POOL_BASE}) found - exiting."
exit 1
fi
@ -124,24 +124,27 @@ fi
## functions {{{
generate_template_list() {
[ -n "$TEMPLATE_POOL" ] || return 1
[ -n "$TEMPLATE_POOL_BASE" ] || return 1
local filelist_prepared=$(mktemp)
local filelist_final=$(mktemp)
# iterate over all files
for file in $(find "$TEMPLATE_POOL" -name \*.tt2 -o -name \*.tt2"${HA_FILE:-}") ; do
# *NO* arguments provided via cmdline
if [ -z "${1:-}" ] ; then
echo "$file" >> "${filelist_prepared}"
else
# arguments (file list/pattern) provided via cmdline
for arg in $* ; do
if echo $file | grep -q -- "${arg}" ; then
echo "$file" >> "${filelist_prepared}"
fi
done
fi
for dir in ${CONFIG_POOL} ; do
[ -n "${dir}" ] || ( echo "${dir} doesn't exist" >&2 ; continue )
# iterate over all files
for file in $(find "$TEMPLATE_POOL_BASE/${dir}" -name \*.tt2 -o -name \*.tt2"${HA_FILE:-}") ; do
# *NO* arguments provided via cmdline
if [ -z "${1:-}" ] ; then
echo "$file" >> "${filelist_prepared}"
else
# arguments (file list/pattern) provided via cmdline
for arg in $* ; do
if echo $file | grep -q -- "${arg}" ; then
echo "$file" >> "${filelist_prepared}"
fi
done
fi
done
done
# remove all filenames where a preferred filename exists

@ -17,18 +17,20 @@ fi
. ${FUNCTIONS}/main
get_config_file_list() {
for file in $(find "$TEMPLATE_POOL" -name \*.tt2 -o -name \*.tt2"${HA_FILE:-}") ; do
x=${file##${NGCPCTL_MAIN}/templates/} # drop leading /etc/ngcp-config
y=${x%%.tt2} # drop trailing suffix '.tt2'
y=${y%%.tt2.sp1} # drop trailing suffix '.tt2.sp1'
y=${y%%.tt2.sp2} # drop trailing suffix '.tt2.sp2'
y=${y%%.customtt} # drop trailing suffix '.customtt'
# if the file does not exist (e.g. because "ngcpcfg apply"
# hasn't been executed yet for whatever reason, then don't
# report missing files, otherwise tar will complain
if [ -r "/${y}" ] ; then
echo "/${y}"
fi
for dir in ${CONFIG_POOL} ; do
for file in $(find "$TEMPLATE_POOL_BASE/${dir}" -name \*.tt2 -o -name \*.tt2"${HA_FILE:-}") ; do
x=${file##${NGCPCTL_MAIN}/templates/} # drop leading /etc/ngcp-config
y=${x%%.tt2} # drop trailing suffix '.tt2'
y=${y%%.tt2.sp1} # drop trailing suffix '.tt2.sp1'
y=${y%%.tt2.sp2} # drop trailing suffix '.tt2.sp2'
y=${y%%.customtt} # drop trailing suffix '.customtt'
# if the file does not exist (e.g. because "ngcpcfg apply"
# hasn't been executed yet for whatever reason, then don't
# report missing files, otherwise tar will complain
if [ -r "/${y}" ] ; then
echo "/${y}"
fi
done
done
}

@ -15,8 +15,6 @@ fi
# main script
cd "$CONFIG_POOL"
DRYRUN='false'
if [[ "${1:-}" == "test" ]] || [[ "${1:-}" == "--dry-run" ]]; then
DRYRUN='true'
@ -42,14 +40,17 @@ unifyer() {
fi
}
for file in $(git status --porcelain | sed 's/^...//') ; do
if [ -r "$file" ] && [ -r "${SERVICES_POOL}/${file}".services ] ; then
log_debug "unifyer ${SERVICES_POOL}/${file}.services"
unifyer "${SERVICES_POOL}/${file}".services
elif [ -r "$file" ] && [ -r $SERVICES_POOL/"$(dirname $file)"/ngcpcfg.services ] ; then
log_debug "unifyer ${SERVICES_POOL}/$(dirname $file)/ngcpcfg.services"
unifyer "${SERVICES_POOL}"/"$(dirname $file)/ngcpcfg.services"
fi
for dir in ${CONFIG_POOL} ; do
cd "${dir}"
for file in $(git status --porcelain | sed 's/^...//') ; do
if [ -r "$file" ] && [ -r "${SERVICES_POOL_BASE}/${dir}/${file}".services ] ; then
log_debug "unifyer ${SERVICES_POOL_BASE}/${dir}/${file}.services"
unifyer "${SERVICES_POOL_BASE}/${dir}/${file}".services
elif [ -r "$file" ] && [ -r $SERVICES_POOL_BASE/${dir}/"$(dirname $file)"/ngcpcfg.services ] ; then
log_debug "unifyer ${SERVICES_POOL_BASE}/${dir}/$(dirname $file)/ngcpcfg.services"
unifyer "${SERVICES_POOL_BASE}/${dir}"/"$(dirname $file)/ngcpcfg.services"
fi
done
done
exec_wrapper() {

@ -13,10 +13,10 @@ CONSTANTS_CONFIG="${NGCPCTL_MAIN}/constants.yml"
CONFIG_POOL='/tmp/output'
# location of templates
TEMPLATE_POOL="${NGCPCTL_MAIN}/templates/testsuite"
TEMPLATE_POOL_BASE="${NGCPCTL_MAIN}/templates/testsuite"
# location of service definitions
SERVICES_POOL="${NGCPCTL_MAIN}/templates/testsuite"
SERVICES_POOL_BASE="${NGCPCTL_MAIN}/templates/testsuite"
## NOTE: only supported with ngcp-ngcpcfg-ha
# supported values: {true,false}

Loading…
Cancel
Save