Enable/Disable module automatically
This commit is contained in:
parent
04639ae724
commit
5446c15a4d
|
@ -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
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue