Bacula
From WPKG | Open Source Software Deployment and Distribution
A silent installer for Bacula.
Clearly this recipe was only for bacula-fd (Bacula Client).
Instead of installing bacula-fd for specific host, I install bacula for all host and I activate it when needed, using some script glue.
My recipe is:
<package
id="bacula"
name="Bacula File Daemon"
revision="2281"
reboot="false"
priority="50">
<check type="uninstall" condition="exists" path="Bacula" />
<install cmd='"%SOFTWARE%\WPKG\winbacula-2.2.8.exe" /S' />
<install cmd='net stop Bacula-fd' >
<exit code='0' />
<exit code='2' />
</install>
<install cmd='sc config Bacula-fd start= demand' />
<upgrade cmd='net stop Bacula-fd' >
<exit code='0' />
<exit code='2' />
</upgrade>
<upgrade cmd='sc delete Bacula-fd' />
<upgrade cmd='"%SOFTWARE%\WPKG\winbacula-2.2.8.exe" /S' />
<upgrade cmd='sc config Bacula-fd start= demand' />
<remove cmd='"%ProgramFiles%\Bacula\uninstall.exe" /S' />
</package>
as you can see:
- I install/upgrade bacula, then I stop and deactivate it (as stated on intro, default installation for all clients, but not activated)
- on upgrade, bacula service have to be removed for a real silent installation, so I stop and remove it before upgrade
Done that, I've to configure, and I use this recipe:
<package
id="bacula-settings"
name="Bacula File Daemon settings"
revision="200803051"
priority="5"
reboot="false"
execute="once">
<depends package-id="bacula" />
<install cmd='%WPKGROOT%\packages\bacula.bat' />
<remove cmd='net stop Bacula-fd' >
<exit code='0' />
<exit code='2' />
</remove>
<remove cmd='sc config Bacula-fd start= demand' />
</package>
Note the execute=once, so this recipe have no check condition nor an upgrade command.
The bacula.bat script simply copies configuration files and scripts from a directory based on the hostname:
@ECHO OFF
:: Stop the service, for maximum safety
::
net stop Bacula-fd
:: We use the %COMPUTERNAME% variable to setup conditionally the bacula daemon
:: Note the dirs for English and Italian configuration files, add/modify as needed
::
if exist "%WPKGROOT%\packages\bacula\%COMPUTERNAME%.conf" (
if exist "%ALLUSERSPROFILE%\Dati applicazioni\Bacula" (
copy /y "%WPKGROOT%\packages\bacula\%COMPUTERNAME%.conf" "%ALLUSERSPROFILE%\Dati applicazioni\Bacula\bacula-fd.conf"
)
if exist "%ALLUSERSPROFILE%\Application Data\Bacula" (
copy /y "%WPKGROOT%\packages\bacula\%COMPUTERNAME%.conf" "%ALLUSERSPROFILE%\Application Data\Bacula\bacula-fd.conf"
)
if exist "%WPKGROOT%\packages\bacula\%COMPUTERNAME%-before.bat" (
if exist "%ALLUSERSPROFILE%\Dati applicazioni\Bacula" (
copy /y "%WPKGROOT%\packages\bacula\%COMPUTERNAME%-before.bat" "%ALLUSERSPROFILE%\Dati applicazioni\Bacula\before.bat"
)
if exist "%ALLUSERSPROFILE%\Application Data\Bacula" (
copy /y "%WPKGROOT%\packages\bacula\%COMPUTERNAME%-before.bat" "%ALLUSERSPROFILE%\Application Data\Bacula\before.bat"
)
)
if exist "%WPKGROOT%\packages\bacula\%COMPUTERNAME%-after.bat" (
if exist "%ALLUSERSPROFILE%\Dati applicazioni\Bacula" (
copy /y "%WPKGROOT%\packages\bacula\%COMPUTERNAME%-after.bat" "%ALLUSERSPROFILE%\Dati applicazioni\Bacula\after.bat"
)
if exist "%ALLUSERSPROFILE%\Application Data\Bacula" (
copy /y "%WPKGROOT%\packages\bacula\%COMPUTERNAME%-after.bat" "%ALLUSERSPROFILE%\Application Data\Bacula\after.bat"
)
)
:: netsh firewall set portopening ALL 9102 "Bacula File Daemon" ENABLE SUBNET
netsh firewall add allowedprogram program = "%ProgramFiles%\Bacula\bin\bacula-fd.exe" name = "Bacula File Daemon"
sc config Bacula-fd start= auto
net start Bacula-fd
) else (
:: netsh firewall delete portopening ALL 9102
netsh firewall delete allowedprogram program = "%ProgramFiles%\Bacula\bin\bacula-fd.exe"
sc config Bacula-fd start= demand
)
:: force an exit with well-known code
::
exit 0
The only drawback for now: if I upgrade the binary (package bacula), I have to upgrade also the settings (bacula-settings) because by default the bacula package disables the service, and only the -settings package enables it.