diff syslog2iptables.spec.in @ 71:79f310d1bc46

RHEL7 systemd and /var/run on tmpfs
author Carl Byington <carl@five-ten-sg.com>
date Thu, 09 Feb 2017 12:44:31 -0800
parents 0e736950a117
children 4685767c0c85
line wrap: on
line diff
--- a/syslog2iptables.spec.in	Mon Dec 21 08:00:33 2015 -0800
+++ b/syslog2iptables.spec.in	Thu Feb 09 12:44:31 2017 -0800
@@ -3,7 +3,7 @@
 Summary:            Syslog to iptables dynamic firewall
 Name:               @PACKAGE@
 Version:            @VERSION@
-Release:            3%{?dist}
+Release:            1%{?dist}
 License:            GPLv3+
 Group:              System Environment/Daemons
 Source:             http://www.five-ten-sg.com/%{name}/packages/%{name}-%{version}.tar.gz
@@ -15,6 +15,15 @@
 Requires:               iptables
 Requires:               coreutils
 BuildRequires:          gcc gcc-c++
+%if "%{?dist}" == ".el7"
+Requires(pre):  systemd-sysv, shadow-utils
+Requires(post): systemd-units
+Requires(preun):  systemd-units
+Requires(postun): systemd-units
+Requires:       coreutils
+Requires:       systemd-units
+BuildRequires:  systemd-units
+%endif
 
 
 %description
@@ -30,31 +39,59 @@
 
 
 %install
-rm -rf $RPM_BUILD_ROOT
-make DESTDIR=$RPM_BUILD_ROOT install
-mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
-mv -f $RPM_BUILD_ROOT%{_sysconfdir}/%{name}        $RPM_BUILD_ROOT/etc/rc.d/init.d
-rm -f $RPM_BUILD_ROOT%{_sysconfdir}/%{name}.conf
+rm -rf %{buildroot}
+make DESTDIR=%{buildroot} install
+%if "%{?dist}" == ".el7"
+install -m 644 -D %{buildroot}%{_sysconfdir}/%{name}.service \
+    %{buildroot}%{_unitdir}/%{name}.service
+%else
+install -m 755 -D %{buildroot}%{_sysconfdir}/%{name} \
+    %{buildroot}%{_initrddir}/%{name}
+%endif
+rm -f  %{buildroot}%{_sysconfdir}/%{name}
+rm -f  %{buildroot}%{_sysconfdir}/%{name}.service
 
 
 %clean
-rm -rf $RPM_BUILD_ROOT
+rm -rf %{buildroot}
 
 
 %pre
 
 
 %post
+if [ $1 = 1 ]; then
+    # initial install
+%if "%{?dist}" == ".el7"
+    /bin/systemctl daemon-reload &>/dev/null || :
+%else
 /sbin/chkconfig --add %{name}
+%endif
 (cd %{_sysconfdir}; ./%{name}.conf.make)
-
+fi
 
 %preun
-[ $1 = 0 ] && /sbin/service %{name} stop || :
+if [ $1 = 0 ]; then
+    # package removal, not upgrade
+%if "%{?dist}" == ".el7"
+    /bin/systemctl --no-reload disable %{name}.service &>/dev/null || :
+    /bin/systemctl stop %{name}.service &>/dev/null || :
+%else
+    /sbin/service %{name} stop || :
+    /sbin/chkconfig --del %{name}
+%endif
+fi
 
 
 %postun
-[ $1 = 0 ] && /sbin/chkconfig --del %{name} || :
+if [ $1 -ge 1 ]; then
+    # package upgrade, not uninstall
+%if "%{?dist}" == ".el7"
+    /bin/systemctl try-restart %{name}.service &>/dev/null || :
+%else
+    /sbin/service %{name} restart || :
+%endif
+fi
 
 
 %files
@@ -68,10 +105,17 @@
 %config(noreplace) %{_sysconfdir}/%{name}.conf.httpd
 %config(noreplace) %{_sysconfdir}/%{name}.conf.bottom
 %attr(750,root,root) %{_sysconfdir}/%{name}.conf.make
-/etc/rc.d/init.d/%{name}
+%if "%{?dist}" == ".el7"
+%{_unitdir}/%{name}.service
+%else
+%{_initrddir}/%{name}
+%endif
 
 
 %changelog
+* Thu Feb 09 2017 Carl Byington <carl@five-ten-sg.com> - 1.17-1
+- RHEL7 systemd and /var/run is on tmpfs
+
 * Mon Dec 21 2015 Carl Byington <carl@five-ten-sg.com> - 1.16-3
 - fix post uninstall script
 - allow config bucket count zero to disable a pattern