forked from I2P_Developers/i2p.i2p

My rationale for this: 1) in case someone is installing I2P on top of an already existing installation this will cause I2P to be shutdown 2) no hangs during the installation if i2p is already installed as a service 3) in case the NT service settings are changed in wrapper.config by us, this will force the service settings to be updated. 4) versions of I2P < 0.8.7 did not remove the service when uninstalling. If someone removed I2P in the past and reinstalls I2P--opting to run as a service--the installation process will hang.
44 lines
999 B
Batchfile
44 lines
999 B
Batchfile
@echo off
|
|
setlocal
|
|
|
|
rem
|
|
rem Java Service Wrapper general NT service install script
|
|
rem
|
|
|
|
if "%OS%"=="Windows_NT" goto nt
|
|
echo This script only works with NT-based versions of Windows.
|
|
goto :eof
|
|
|
|
:nt
|
|
rem
|
|
rem Find the application home.
|
|
rem
|
|
rem %~dp0 is location of current script under NT
|
|
set _REALPATH=%~dp0
|
|
set _WRAPPER_EXE=%_REALPATH%I2Psvc.exe
|
|
|
|
rem
|
|
rem Find the wrapper.conf
|
|
rem
|
|
:conf
|
|
set _WRAPPER_CONF="%~f1"
|
|
if not %_WRAPPER_CONF%=="" goto startup
|
|
set _WRAPPER_CONF="%_REALPATH%wrapper.config"
|
|
|
|
rem
|
|
rem Install the Wrapper as an NT service.
|
|
rem
|
|
:startup
|
|
:: We remove the existing service to
|
|
:: 1) force the service to stop
|
|
:: 2) update service configuration in case wrapper.config was edited
|
|
:: 3) prevent hanging the installer if 'install as service' is selected
|
|
:: and it's already enabled as a service.
|
|
"%_WRAPPER_EXE%" -r %_WRAPPER_CONF%
|
|
"%_WRAPPER_EXE%" -i %_WRAPPER_CONF%
|
|
if not errorlevel 1 goto :eof
|
|
if %2=="--nopause" goto :eof
|
|
pause
|
|
|
|
:eof
|