111 |
{ |
{ |
112 |
# set connection timeout to 20 secs |
# set connection timeout to 20 secs |
113 |
mysql --connect_timeout=20 \ |
mysql --connect_timeout=20 \ |
114 |
--user="${SQL_USER}" \ |
--user="${MCORE_SQL_USER}" \ |
115 |
--password="${SQL_PASS}" \ |
--password="${MCORE_SQL_PASS}" \ |
116 |
--host="${SQL_HOST}" \ |
--host="${MCORE_SQL_HOST}" \ |
117 |
--database="${SQL_DB}" \ |
--database="${MCORE_SQL_DB}" \ |
118 |
--batch \ |
--batch \ |
119 |
--execute="" &> /dev/null && return 0 || \ |
--execute="" &> /dev/null && return 0 || \ |
120 |
( |
( |
121 |
echo -e ${COLRED} |
echo -e ${COLRED} |
122 |
echo "Cannot reach a mysql-server at '${SQL_HOST}'." |
echo "Cannot reach a mysql-server at '${MCORE_SQL_HOST}'." |
123 |
echo "None of the current settings of this client will be touched." |
echo "None of the current settings of this client will be touched." |
124 |
echo "Please inform your system-administrator." |
echo "Please inform your system-administrator." |
125 |
echo -e ${COLDEFAULT} |
echo -e ${COLDEFAULT} |
132 |
mysqldo() |
mysqldo() |
133 |
{ |
{ |
134 |
mysql_command \ |
mysql_command \ |
135 |
"${SQL_USER}" \ |
"${MCORE_SQL_USER}" \ |
136 |
"${SQL_PASS}" \ |
"${MCORE_SQL_PASS}" \ |
137 |
"${SQL_HOST}" \ |
"${MCORE_SQL_HOST}" \ |
138 |
"${SQL_DB}" \ |
"${MCORE_SQL_DB}" \ |
139 |
"$@" \ |
"$@" \ |
140 |
&& return 0 || return 1 |
&& return 0 || return 1 |
141 |
} |
} |
161 |
fi |
fi |
162 |
|
|
163 |
# setup arrays |
# setup arrays |
164 |
all_vars=( $(mysql_enum_colums ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} ${table} show) ) |
all_vars=( $(mysql_enum_colums ${MCORE_SQL_USER} ${MCORE_SQL_PASS} ${MCORE_SQL_HOST} ${MCORE_SQL_DB} ${table} show) ) |
165 |
all_items=( $(mysqldo "select * from ${table} ${where_statement}") ) |
all_items=( $(mysqldo "select * from ${table} ${where_statement}") ) |
166 |
|
|
167 |
# sanity check |
# sanity check |
194 |
fi |
fi |
195 |
|
|
196 |
export eval $(mysql \ |
export eval $(mysql \ |
197 |
--user="${SQL_USER}" \ |
--user="${MCORE_SQL_USER}" \ |
198 |
--password="${SQL_PASS}" \ |
--password="${MCORE_SQL_PASS}" \ |
199 |
--host="${SQL_HOST}" \ |
--host="${MCORE_SQL_HOST}" \ |
200 |
--database="${SQL_DB}" \ |
--database="${MCORE_SQL_DB}" \ |
201 |
--xml \ |
--xml \ |
202 |
--execute="select * from ${table} ${where_statement}" \ |
--execute="select * from ${table} ${where_statement}" \ |
203 |
| xml sel -T -t -m //row/field \ |
| xml sel -T -t -m //row/field \ |