-# TODO:
-# If you call 'check_raid -S' as root it will attempt to add the required lines to the sudoers file in order for itself to work.
%define plugin check_raid
Summary: Nagios plugin to check current server's RAID status
Name: nagios-plugin-%{plugin}
-Version: 2.0
-Release: 0.2
+Version: 2.1
+Release: 0.5
License: Unknown
Group: Networking
Source0: %{plugin}
URL: http://exchange.nagios.org/directory/Plugins/Hardware/Storage-Systems/RAID-Controllers/check_raid/details
Source1: %{plugin}.cfg
Requires: nagios-core
+Requires: sudo
BuildArch: noarch
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%clean
rm -rf $RPM_BUILD_ROOT
+%post
+if [ "$1" = 1 ]; then
+ # setup sudo rules on first install
+ %{plugindir}/%{plugin} -S || :
+fi
+
+%postun
+if [ "$1" = 0 ]; then
+ # remove all sudo rules related to us
+ %{__sed} -i -e '/CHECK_RAID/d' /etc/sudoers
+fi
+
%files
%defattr(644,root,root,755)
%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{plugin}.cfg