]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3599] Fixed issues with the kea-admin script portability.
authorMarcin Siodelski <marcin@isc.org>
Mon, 8 Dec 2014 14:13:03 +0000 (15:13 +0100)
committerMarcin Siodelski <marcin@isc.org>
Mon, 8 Dec 2014 14:13:03 +0000 (15:13 +0100)
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.

src/bin/admin/.gitignore [new file with mode: 0644]
src/bin/admin/admin-utils.sh
src/bin/admin/kea-admin.in
src/bin/admin/scripts/mysql/.gitignore [new file with mode: 0644]
src/bin/admin/tests/.gitignore [new file with mode: 0644]
src/bin/admin/tests/mysql_tests.sh.in

diff --git a/src/bin/admin/.gitignore b/src/bin/admin/.gitignore
new file mode 100644 (file)
index 0000000..d938490
--- /dev/null
@@ -0,0 +1,2 @@
+/kea-admin
+/kea-admin.8
index f1b621da1110c792f574223dd9693ef3ad770bae..9f23c3dee0d0890ea7bf8de519471075f37fb2eb 100644 (file)
@@ -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
+}
index 79025b4e1847a5597aaad3e935f33f40b1dd8f47..b4590806c04c5cf83054429d1076a991a7bdbb3f 100644 (file)
@@ -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 (file)
index 0000000..e814b1a
--- /dev/null
@@ -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 (file)
index 0000000..c6971c7
--- /dev/null
@@ -0,0 +1,2 @@
+/memfile_tests.sh
+/mysql_tests.sh
index b8d2ca07515f8d094df769e1ab5e634ea97d20c5..c5bdead119d3ea3ebbe7ed5d463e6b468c6e0775 100644 (file)
@@ -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 <<EOF
+    mysql -u$db_user -p$db_pass $db_name >/dev/null 2>&1 <<EOF
 SET @tables = NULL;
 SELECT GROUP_CONCAT(table_schema, '.', table_name) INTO @tables
   FROM information_schema.tables
@@ -64,35 +64,35 @@ mysql_lease_init_test() {
 
     # Ok, now let's check if the tables are indeed there.
     # First table: schema_version. Should have 2 columns: version and minor.
-    mysql -u$db_user -p$db_pass $db_name &>/dev/null <<EOF
+    mysql -u$db_user -p$db_pass $db_name >/dev/null 2>&1 <<EOF
     SELECT version, minor FROM schema_version;
 EOF
     ERRCODE=$?
     assert_eq 0 $ERRCODE "schema_version table is missing or broken. (returned status code %d, expected %d)"
 
     # Second table: lease4
-    mysql -u$db_user -p$db_pass $db_name &>/dev/null <<EOF
+    mysql -u$db_user -p$db_pass $db_name >/dev/null 2>&1 <<EOF
     SELECT address, hwaddr, client_id, valid_lifetime, expire, subnet_id, fqdn_fwd, fqdn_rev, hostname FROM lease4;
 EOF
     ERRCODE=$?
     assert_eq 0 $ERRCODE "lease4 table is missing or broken. (returned status code %d, expected %d)"
 
     # Third table: lease6
-    mysql -u$db_user -p$db_pass $db_name &>/dev/null <<EOF
+    mysql -u$db_user -p$db_pass $db_name >/dev/null 2>&1 <<EOF
     SELECT address, duid, valid_lifetime, expire, subnet_id, pref_lifetime, lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, hwaddr, hwtype, hwaddr_source FROM lease6;
 EOF
     ERRCODE=$?
     assert_eq 0 $ERRCODE "lease6 table is missing or broken. (returned status code %d, expected %d)"
 
     # Fourth table: lease6_types
-    mysql -u$db_user -p$db_pass $db_name &>/dev/null <<EOF
+    mysql -u$db_user -p$db_pass $db_name >/dev/null 2>&1 <<EOF
     SELECT lease_type, name FROM lease6_types;
 EOF
     ERRCODE=$?
     assert_eq 0 $ERRCODE "lease6_types table is missing or broken. (returned status code %d, expected %d)"
 
     # Fifth table: lease_hwaddr_source
-    mysql -u$db_user -p$db_pass $db_name &>/dev/null <<EOF
+    mysql -u$db_user -p$db_pass $db_name >/dev/null 2>&1 <<EOF
     SELECT hwaddr_source, name FROM lease_hwaddr_source;
 EOF
     ERRCODE=$?
@@ -111,7 +111,7 @@ mysql_lease_version_test() {
     mysql_wipe
 
     # Ok, now let's create a version 1.7
-    mysql -u$db_user -p$db_pass $db_name &>/dev/null <<EOF
+    mysql -u$db_user -p$db_pass $db_name >/dev/null 2>&1 <<EOF
 CREATE TABLE schema_version (
     version INT PRIMARY KEY NOT NULL,
     minor INT
@@ -152,14 +152,14 @@ mysql_lease_upgrade_test() {
     # Let's check that the new tables are indeed there.
 
     # Third table: lease6
-    mysql -u$db_user -p$db_pass $db_name &>/dev/null <<EOF
+    mysql -u$db_user -p$db_pass $db_name >/dev/null 2>&1 <<EOF
     SELECT hwaddr, hwtype, hwaddr_source FROM lease6;
 EOF
     ERRCODE=$?
     assert_eq 0 $ERRCODE "lease6 table not upgraded to 2.0 (returned status code %d, expected %d)"
 
     # Fifth table: lease_hwaddr_source
-    mysql -u$db_user -p$db_pass $db_name &>/dev/null <<EOF
+    mysql -u$db_user -p$db_pass $db_name >/dev/null 2>&1 <<EOF
     SELECT hwaddr_source, name FROM lease_hwaddr_source;
 EOF
     ERRCODE=$?