function _log() {
    echo "[Log] $@"
}

root_path=`pwd`
file_name=$1

version_sql_path=$root_path/global/sql
if [ ! -d $version_sql_path ];
then
    mkdir -p $version_sql_path
fi

db_gamedata=`grep dbconf.mysql_gamedb $file_name -A 9 | grep database | awk -F\" '{print $2}'`
db_gameconf=`grep dbconf.mysql_confdb $file_name -A 9 | grep database | awk -F\" '{print $2}'`
user=`grep dbconf.mysql_gamedb $file_name -A 9 | grep user | awk -F\" '{print $2}'`
host=`grep dbconf.mysql_gamedb $file_name -A 9 | grep host | awk -F\" '{print $2}'`
port=`grep dbconf.mysql_gamedb $file_name -A 9 | grep port | awk -F\= '{print $2}' | awk -F, '{print $1}'`
password=`grep dbconf.mysql_gamedb $file_name -A 9 | grep password | awk -F\" '{print $2}'`
_log $db_gamedata $user $host $port $password

MYSQL="mysql -u$user -p$password -h$host -P$port"

cd ${version_sql_path}
files=$(ls)
for file in ${files[@]} 
do
    _log "执行 sql文件:" $file
    ${MYSQL} --force $db_gamedata < $file 2>/dev/null
done
