#!/bin/bash
mkdir -p /opt/euro-beta/log
echo show tables\; | mysql -s -u euro3g -peuro3g eurotest > /tmp/tablelist
echo +-----------------------------------------------------------------+ >> /opt/euro-beta/log/dbcheck.log
echo `date` Database check ....... >> /opt/euro-beta/log/dbcheck.log
echo +-----------------------------------------------------------------+ >> /opt/euro-beta/log/dbcheck.log
for table in `cat /tmp/tablelist` ; do echo check table $table\; ; done | mysql -s -u euro3g -peuro3g eurotest > /tmp/first_dbcheck
cat /tmp/first_dbcheck >> /opt/euro-beta/log/dbcheck.log

if [ `cat /tmp/tablelist | wc -l` != `cat /tmp/first_dbcheck | grep -e "^eurotest.*status.*OK.*$" | wc -l` ] ; then

  exit 1

fi
exit 0
