#!/bin/bash

# this file checks for proper permission in the mysql database appliances

# check if database is required and installed

started=0
for (( i=0; i<10; i=i+1 ))
do
   sleep 1
   #if [ ! -S /var/lib/mysql/mysql.sock ]; then
   if [ ! -f /var/run/mysqld/mysqld.pid ]; then
      continue
   fi
   i=10
   started=1
done

if [ $started -eq 0 ]; then
   exit 0
fi

F=`mysql -D mysql -e "show grants for 'root'@'%'"`
RET=$?

if [ $RET -eq 1 ] || [ "${F:18}" != "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION" ] ; then
exit 1
fi

exit 0



