@ECHO OFF
title AIS KIT-XXI GRK Update #1.00.89
IF NOT EXIST "C:\Program Files" goto exit64
tasklist | find /i "postgres" || SET servneedstart=yes
tasklist | find /i "postgres" || "C:\Program Files\AIC KIT-XXI\PostgreSQL\bin\pg_ctl.exe" -D "C:\Program Files\AIC KIT-XXI\PostgreSQL\data" -l "%TEMP%\pgserver.log" start > nul
cls
echo wait ...
ping 1.2.3.4 -n 10 -w 1000 >nul
cls
tasklist | find /i "postgres" || goto exiterror
@ECHO OFF
SET PGUSER=chupa
SET PGPASSWORD=postgre
SET PGHOST=127.0.0.1
SET FileNameData=fulldump_%date:~-4%_%date:~3,2%_%date:~0,2%_%time:~0,2%_%time:~3,2%_%time:~6,2%.dump
@ECHO ON
MD Backup
MD log
rem IF NOT EXIST Backup (goto rolerror)
rem "C:\Program Files\AIC KIT-XXI\PostgreSQL\bin\pg_dump.exe" -Fc -Z 9 -b budg_grk > ".\Backup\fulldump.dump"
rem copy ".\Backup\fulldump.dump"  ".\Backup\"%FileNameData%
rem copy ".\Backup\fulldump.dump"  "C:\Program Files\AIC KIT-XXI\DumpFiles\"%FileNameData%
"C:\Program Files\AIC KIT-XXI\PostgreSQL\bin\psql.exe" -d budg_grk -a -f p_kill_sessions.sq -L ".\log\s_log_p.log" >> .\log\s_log_f.log 2>&1
"C:\Program Files\AIC KIT-XXI\PostgreSQL\bin\psql.exe" -d budg_grk -a -f z_sql1.zu -L ".\log\z_log_p.log" >> .\log\z_log_f.log 2>&1
"C:\Program Files\AIC KIT-XXI\PostgreSQL\bin\psql.exe" -d budg_grk -a -f z_sql2.zu -L ".\log\z_log_p.log" >> .\log\z_log_f.log 2>&1
"C:\Program Files\AIC KIT-XXI\PostgreSQL\bin\pg_restore.exe" --disable-triggers -a -d budg_grk zcrystalrep_dump.dump>> .\log\z_log_f.log 2>&1
"C:\Program Files\AIC KIT-XXI\PostgreSQL\bin\psql.exe" -d budg_grk -a -f z_sql3.zu -L ".\log\z_log_p.log" >> .\log\z_log_f.log 2>&1
"C:\Program Files\AIC KIT-XXI\PostgreSQL\bin\psql.exe" -d budg_grk -a -f z_sql4.zu -L ".\log\z_log_p.log" >> .\log\z_log_f.log 2>&1
"C:\Program Files\AIC KIT-XXI\PostgreSQL\bin\psql.exe" -d budg_grk -a -f trans_pas_to_pas_exec_3.us -L ".\log\z_log_p.log" >> .\log\z_log_f.log 2>&1
"C:\Program Files\AIC KIT-XXI\PostgreSQL\bin\psql.exe" -d budg_grk -a -f trans_pas_to_pas_exec_5.us -L ".\log\z_log_p.log" >> .\log\z_log_f.log 2>&1
"C:\Program Files\AIC KIT-XXI\PostgreSQL\bin\psql.exe" -d budg_grk -a -f version.us -L ".\log\z_log_p.log" >> .\log\z_log_f.log 2>&1
goto exitok
:exit64
@ECHO OFF
cls
color 84
echo Zapystite start_update.cmd !!!
echo -----------------------------------------------------------------------
pause
exit
:exiterror
@ECHO OFF
cls
color 84
echo ‡ Їгбвiвм KIT-XXI CLIENT в  ўЁ©¤iвм § ­м®Ј®. Џiб«п з®Ј® § Їгбвiвм ¤ ­Ґ ®­®ў«Ґ­­п.
echo =
echo Zapystite KIT-XXI CLIENT i viidite s nego. Posle chego zapystite eto obnovlenie.
echo -----------------------------------------------------------------------
pause
exit
:rolerror
@ECHO OFF
cls
color 84
echo „«п Є®аҐЄв­®Ј® ®­®ў«Ґ­­п Їа®Ја ¬Ё "KIT-XXI ѓђЉ" § Їгбв?вм Їа®Ја ¬г "upd_1.00.89.exe" § Їа ў ¬Ё Ђ¤¬?­?бва в®а .
echo =
echo Dlya korektnoho onovlennya prohramu "KIT-XXI GRK" zapustit? prohramu "upd_v1.00.89.exe" z pravamy Administratora.
echo -----------------------------------------------------------------------
pause
exit
:exitok
@ECHO OFF
cls
echo Ћ­®ў«Ґ­­п 1.00.89 § ўҐаиҐ­®.
echo =
echo Onovlennya 1.00.89 zaversheno.
echo -----------------------------------------------------------------------
pause
IF %servneedstart%==yes "C:\Program Files\AIC KIT-XXI\PostgreSQL\bin\pg_ctl.exe" -D "C:\Program Files\AIC KIT-XXI\PostgreSQL\data" -l "%TEMP%\pgserver.log" stop > nul
