#!/bin/bash
OLDDIR=`pwd`
echo show tables\; | mysql -s -u euro3g -peuro3g eurotest > /tmp/tablelist
echo +-----------------------------------------------------------------+ >> /tmp/dbcheck.log
echo `date` Database repair ....... >> /tmp/dbcheck.log
echo +-----------------------------------------------------------------+ >> /tmp/dbcheck.log

cd /var/lib/mysql/eurotest
for table in *.MYI ; do myisamchk -o `basename $table ".MYI"` > /dev/null 2>&1 ; done
echo Check after myisamchk -o ....... >> /tmp/dbcheck.log
for table in `cat /tmp/tablelist` ; do echo check table $table\; ; done | mysql -s -u euro3g -peuro3g eurotest >> /tmp/dbcheck.log
echo Starting single table repair loop ....... >> /tmp/dbcheck.log
for table in `cat /tmp/tablelist` ; do echo repair table $table\; ; done | mysql -s -u euro3g -peuro3g eurotest >> /tmp/dbcheck.log
echo Final check ....... >> /tmp/dbcheck.log
for table in `cat /tmp/tablelist` ; do echo check table $table\; ; done | mysql -s -u euro3g -peuro3g eurotest >> /tmp/dbcheck.log

cd $OLDDIR
