Created
December 11, 2011 04:03
-
-
Save djangofan/1458224 to your computer and use it in GitHub Desktop.
Advanced script to start Openfire Chat server on Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
::------------------------------------------------------------------- | |
:: openfire_START.bat | |
:: The directory usually called "Openfire" is referred to as _SERVER_HOME | |
:: Script assumes these directories exist: | |
:: \Openfire , \Openfire\Javasoft, \Openfire\Databases, \Openfire\lib, \Openfire\plugins | |
::------------------------------------------------------------------- | |
setlocal | |
IF DEFINED SERVER_HOME ( | |
ECHO SERVER_HOME is already set to %SERVER_HOME% from system environment | |
SET _SERVER_HOME=%SERVER_HOME% | |
PING.exe -n 5 127.0.0.1>nul | |
GOTO :HOMESET | |
) | |
::------------------------------------------------------------------- | |
:: Locate _SERVER_HOME directory | |
::------------------------------------------------------------------- | |
SET _ofobject=lib\openfire.jar | |
SET "_TMPDIR=%~f0" | |
:LOOP | |
CALL :GET_DIR "%_TMPDIR%" | |
IF EXIST "%_TMPDIR%\%_ofobject%" ( | |
ECHO Found _SERVER_HOME at %_TMPDIR%\ | |
GOTO :HOMESET | |
) | |
IF "%_TMPDIR:~-1%" == ":" ( | |
CALL :FAILURE "Searched path up to the root directory and the required" "object^ | |
'%_ofobject%' was not found." | |
) | |
GOTO :LOOP | |
:HOMESET | |
SET _SERVER_HOME=%_TMPDIR% | |
IF !_SERVER_HOME:~-1!==\ SET _SERVER_HOME=!_SERVER_HOME:~0,-1! | |
SET __JAVA_HOME=%_SERVER_HOME%\Javasoft | |
ECHO. | |
::------------------------------------------------------------------- | |
:: Set _JAVA_HOME under _SERVER_HOME | |
::------------------------------------------------------------------- | |
set _JAVA_HOME=%_SERVER_HOME%\Javasoft | |
::------------------------------------------------------------------- | |
:: Other configurations plugins for Openfire | |
::------------------------------------------------------------------- | |
if not exist ..\plugins\monitoring.jar ( | |
ECHO. | |
ECHO Monitoring plugin should be installed if using Openfire 3.7 or later | |
) | |
if not exist %_SERVER_HOME%\Tools\7-Zip ( | |
@echo 7-Zip is missing in %_SERVER_HOME%\Tools\7-Zip. | |
@echo Please install 7-zip into %_SERVER_HOME%\Tools directory, then try again. | |
pause | |
exit | |
) | |
set _CURRENTDIR=%CD% | |
cd %_SERVER_HOME%\Databases | |
set _DATABASES=%CD% | |
cd %_CURRENTDIR% | |
if not exist %_DATABASES%\openfire_Data.MDF ( | |
%_SERVER_HOME%\Tools\7-Zip\7z e -y %_DATABASES%\openfire.7z | |
osql -D LocalServer -E -Q "EXEC sp_detach_db @dbname = N'openfire' | |
move /Y *.*df %_DATABASES% | |
osql -D LocalServer -E -Q "EXEC sp_attach_db @dbname = N'openfire',^ | |
@filename1=N'%_DATABASES%\openfire_Data.MDF',@filename2=N'%_DATABASES%\openfire_Log.LDF' | |
) | |
::------------------------------------------------------------------- | |
:: Start Openfire server | |
::------------------------------------------------------------------- | |
TITLE Openfire Server | |
echo. Launching Openfire jar in DOS shell | |
echo. | |
%__JAVA_HOME%\bin\java.exe -jar ../lib/startup.jar | |
GOTO END | |
::------------------------------------------------------------------- | |
:: Functions | |
::------------------------------------------------------------------- | |
:GET_DIR | |
SET "_TMPDIR=%~dp1" | |
SET "_TMPDIR=%_TMPDIR:~0,-1%" | |
EXIT /B 0 | |
:END | |
ECHO End of openfire_START.bat | |
pause>nul |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment