diff options
Diffstat (limited to 'src/bin/admin')
-rw-r--r-- | src/bin/admin/Makefile.am | 2 | ||||
-rwxr-xr-x | src/bin/admin/admin-utils.sh | 46 | ||||
-rw-r--r-- | src/bin/admin/kea-admin.xml | 2 |
3 files changed, 32 insertions, 18 deletions
diff --git a/src/bin/admin/Makefile.am b/src/bin/admin/Makefile.am index a71ee1c737..775e4cee2f 100644 --- a/src/bin/admin/Makefile.am +++ b/src/bin/admin/Makefile.am @@ -10,7 +10,7 @@ EXTRA_DIST = $(man_MANS) kea-admin.xml admin-utils.sh if GENERATE_DOCS kea-admin.8: kea-admin.xml - @XSLTPROC@ --novalid --xinclude --nonet -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $(srcdir)/kea-admin.xml + @XSLTPROC@ --novalid --xinclude -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $(srcdir)/kea-admin.xml else diff --git a/src/bin/admin/admin-utils.sh b/src/bin/admin/admin-utils.sh index eb5fbbe63b..33616d9a90 100755 --- a/src/bin/admin/admin-utils.sh +++ b/src/bin/admin/admin-utils.sh @@ -19,11 +19,25 @@ mysql_execute() { QUERY=$1 shift if [ $# -gt 1 ]; then - mysql -N -B $* -e "${QUERY}" + mysql -N -B "$@" -e "${QUERY}" retcode=$? else - mysql -N -B --host=$db_host --user=$db_user --password=$db_password -e "${QUERY}" $db_name - retcode="$?" + mysql -N -B --database="${db_name}" --user="${db_user}" --password="${db_password}" -e "${QUERY}" + retcode=$? + fi + + return $retcode +} + +mysql_execute_script() { + file=$1 + shift + if [ $# -ge 1 ]; then + mysql -N -B "$@" < "${file}" + retcode=$? + else + mysql -N -B --database="${db_name}" --user="${db_user}" --password="${db_password}" < "${file}" + retcode=$? fi return $retcode @@ -48,11 +62,11 @@ pgsql_execute() { QUERY=$1 shift if [ $# -gt 0 ]; then - echo $QUERY | psql --set ON_ERROR_STOP=1 -A -t -h localhost -q $* + echo "${QUERY}" | psql --set ON_ERROR_STOP=1 -A -t -h localhost -q "$@" retcode=$? else export PGPASSWORD=$db_password - echo $QUERY | psql --set ON_ERROR_STOP=1 -A -t -h $db_host -q -U $db_user -d $db_name + echo "${QUERY}" | psql --set ON_ERROR_STOP=1 -A -t -h localhost -q -U "${db_user}" -d "${db_name}" retcode=$? fi return $retcode @@ -72,11 +86,11 @@ pgsql_execute_script() { file=$1 shift if [ $# -gt 0 ]; then - psql --set ON_ERROR_STOP=1 -A -t -h localhost -q -f $file $* + psql --set ON_ERROR_STOP=1 -A -t -h localhost -q -f "${file}" "$@" retcode=$? else export PGPASSWORD=$db_password - psql --set ON_ERROR_STOP=1 -A -t -h $db_host -q -U $db_user -d $db_name -f $file + psql --set ON_ERROR_STOP=1 -A -t -h localhost -q -U "${db_user}" -d "${db_name}" -f "${file}" retcode=$? fi return $retcode @@ -91,15 +105,15 @@ cql_execute() { query=$1 shift if [ $# -gt 1 ]; then - cqlsh $* -e "$query" + cqlsh "$@" -e "$query" retcode=$? else - cqlsh -u $db_user -p $db_password -k $db_name -e "$query" + cqlsh -u "${db_user}" -p "${db_password}" -k "${db_name}" -e "${query}" retcode=$? fi if [ $retcode -ne 0 ]; then - printf "cqlsh returned with exit status $retcode\n" + printf "cqlsh returned with exit status %s\n" "${retcode}" exit $retcode fi @@ -110,15 +124,15 @@ cql_execute_script() { file=$1 shift if [ $# -gt 1 ]; then - cqlsh $* -e "$file" + cqlsh "$@" -e "$file" retcode=$? else - cqlsh -u $db_user -p $db_password -k $db_name -f "$file" + cqlsh -u "${db_user}" -p "${db_password}" -k "${db_name}" -f "${file}" retcode=$? fi if [ $retcode -ne 0 ]; then - printf "cqlsh returned with exit status $retcode\n" + printf "cqlsh returned with exit status %s\n" "${retcode}" exit $retcode fi @@ -126,8 +140,8 @@ cql_execute_script() { } cql_version() { - version=`cql_execute "SELECT version, minor FROM schema_version" "$@"` - version=`echo "$version" | grep -A 1 "+" | grep -v "+" | tr -d ' ' | cut -d "|" -f 1-2 --output-delimiter="."` - echo $version + version=$(cql_execute "SELECT version, minor FROM schema_version" "$@") + version=$(echo "$version" | grep -A 1 "+" | grep -v "+" | tr -d ' ' | cut -d "|" -f 1-2 --output-delimiter=".") + echo "${version}" return $? } diff --git a/src/bin/admin/kea-admin.xml b/src/bin/admin/kea-admin.xml index 90957bc8d7..0cafdea94d 100644 --- a/src/bin/admin/kea-admin.xml +++ b/src/bin/admin/kea-admin.xml @@ -103,7 +103,6 @@ migrating between old and new Kea versions.</para> </listitem> </varlistentry> - </variablelist> <varlistentry> <term>lease-dump</term> @@ -114,6 +113,7 @@ The first line of file is a header line containing the column names.</para> </listitem> </varlistentry> + </variablelist> </listitem> </varlistentry> |