MT#14229 clean shellcheck warnings

While at it spread support for testsuite

Change-Id: I60c4dae5479827b0d28ffa135105d9dbdf603825
changes/13/2713/4
Victor Seva 10 years ago
parent 76ada0a772
commit eac494cb42

@ -6,14 +6,19 @@ set -e
set -u
set -o pipefail
if ! [ -r /usr/share/ngcp-ngcpcfg/functions/main ] ; then
printf "Error: /usr/share/ngcp-ngcpcfg/functions/main could not be read. Exiting.\n" >&2
# support testsuite
FUNCTIONS="${FUNCTIONS:-/usr/share/ngcp-ngcpcfg/functions/}"
HELPER="${HELPER:-/usr/share/ngcp-ngcpcfg/helper/}"
SCRIPTS="${SCRIPTS:-/usr/share/ngcp-ngcpcfg/scripts/}"
if ! [ -r "${FUNCTIONS}"/main ] ; then
printf "Error: %s/main could not be read. Exiting.\n" "${FUNCTIONS}">&2
exit 1
fi
. /usr/share/ngcp-ngcpcfg/functions/main
timestamp_replacementchars=''
. "${FUNCTIONS}"/main
HELPER="${HELPER:-/usr/share/ngcp-ngcpcfg/helper/}"
# main script
cd "$NGCPCTL_MAIN"
@ -35,16 +40,16 @@ if ! git config user.name >/dev/null ; then
git config user.name "ngcp-config"
fi
if ! git config user.email >/dev/null ; then
log_debug 'git config user.email "root@$(hostname)"'
log_debug "git config user.email \"root@\$(hostname)\""
git config user.email "root@$(hostname)"
fi
if ! git config --global user.name >/dev/null ; then
log_debug 'git config --global user.name "git user on $(hostname)"'
log_debug "git config --global user.name \"git user on \$(hostname)\""
git config --global user.name "git user on $(hostname)"
fi
if ! git config --global user.email >/dev/null ; then
log_debug 'git config --global user.email "root@$(hostname)"'
log_debug "git config --global user.email \"root@\$(hostname)\""
git config --global user.email "root@$(hostname)"
fi
@ -59,23 +64,23 @@ log_debug "git status | grep -q 'working directory clean'"
if git status | grep -q 'working directory clean' ; then
log_info "OK: nothing to commit."
else
if [ -f /usr/share/ngcp-ngcpcfg/scripts/pull ] ; then
if [ -f "${SCRIPTS}"/pull ] ; then
log_debug 'git stash'
git stash >/dev/null
if ! /usr/share/ngcp-ngcpcfg/scripts/pull ; then
if ! "${SCRIPTS}"/pull ; then
exit 1
fi
log_debug 'git stash pop'
git stash pop >/dev/null
fi
log_debug 'git add . ; git commit -a -m "$msg [$(date --rfc-3339=ns)]"'
log_debug "git add . ; git commit -a -m \"\$msg [\$(date --rfc-3339=ns)]\""
git add .
git commit -a -m "$msg [$(date --rfc-3339=ns)]" >/dev/null
log_info "OK"
fi
log_debug "/usr/share/ngcp-ngcpcfg/scripts/etckeeper"
/usr/share/ngcp-ngcpcfg/scripts/etckeeper >/dev/null
log_debug "${SCRIPTS}/etckeeper"
"${SCRIPTS}"/etckeeper >/dev/null
if [ -z "${NO_DB_SYNC:-}" ] ; then
log_info "Synchronizing data from ${CONSTANTS_CONFIG}"

