From 150d2a5e2ea0e118f2435c6d7e6ea2b6456bd212 Mon Sep 17 00:00:00 2001 From: Alexander Lutay Date: Tue, 9 May 2017 15:25:46 +0200 Subject: [PATCH] TT#15824 Update code based on comments from previous code review Change-Id: Ic5adbb93eb7fc908c013f257321e82a67d61fbf1 --- helper/build_config | 5 +++++ helper/check-for-mysql | 13 +++++++++---- helper/restore-permissions | 4 ++++ scripts/build | 12 ++++++------ scripts/diff | 12 +++++++++--- 5 files changed, 33 insertions(+), 13 deletions(-) diff --git a/helper/build_config b/helper/build_config index 7d6a1bb6..c80518cb 100755 --- a/helper/build_config +++ b/helper/build_config @@ -17,6 +17,11 @@ CONFIG_POOL="${CONFIG_POOL:-/etc}" FUNCTIONS="${FUNCTIONS:-/usr/share/ngcp-ngcpcfg/functions/}" HELPER="${HELPER:-/usr/share/ngcp-ngcpcfg/helper/}" +if ! [ -r "${FUNCTIONS}"/main ] ; then + printf "Error: %s/main could not be read. Exiting.\n" "${FUNCTIONS}" >&2 + exit 1 +fi + . "${FUNCTIONS}"/main # main script diff --git a/helper/check-for-mysql b/helper/check-for-mysql index dc8a3f11..0cd38382 100755 --- a/helper/check-for-mysql +++ b/helper/check-for-mysql @@ -17,13 +17,18 @@ if [ $COUNT -le 0 ] ; then exit 1 fi -if ! [ -x /usr/sbin/mysqld ] || ! [ -x /usr/bin/mysqladmin ] ; then - echo "Error: mysqld or mysqladmin not present. Exiting." >&2 +if ! which mysqld >/dev/null 2>&1 ; then + echo "Error: mysqld is not present. Exiting." >&2 + exit 1 +fi + +if ! which mysqladmin >/dev/null 2>&1 ; then + echo "Error: mysqladmin is not present. Exiting." >&2 exit 1 fi mysqld_get_param() { - /usr/sbin/mysqld --defaults-group-suffix=$SUFF --print-defaults 2>/dev/null \ + mysqld --defaults-group-suffix=$SUFF --print-defaults 2>/dev/null \ | tr " " "\n" \ | grep -- "--$1" \ | tail -n 1 \ @@ -31,7 +36,7 @@ mysqld_get_param() { } mysqld_status () { - if /usr/bin/mysqladmin --defaults-group-suffix=$SUFF \ + if mysqladmin --defaults-group-suffix=$SUFF \ --defaults-file=/etc/mysql/debian.cnf ping 2>&1 ; then ping_alive=1 else diff --git a/helper/restore-permissions b/helper/restore-permissions index 38a9bf8e..02b2d718 100755 --- a/helper/restore-permissions +++ b/helper/restore-permissions @@ -22,6 +22,10 @@ if "${SKIP_NGCP_FUNCTIONS}" ; then log_errror () { echo "$@" >&2 ; } log_warn () { echo "$@" ; } else + if ! [ -r "${FUNCTIONS}"/main ] ; then + printf "Error: %s/main could not be read. Exiting.\n" "${FUNCTIONS}" >&2 + exit 1 + fi . "${FUNCTIONS}/main" fi diff --git a/scripts/build b/scripts/build index c04d4431..96bb0460 100755 --- a/scripts/build +++ b/scripts/build @@ -81,12 +81,12 @@ else done fi - if git diff-index --name-only HEAD | grep \ - -qe "$(basename "$NGCPCTL_CONFIG")" \ - -qe "$(basename "$HOST_CONFIG")" \ - -qe "$(basename "$LOCAL_CONFIG")" \ - -qe "$(basename "$NETWORK_CONFIG")" \ - -qe "$(basename "$CONSTANTS_CONFIG")" ; then + if git diff-index --name-only HEAD | grep -q \ + -e "$(basename "$NGCPCTL_CONFIG")" \ + -e "$(basename "$HOST_CONFIG")" \ + -e "$(basename "$LOCAL_CONFIG")" \ + -e "$(basename "$NETWORK_CONFIG")" \ + -e "$(basename "$CONSTANTS_CONFIG")" ; then log_debug "modification in main configuration file found" trigger_rebuild=true fi diff --git a/scripts/diff b/scripts/diff index 32466d66..614b9598 100755 --- a/scripts/diff +++ b/scripts/diff @@ -6,12 +6,18 @@ 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 # main script log_debug "cd $NGCPCTL_MAIN"