powered by Jive Software

Script for deploying the spark.properties file

I created a batch script for deploying the spark.properties file to all user profiles on a Windows machine. When the batch file is executed, it checks if the spark.properties file exists and if it doesn’t, it copies the file from C:\Program Files\Spark (you need to create your default spark.properties file there first) to the Spark folder in the user profile. It will also create the Spark folder in the user profile if it doesn’t exist. Then it launches Spark. If the file aleady exists in the user profile, it just launches Spark. Here’s the code. Save it as a .bat file.

REM ECHO OFF

echo.

:Check
If exist “%USERPROFILE%\Spark\spark.properties” goto Launch
If not errorlevel 1 goto Copy

:Launch
start “” "C:\Program Files\Spark\Spark.exe"
exit

:Copy
mkdir "%USERPROFILE%\Spark"
copy “C:\Program Files\Spark\spark.properties” "%USERPROFILE%\Spark"
goto Launch

I am using this on a Terminal Services server, and will have the users execute the batch file instead of the .exe to open Spark.

Overly complex and only works if the version of spark is 2.5.8 or below.

Thanks for your input Todd. How would you simplify this? I am using 2.5.8 for my company because it is the latest production release. What changes after 2.5.8 that would cause this not to work?.. the location of the Spark user profile folder?

I believe the comment regarding this not working after 2.5.8 is because the spark.properties file is moving; “SVN version user’s profile path has been changed from \Username\Spark to \Username\Application Data\Spark (Windows XP) and \Username\AppData\Roaming\Spark (Windows Vista and 7).” (taken from http://www.igniterealtime.org/community/docs/DOC-1822 )

I built a batch script to (re)configure my user’s Spark client that runs on userlogon by a domain Policy.

Using few powerful command line tools like SED and PSKILL proved very useful in my case, so I have them on my SYSVOL (netlogon).

@echo off

IF EXIST “%USERPROFILE%\AppData\Roaming\Spark\spark.properties” GOTO DoesExist

echo “Spark not deployed.”

GOTO End

:DoesExist

echo.

echo - Seeking Spark…

IF EXIST %USERPROFILE%\AppData\Roaming\Spark\spark.propertiesSpark\spark.properties.bkp GOTO Done

echo.

echo – Ending Spark process…

\yourdomain\NETLOGON\apl\SPARK\ChangeServer\pskill.exe /accepteula spark

echo.

echo — Updating Spark configuration…

echo.

echo ---- Server … OK

\yourdomain\NETLOGON\apl\SPARK\ChangeServer\sed.exe “s/^server=.*/server=openfireserver.yourdomain/” -i.bkp “%USERPROFILE%\AppData\Roaming\Spark\spark.properties”

echo.

echo ---- Username … OK

\yourdomain\NETLOGON\apl\SPARK\ChangeServer\sed.exe “s/^username=.*/username=%username%/” -i.bkp “%USERPROFILE%\AppData\Roaming\Spark\spark.properties”

echo.

echo ---- Password … OK

\yourdomain\NETLOGON\apl\SPARK\ChangeServer\sed.exe “s/^passwordSaved=.*/passwordSaved=true/” -i.bkp “%USERPROFILE%\AppData\Roaming\Spark\spark.properties”

echo.

echo ----- Done.

GOTO End

:Done

echo Spark configuration already looks up-to-date. skiping…

GOTO End

:End

I hope it helps.

Juan Mottini