@echo off


if ""=="%1" set ctype=vpn
if NOT ""=="%1" set ctype=%1

set cnfdir=c:\dkc200\config\


echo.
echo [ASSIST Center IP address Change Tool for RAID500]
echo Config dir is %cnfdir%.
echo.
echo ASSIST paramater is erased, 
echo     and then this batch sets up changes IP address of ASSIST center.
echo.
echo May I erase ASSIST paramater,
echo     and will I be allowed to set up ASSIST center IP address.
echo     (center address is %ctype% type.)
echo  yes = hit return key.
echo  no  = hit Ctl+C  key.
echo.
pause


if vpn==%ctype% goto orgbackup
if isdn==%ctype% goto orgbackup

goto parmerror


:orgbackup
if NOT EXIST %cnfdir%eastcall.org copy /v /b %cnfdir%eastcall.cfg %cnfdir%eastcall.org
if NOT ERRORLEVEL 0 goto copyerror
if NOT EXIST %cnfdir%westcall.org copy /v /b %cnfdir%westcall.cfg %cnfdir%westcall.org
if NOT ERRORLEVEL 0 goto copyerror
if NOT EXIST %cnfdir%answ.org copy /v /b %cnfdir%answ.cfg %cnfdir%answ.org
if NOT ERRORLEVEL 0 goto copyerror
if NOT EXIST %cnfdir%call.org copy /v /b %cnfdir%call.cfg %cnfdir%call.org
if NOT ERRORLEVEL 0 goto copyerror
if NOT EXIST %cnfdir%rmfc.org copy /v /b %cnfdir%rmfc.cfg %cnfdir%rmfc.org
if NOT ERRORLEVEL 0 goto copyerror

if NOT EXIST %cnfdir%eastcall.org goto copyerror
if NOT EXIST %cnfdir%westcall.org goto copyerror
if NOT EXIST %cnfdir%answ.org goto copyerror
if NOT EXIST %cnfdir%call.org goto copyerror
if NOT EXIST %cnfdir%rmfc.org goto copyerror

if isdn==%ctype% goto setisdn
goto setvpn


:setvpn
set asteip=172.16.0.1
set astwip=172.16.1.1
set str1ip=172.16.2.1
set gwip=172.16.0.1
goto setip


:setisdn
set asteip=10.0.64.110
set astwip=10.0.128.110
set str1ip=10.0.1.1
set gwip=10.0.64.110
goto setip


:setip
echo ID ASTE> %cnfdir%eastcall.cfg
echo    ASSIST00>> %cnfdir%eastcall.cfg
echo    %asteip%>> %cnfdir%eastcall.cfg
echo ID ASTW>> %cnfdir%eastcall.cfg
echo    ASSIST00>> %cnfdir%eastcall.cfg
echo    %astwip%>> %cnfdir%eastcall.cfg

echo ID ASTW> %cnfdir%westcall.cfg
echo    ASSIST00>> %cnfdir%westcall.cfg
echo    %astwip%>> %cnfdir%westcall.cfg
echo ID ASTE>> %cnfdir%westcall.cfg
echo    ASSIST00>> %cnfdir%westcall.cfg
echo    %asteip%>> %cnfdir%westcall.cfg

echo ID ASTE> %cnfdir%answ.cfg
echo    ASSIST00>>%cnfdir%answ.cfg
echo    %asteip%>>%cnfdir%answ.cfg
echo ID ASTW>>%cnfdir%answ.cfg
echo    ASSIST00>>%cnfdir%answ.cfg
echo    %astwip%>>%cnfdir%answ.cfg
echo ID STR1>>%cnfdir%answ.cfg
echo    ASSIST00>>%cnfdir%answ.cfg
echo    %str1ip%>>%cnfdir%answ.cfg

echo CNT 10> %cnfdir%call.cfg
echo TIME 60>> %cnfdir%call.cfg
echo GW %gwip%>> %cnfdir%call.cfg
echo ID ASTE>> %cnfdir%call.cfg
echo    ASSIST00>> %cnfdir%call.cfg
echo    %asteip%>> %cnfdir%call.cfg
echo ID ASTW>> %cnfdir%call.cfg
echo    ASSIST00>> %cnfdir%call.cfg
echo    %astwip%>> %cnfdir%call.cfg

echo ID ASTE> %cnfdir%rmfc.cfg
echo    ASSIST00>> %cnfdir%rmfc.cfg
echo    %asteip%>> %cnfdir%rmfc.cfg
echo ID STR1>> %cnfdir%rmfc.cfg
echo    ASSIST00>> %cnfdir%rmfc.cfg
echo    %str1ip%>> %cnfdir%rmfc.cfg

if NOT EXIST %cnfdir%eastcall.cfg goto makeerror
if NOT EXIST %cnfdir%westcall.cfg goto makeerror
if NOT EXIST %cnfdir%answ.cfg goto makeerror
if NOT EXIST %cnfdir%call.cfg goto makeerror
if NOT EXIST %cnfdir%rmfc.cfg goto makeerror

echo.
echo completed. 
echo.
echo Caution!
echo     Operate a setup of ASSIST paramater next surely.
echo.

goto end




:parmerror
echo ERROR:Illegal parameter.
echo.
echo Input a parameter to execute.
echo.
echo Usage:
echo  acipvpn.bat          (IP address of ASSIST center for VPN)
echo  acipvpn.bat vpn      (IP address of ASSIST center for VPN)
echo  acipvpn.bat isdn     (IP address of ASSIST center for ISDN)
echo.

goto end


:copyerror
echo ERROR:Original file backup error.
echo.
echo There was a copy error with either of the following files.
echo     %cnfdir%eastcall.cfg to %cnfdir%eastcall.org.
echo     %cnfdir%westcall.cfg to %cnfdir%westcall.org.
echo     %cnfdir%answ.cfg to %cnfdir%answ.org.
echo     %cnfdir%call.cfg to %cnfdir%call.org.
echo     %cnfdir%rmfc.cfg to %cnfdir%rmfc.org.
echo.
echo Please confirm that:
echo    1: Original file exist.
echo    2: %cnfdir% directory exist.
echo    3: disk free space.

goto end


:makeerror
echo ERROR:cfg make error.
echo.
echo There was a preparation error with either of the following files.
echo     %cnfdir%eastcall.cfg
echo     %cnfdir%westcall.cfg
echo     %cnfdir%answ.cfg
echo     %cnfdir%call.cfg
echo     %cnfdir%rmfc.cfg
echo.
echo Please manual restore.
echo     %cnfdir%eastcall.org to %cnfdir%eastcall.cfg
echo     %cnfdir%westcall.org to %cnfdir%westcall.cfg
echo     %cnfdir%answ.org to %cnfdir%answ.cfg
echo     %cnfdir%call.org to %cnfdir%call.cfg
echo     %cnfdir%rmfc.org to %cnfdir%rmfc.cfg
echo.

goto end


:end
pause

