From: Marcin Siodelski Date: Mon, 8 Dec 2014 14:13:03 +0000 (+0100) Subject: [3599] Fixed issues with the kea-admin script portability. X-Git-Tag: kea-eng-20141219~9^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8502a73ca71558642ee375215d0d2e447df23ef8;p=thirdparty%2Fkea.git [3599] Fixed issues with the kea-admin script portability. The following issues causing failures on the FreeBSD were corrected: - Don't use sed to replace tabulations from the returned kea version. Instead the CONCAT mysql function is used. - Replace &>dev/null with the >/dev/null 2>&1 Additional changes: - Added a new line before printing existing tables in the mysql. - Added .gitignore for new files. --- diff --git a/src/bin/admin/.gitignore b/src/bin/admin/.gitignore new file mode 100644 index 0000000000..d938490cde --- /dev/null +++ b/src/bin/admin/.gitignore @@ -0,0 +1,2 @@ +/kea-admin +/kea-admin.8 diff --git a/src/bin/admin/admin-utils.sh b/src/bin/admin/admin-utils.sh index f1b621da11..9f23c3dee0 100644 --- a/src/bin/admin/admin-utils.sh +++ b/src/bin/admin/admin-utils.sh @@ -28,17 +28,17 @@ mysql_execute() { if [ $# -gt 1 ]; then QUERY=$1 shift - _RESULT=`echo $QUERY | mysql -N -B $@ | sed "s/\t/./g"` + _RESULT=`echo $QUERY | mysql -N -B $@` else - _RESULT=$(mysql -N -B --user=$db_user --password=$db_password -e "${1}" $db_name | sed "s/\t/./g") + _RESULT=$(mysql -N -B --user=$db_user --password=$db_password -e "${1}" $db_name) fi } mysql_version() { - mysql_execute "SELECT version,minor FROM schema_version" "$@" + mysql_execute "SELECT CONCAT(version,\".\",minor) FROM schema_version" "$@" } mysql_version_print() { mysql_version "$@" printf "%s" $_RESULT -} \ No newline at end of file +} diff --git a/src/bin/admin/kea-admin.in b/src/bin/admin/kea-admin.in index 79025b4e18..b4590806c0 100644 --- a/src/bin/admin/kea-admin.in +++ b/src/bin/admin/kea-admin.in @@ -138,7 +138,7 @@ mysql_init() { if [ $COUNT -gt 0 ]; then # Let't start with a new line. mysql could have printed something out. printf "\n" - log_error "Expected empty database $db_name, but there are $COUNT tables: $_RESULT. Aborting." + log_error "Expected empty database $db_name, but there are $COUNT tables: \n$_RESULT. Aborting." exit 1 fi diff --git a/src/bin/admin/scripts/mysql/.gitignore b/src/bin/admin/scripts/mysql/.gitignore new file mode 100644 index 0000000000..e814b1ae3f --- /dev/null +++ b/src/bin/admin/scripts/mysql/.gitignore @@ -0,0 +1 @@ +/upgrade_1.0_to_2.0.sh diff --git a/src/bin/admin/tests/.gitignore b/src/bin/admin/tests/.gitignore new file mode 100644 index 0000000000..c6971c7b04 --- /dev/null +++ b/src/bin/admin/tests/.gitignore @@ -0,0 +1,2 @@ +/memfile_tests.sh +/mysql_tests.sh diff --git a/src/bin/admin/tests/mysql_tests.sh.in b/src/bin/admin/tests/mysql_tests.sh.in index b8d2ca0751..c5bdead119 100644 --- a/src/bin/admin/tests/mysql_tests.sh.in +++ b/src/bin/admin/tests/mysql_tests.sh.in @@ -37,7 +37,7 @@ keaadmin=@abs_top_builddir@/src/bin/admin/kea-admin # Wipe all tables from the DB: mysql_wipe() { printf "Wiping whole database %s\n" $db_name - mysql -u$db_user -p$db_pass $db_name &>/dev/null </dev/null 2>&1 </dev/null </dev/null 2>&1 </dev/null </dev/null 2>&1 </dev/null </dev/null 2>&1 </dev/null </dev/null 2>&1 </dev/null </dev/null 2>&1 </dev/null </dev/null 2>&1 </dev/null </dev/null 2>&1 </dev/null </dev/null 2>&1 <