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 are:
<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:
1. i install/upgrade bacula, then i stop and deactivate it (default installation for alla clients, but not activated) 2. 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 ececute=once, so this recipe have no check condition nor upgrade command.
The bacula.bat script simply copy 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.b
at"
)
if exist "%ALLUSERSPROFILE%\Application Data\Bacula" (
copy /y "%WPKGROOT%\packages\bacula\%COMPUTERNAME%-before.bat" "%ALLUSERSPROFILE%\Application Data\Bacula\before.ba
t"
)
)
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 are if i upgrade binary (package bacula), i've to upgrade also the settings (bacula-settings) because by default the bacula package disable the service, and only the -settings package enable it.