--- alx-src/trunk/alxconfig-ng/functions/mysqlfunctions 2005/04/12 20:46:52 239 +++ alx-src/branches/alxconf_20060908/alxconfig-ng/functions/mysqlfunctions 2009/02/04 19:51:39 543 @@ -6,9 +6,10 @@ # # Niels Rogalla # -# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/mysqlfunctions,v 1.3 2005-04-12 20:45:55 niro Exp $ +# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/mysqlfunctions,v 1.8 2005-10-09 21:32:33 niro Exp $ -mysql_command(){ +mysql_command() +{ local SQL_USER local SQL_PASS @@ -49,7 +50,8 @@ return 0 } -mysql_enum_colums(){ +mysql_enum_colums() +{ local SQL_USER local SQL_PASS local SQL_HOST @@ -104,3 +106,45 @@ EOF [ "${SHOWTABLES}" == true ] || echo "${i}" } + +beep3x() +{ + echo -en "\a" + sleep 0.7 + echo -en "\a" + sleep 0.7 + echo -en "\a" +} + +reach_mysql_server() +{ + # set connection timeout to 20 secs + mysql --connect_timeout=20 \ + --user="${SQL_USER}" \ + --password="${SQL_PASS}" \ + --host="${SQL_HOST}" \ + --database="${SQL_DB}" \ + --batch \ + --execute="" &> /dev/null && return 0 || \ + ( + echo -e ${COLRED} + echo "Cannot reach a mysql-server at '${SQL_HOST}'." + echo "None of the current settings of this client will be touched." + echo "Please inform your system-administrator." + echo -e ${COLDEFAULT} + beep3x + sleep 5 + return 1 + ) +} + +mysqldo() +{ + mysql_command \ + "${SQL_USER}" \ + "${SQL_PASS}" \ + "${SQL_HOST}" \ + "${SQL_DB}" \ + "$@" \ + && return 0 || return 1 +}