Enable/Disable module automatically

This commit is contained in:
Markus Frosch 2019-05-02 15:24:12 +02:00
parent 04639ae724
commit 5446c15a4d
2 changed files with 45 additions and 0 deletions

18
icinga-build-test Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
set -e
module_name=director
echo "Installing icingaweb2 module ${module_name}"
icinga-build-rpm-install "icingaweb2-module-${module_name}"
sudo sh -ex <<ROOT
ls -al /usr/share/icingaweb2/modules
find /etc/icingaweb2
if [ ! -L /etc/icingaweb2/enabledModules/${module_name} ]; then
echo "Module is not enabled at /etc/icingaweb2/enabledModules/${module_name}" >&2
exit 1
fi
ROOT

View File

@ -46,6 +46,33 @@ cp -r * %{buildroot}%{basedir}
%clean
rm -rf %{buildroot}
%post
set -e
# Only for fresh installations
if [ $1 == 1 ]; then
if [ ! -d /etc/icingaweb2/enabledModules ]; then
mkdir /etc/icingaweb2/enabledModules
chmod g=rwx,o= /etc/icingaweb2/enabledModules
fi
echo "Enabling icingaweb2 module '%{module_name}'"
ln -svf /usr/share/icingaweb2/modules/%{module_name} /etc/icingaweb2/enabledModules/%{module_name}
fi
exit 0
%preun
set -e
# Only for removal
if [ $1 == 0 ]; then
echo "Disabling icingaweb2 module '%{module_name}'"
rm -f /etc/icingaweb2/enabledModules/%{module_name}
fi
exit 0
%files
%doc README.md LICENSE