36 lines
984 B
Batchfile
36 lines
984 B
Batchfile
@echo off
|
|
setlocal EnableExtensions DisableDelayedExpansion
|
|
|
|
if "%~1"=="" goto :usage
|
|
if "%~2"=="" goto :usage
|
|
if "%~3"=="" goto :usage
|
|
if not "%~3"=="CONFIRM_UNINSTALL" goto :refuse
|
|
|
|
set "SQL_SERVER=%~1"
|
|
set "DATABASE=%~2"
|
|
set "SQL_FILE=%~dp0..\fortucky-algorithm\src\main\resources\db\sqlserver\uninstall-shadow.sql"
|
|
|
|
if not exist "%SQL_FILE%" (call :fail "uninstall SQL file is missing" & exit /b 1)
|
|
where sqlcmd >nul 2>nul
|
|
if errorlevel 1 (call :fail "sqlcmd is not available on PATH" & exit /b 1)
|
|
|
|
echo WARNING: export all alg.* evidence before uninstalling.
|
|
echo The shadow application must be stopped and the stable service restored first.
|
|
sqlcmd -S "%SQL_SERVER%" -d "%DATABASE%" -E -b -r1 -i "%SQL_FILE%"
|
|
if errorlevel 1 exit /b 1
|
|
|
|
echo UNINSTALL_OK
|
|
exit /b 0
|
|
|
|
:usage
|
|
echo Usage: %~nx0 SQL_SERVER DATABASE CONFIRM_UNINSTALL 1>&2
|
|
exit /b 2
|
|
|
|
:refuse
|
|
echo UNINSTALL_REFUSED third argument must be CONFIRM_UNINSTALL 1>&2
|
|
exit /b 3
|
|
|
|
:fail
|
|
echo UNINSTALL_FAILED %~1 1>&2
|
|
exit /b 1
|