@ECHO OFF
REM =======================================
REM =
REM = 윈도우용 apache-tomcat 설치 스크립트
REM = (.zip으로 배포된 버전)
REM =
REM = 사용 방법:
REM = install_apache-tomcat.bat install
REM = install_apache-tomcat.bat uninstall
REM =
REM =======================================
CHCP 65001 1> NUL 2> NUL
CLS
REM ---------------------------------------
REM - 서비스 명과 자바홈 설정
REM ---------------------------------------
SET "SSC_VERSION=2310"
SET "DEFAULT_SERVICE_NAME=tomcat9"
SET "SERVICE_NAME=ssc_%SSC_VERSION%"
SET "JAVA_HOME=c:\PortableApps\jdk-11.0.16.1"
REM ---------------------------------------
REM - 최소/최대 Java Heap 메모리 설정
REM ---------------------------------------
SET "JvmMs=1024"
SET "JvmMx=8192"
REM ---------------------------------------
REM - 기본 상수 정의
REM ---------------------------------------
SET "CURRENT_DIR=%CD%"
SET "TIMESTAMP_VAL=%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%"
SET "TIMESTAMP_VAL=%TIMESTAMP_VAL: =0%"
IF NOT EXIST "%CURRENT_DIR%\bin\catalina.bat" (
ECHO "%CURRENT_DIR%\bin\catalina.bat" not found.
EXIT /B 1
)
CD /D "%CURRENT_DIR%\bin"
REM ---------------------------------------
REM - install/uninstall 파라미터 처리
REM ---------------------------------------
SET ARGC=0
FOR %%X IN (%*) DO SET /A ARGC+=1
IF %ARGC% LSS 1 GOTO LABEL_USAGE
IF "%1"=="install" (
ECHO YOUR FIRST PARAM IS "%1"
ECHO.
PAUSE
GOTO LABEL_INSTALL
)
IF "%1"=="uninstall" (
ECHO YOUR FIRST PARAM IS "%1"
ECHO.
PAUSE
GOTO LABEL_UNINSTALL
)
REM ---------------------------------------
REM - 사용법 출력 후 종료
REM ---------------------------------------
:LABEL_USAGE
ECHO Usage:
ECHO %0 ^<install/uninstall^>
CD /D %CURRENT_DIR%
PAUSE
EXIT /B 1
REM ---------------------------------------
REM - 설치 프로세스
REM ---------------------------------------
:LABEL_INSTALL
CALL SERVICE.BAT install "%SERVICE_NAME%"
ECHO ^<%%>..\webapps\ROOT\test.jsp
ECHO out.println("Aapache-Tomcat %SERVICE_NAME% Installed.");>>..\webapps\ROOT\test.jsp
ECHO %%^>>>..\webapps\ROOT\test.jsp
CALL :FUNC_CREATE_SHORTCUT "%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Apache Tomcat (%SERVICE_NAME%).lnk" "%CD%\%DEFAULT_SERVICE_NAME%w.exe" "//ES//%SERVICE_NAME%" "-" 1 "%CD%"
CALL :FUNC_CREATE_SHORTCUT "%PUBLIC%\Desktop\Apache Tomcat (%SERVICE_NAME%).lnk" "%CD%\%DEFAULT_SERVICE_NAME%w.exe" "//ES//%SERVICE_NAME%" "-" 1 "%CD%"
ECHO.
ECHO Please add "-Dfortify.home=D:\ssc_data\ssc_%SSC_VERSION%" to Java Options.
PAUSE
CD /D %CURRENT_DIR%
GOTO :EOF
REM ---------------------------------------
REM - 삭제 프로세스
REM ---------------------------------------
:LABEL_UNINSTALL
ECHO CALL SERVICE.BAT uninstall "%SERVICE_NAME%"
CALL SERVICE.BAT uninstall "%SERVICE_NAME%"
DEL /F /Q "%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Apache Tomcat (%SERVICE_NAME%).lnk"
DEL /F /Q "%PUBLIC%\Desktop\Apache Tomcat (%SERVICE_NAME%).lnk"
PAUSE
CD /D %CURRENT_DIR%
GOTO :EOF
REM -----------------------------------------------------------
REM 바로가기를 만드는 함수
REM
REM CALL :FUNC_CREATE_SHORTCUT <인수>
REM 인수 %1: 바로가기 파일명
REM %2: 타겟 파일명
REM %3: Arguments or "-"
REM %4: 아이콘 파일명 or "-"
REM %5: 윈도우 스타일 or "-"
REM %6: 시작 디렉토리 or "-"
REM -----------------------------------------------------------
:FUNC_CREATE_SHORTCUT
SET TMP_SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
ECHO Set oWS = WScript.CreateObject("WScript.Shell") > %TMP_SCRIPT%
ECHO sLinkFile = %1 >> %TMP_SCRIPT%
ECHO Set oLink = oWS.CreateShortcut(sLinkFile) >> %TMP_SCRIPT%
ECHO oLink.TargetPath = %2 >> %TMP_SCRIPT%
IF %3 NEQ "-" (
ECHO oLink.Arguments = %3 >> %TMP_SCRIPT%
)
IF %4 NEQ "-" (
ECHO oLink.IconLocation = %4 >> %TMP_SCRIPT%
)
REM 1: Default, 3:Maximized Window, 7:Minimized Window
IF %5 NEQ "-" (
ECHO oLink.WindowStyle = %5 >> %TMP_SCRIPT%
)
IF %6 NEQ "-" (
ECHO oLink.WorkingDirectory = %6 >> %TMP_SCRIPT%
)
ECHO oLink.Save >> %TMP_SCRIPT%
CSCRIPT /NOLOGO %TMP_SCRIPT%
DEL /F /Q %TMP_SCRIPT%
EXIT /B 0