@echo off

echo update mysql begin...

if not exist ..\Runtime\jre6.0.18\bin\ (
	echo collector no need to update mysql.
	GOTO :EOF
)

setlocal enabledelayedexpansion
set username="";
set password="";

for /f %%1 in ('.\..\Runtime\jre6.0.18\bin\java -jar DecryptUtil-1.0.jar') do (
	set str=%%1
	echo !str!|findstr "username=" >nul
	if !errorlevel! equ 0 (
	set username=!str:~9!)
	echo !str!|findstr "password=" >nul
	if !errorlevel! equ 0 (
	set password=!str:~9!)
)

if exist ..\Runtime\Tomcat6\Lego-UI-Plat\WEB-INF\lib\ (

	..\MySQL\bin\mysql.exe -u%username% -p%password%  -s -e "use lego; update t_vsm_zone_httpsflood set https_decrypt_enable=null, https_decrypt_alert_rate=null, server_code_enable=null, server_code_period=null, server_code_times=null, finger_learn_enable=null, learn_period=null, match_times=null; delete from t_atic_library_file where lib_type='Lib_IPS';" >>.\log\intall_mysql.log 2>&1
	if %errorlevel% NEQ 0 (GOTO :EOF)
	..\MySQL\bin\mysql.exe -u%username% -p%password% < .\sql\6.7.090_create_others.sql >>.\log\intall_mysql.log 2>&1
	if %errorlevel% NEQ 0 (GOTO :EOF)
	..\MySQL\bin\mysql.exe -u%username% -p%password% < .\sql\6.7.091_create_others.sql >>.\log\intall_mysql.log 2>&1
	if %errorlevel% NEQ 0 (GOTO :EOF)
	..\MySQL\bin\mysql.exe -u%username% -p%password% < .\sql\6.7.100_create_others.sql >>.\log\intall_mysql.log 2>&1
	if %errorlevel% NEQ 0 (GOTO :EOF)
	..\MySQL\bin\mysql.exe -u%username% -p%password% < .\sql\6.7.101_create_others.sql >>.\log\intall_mysql.log 2>&1
	if %errorlevel% NEQ 0 (GOTO :EOF)
	..\MySQL\bin\mysql.exe -u%username% -p%password% < .\sql\6.7.103_create_others.sql >>.\log\intall_mysql.log 2>&1
	if %errorlevel% NEQ 0 (GOTO :EOF)
	..\MySQL\bin\mysql.exe -u%username% -p%password% < .\sql\6.7.106_create_others.sql >>.\log\intall_mysql.log 2>&1
	if %errorlevel% NEQ 0 (GOTO :EOF)
)

echo update mysql finished...

@echo off