@ -20,7 +20,8 @@ console_output() {
return 0
fi
local timestamp="$(date "$TIME_FORMAT")"
local timestamp
timestamp="$(date "$TIME_FORMAT")"
# indent depending on number of characters in date output
timestamp_replacementchars="$(printf -- "%s: " "$timestamp" | sed 's/./ /g')"

@ -9,15 +9,16 @@ set -u
FUNCTIONS="${FUNCTIONS:-/usr/share/ngcp-ngcpcfg/functions/}"
HELPER="${HELPER:-/usr/share/ngcp-ngcpcfg/helper/}"
if ! [ -r ${FUNCTIONS}/main ] ; then
printf "Error: ${FUNCTIONS}/main could not be read. Exiting.\n" >&2
if ! [ -r "${FUNCTIONS}"/main ] ; then
printf "Error: %s/main could not be read. Exiting.\n" "${FUNCTIONS}" >&2
exit 1
fi
. ${FUNCTIONS}/main
. "${FUNCTIONS}"/main
get_config_file_list() {
for dir in ${CONFIG_POOL} ; do
# shellcheck disable=SC2044
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'
@ -43,7 +44,7 @@ fi
RC=0
TARGZ=/etc/ngcp-config-crypted.tgz
FILES=$(get_config_file_list)
# shellcheck disable=SC2086
tar zcf "$TARGZ" /etc/ngcp-config/ $FILES /etc/.git
if gpg --symmetric "$TARGZ" ; then
log_info "Successfully created crypted ngcpcfg configuration archive ${TARGZ}.gpg"
@ -54,8 +55,10 @@ fi
log_info_n "Now really erase all configuration files managed by ngcpcfg? [y/N] "
a='' ; read a
if [[ "$a" == "y" ]] || [ "$a" == "Y" ]] ; then
rm -rf "$NGCPCTL_MAIN" ; rm -f "$TARGZ" ; rm -f $FILES ; rm -rf /etc/.git
if [[ "$a" == "y" ]] || [[ "$a" == "Y" ]] ; then
rm -rf "$NGCPCTL_MAIN" ; rm -f "$TARGZ"
# shellcheck disable=SC2086
rm -f $FILES ; rm -rf /etc/.git
# make sure we don't leavy any stuff on shared storage
rm -rf /var/lib/glusterfs/export/ngcpcfg-share
rm -rf /mnt/glusterfs/ngcpcfg-share/

@ -6,12 +6,16 @@ set -e
set -u
set -o pipefail
if ! [ -r /usr/share/ngcp-ngcpcfg/functions/main ] ; then
printf "Error: /usr/share/ngcp-ngcpcfg/functions/main could not be read. Exiting.\n" >&2
# support testsuite
FUNCTIONS="${FUNCTIONS:-/usr/share/ngcp-ngcpcfg/functions/}"
if ! [ -r "${FUNCTIONS}"/main ] ; then
printf "Error: %s/main could not be read. Exiting.\n" "${FUNCTIONS}">&2
exit 1
fi
. /usr/share/ngcp-ngcpcfg/functions/main
timestamp_replacementchars=''
. "${FUNCTIONS}"/main
# main script
@ -35,7 +39,7 @@ log_debug 'git status | grep -q "working directory clean"'
if git status | grep -q 'working directory clean' ; then
log_info "OK: nothing to commit."
else
log_debug 'etckeeper commit "ngcpcfg apply on $(date)"'
log_debug "etckeeper commit \"ngcpcfg apply on \$(date)\""
etckeeper commit "ngcpcfg apply on $(date)" | sed "s/^/$timestamp_replacementchars/"
fi

@ -5,12 +5,15 @@
set -e
set -u
if ! [ -r /usr/share/ngcp-ngcpcfg/functions/main ] ; then
printf "Error: /usr/share/ngcp-ngcpcfg/functions/main could not be read. Exiting.\n" >&2
# support testsuite
FUNCTIONS="${FUNCTIONS:-/usr/share/ngcp-ngcpcfg/functions/}"
if ! [ -r "${FUNCTIONS}"/main ] ; then
printf "Error: %s/main could not be read. Exiting.\n" "${FUNCTIONS}">&2
exit 1
fi
. /usr/share/ngcp-ngcpcfg/functions/main
. "${FUNCTIONS}"/main
# main script
@ -63,7 +66,7 @@ if ! [ -r /etc/.gitignore ] ; then
else
log_debug 'grep -q ngcp-config /etc/.gitignore'
if ! grep -q ngcp-config /etc/.gitignore ; then
log_info_n "etckeeper seems to be present, adding "$NGCPCTL_MAIN" to ignore list: "
log_info_n "etckeeper seems to be present, adding \"$NGCPCTL_MAIN\" to ignore list: "
echo "ngcp-config" >> /etc/.gitignore
log_debug 'cd /etc ; git add .gitignore ; git commit -m "add ngcp-config directory to .gitignore"'
cd /etc

@ -6,12 +6,15 @@
set -e
set -u
if ! [ -r /usr/share/ngcp-ngcpcfg/functions/main ] ; then
printf "Error: /usr/share/ngcp-ngcpcfg/functions/main could not be read. Exiting.\n" >&2
# support testsuite
FUNCTIONS="${FUNCTIONS:-/usr/share/ngcp-ngcpcfg/functions/}"
if ! [ -r "${FUNCTIONS}"/main ] ; then
printf "Error: %s/main could not be read. Exiting.\n" "${FUNCTIONS}">&2
exit 1
fi
. /usr/share/ngcp-ngcpcfg/functions/main
. "${FUNCTIONS}"/main
# main script
@ -42,6 +45,7 @@ unifyer() {
}
for dir in ${CONFIG_POOL} ; do
#shellcheck disable=SC2106
(
if ! [[ "${dir}" =~ ^/ ]] ; then
log_error "${dir} is not an absolute path"
@ -56,9 +60,9 @@ for dir in ${CONFIG_POOL} ; 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"
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
)
@ -98,6 +102,7 @@ normalize_files() {
log_debug "NORMALIZED_FILES = $NORMALIZED_FILES"
while read line ; do
# shellcheck disable=SC2001
echo "$line" | sed -e 's_\./_/_g ; s_//_/_g' >> "${NORMALIZED_FILES}"
done < "$TMPFILE"
}

@ -9,12 +9,13 @@ set -o pipefail
# support testsuite
FUNCTIONS="${FUNCTIONS:-/usr/share/ngcp-ngcpcfg/functions/}"
if ! [ -r ${FUNCTIONS}/main ] ; then
printf "Error: ${FUNCTIONS}/main could not be read. Exiting.\n" >&2
if ! [ -r "${FUNCTIONS}"/main ] ; then
printf "Error: %s/main could not be read. Exiting.\n" "${FUNCTIONS}">&2
exit 1
fi
. ${FUNCTIONS}/main
timestamp_replacementchars=''
. "${FUNCTIONS}"/main
# main script
@ -29,6 +30,9 @@ usage() {
--local-only - do not check state on any remote host(s) (HA/PRO only)\n\n"
}
# shellcheck disable=SC2034
{
# used on ngcpcfg-ha/functions/ha_features.execute_check_remote()
CHECK_REMOTE=true
REMOTE_INVOKED=false
while [ -n "${1:-}" ] ; do
@ -39,6 +43,7 @@ while [ -n "${1:-}" ] ; do
*) break ;;
esac
done
}
check_local_state() {
log_debug "check_local_state"

@ -31,12 +31,12 @@ fi
FUNCTIONS="${FUNCTIONS:-/usr/share/ngcp-ngcpcfg/functions/}"
HELPER="${HELPER:-/usr/share/ngcp-ngcpcfg/helper/}"
if ! [ -r ${FUNCTIONS}/main ] ; then
printf "Error: ${FUNCTIONS}/main could not be read. Exiting.\n" >&2
if ! [ -r "${FUNCTIONS}"/main ] ; then
printf "Error: %s/main could not be read. Exiting.\n" "${FUNCTIONS}">&2
exit 1
fi
. ${FUNCTIONS}/main
. "${FUNCTIONS}"/main
TT_WRAPPER="${HELPER}/tt2-wrapper"
@ -45,7 +45,7 @@ killall tt2-daemon 2>/dev/null || true
rm -f /var/run/ngcpcfg.port
# Start new tt2-daemon Perl process
${HELPER}/tt2-daemon --quiet
"${HELPER}"/tt2-daemon --quiet
# Load all the configs in proper order and check their avialability and valid YAML syntax
for f in ${NGCPCTL_CONFIG:-} ${HOST_CONFIG:-} ${LOCAL_CONFIG:-} ${NETWORK_CONFIG:-} ${EXTRA_CONFIG_FILES:-} ${CONSTANTS_CONFIG:-} ; do

Loading…
Cancel
Save