diff --git a/fail2ban.changes b/fail2ban.changes index e9980b0..5ba0896 100644 --- a/fail2ban.changes +++ b/fail2ban.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Sat Sep 21 11:38:29 UTC 2013 - schuetzm@gmx.net + +- Added systemd service file and systemd-tmpfiles configuration + ------------------------------------------------------------------- Thu Jun 13 08:58:53 UTC 2013 - jweberhofer@weberhofer.at diff --git a/fail2ban.service b/fail2ban.service new file mode 100644 index 0000000..3c4b18a --- /dev/null +++ b/fail2ban.service @@ -0,0 +1,15 @@ +[Unit] +Description=Bans IPs with too many authentication failures +After=network.target SuSEfirewall2.service + +[Service] +Type=forking +EnvironmentFile=-/etc/sysconfig/fail2ban +PIDFile=/run/fail2ban/fail2ban.pid +ExecStart=/usr/bin/fail2ban-client -x $FAIL2BAN_OPTIONS start +ExecReload=/usr/bin/fail2ban-client reload +ExecStop=/usr/bin/fail2ban-client stop + +[Install] +WantedBy=multi-user.target + diff --git a/fail2ban.spec b/fail2ban.spec index c4526ec..6c03692 100644 --- a/fail2ban.spec +++ b/fail2ban.spec @@ -28,6 +28,10 @@ Requires: python-pyinotify %if 0%{?suse_version} >= 1220 Requires: python-gamin %endif +%if 0%{?suse_version} >= 1230 +%{?systemd_requires} +BuildRequires: systemd +%endif BuildRequires: logrotate BuildRequires: python-devel PreReq: %fillup_prereq @@ -41,9 +45,15 @@ License: GPL-2.0+ Group: Productivity/Networking/Security #URL https://codeload.github.com/fail2ban/fail2ban/tar.gz/0.8.9 Source0: %{name}-%{version}.tar.gz +%if 0%{?suse_version} < 1230 Source1: %{name}.init +%endif Source2: %{name}.sysconfig Source3: %{name}.logrotate +%if 0%{?suse_version} >= 1230 +Source4: %{name}.service +Source5: %{name}.tmpfiles +%endif %description Fail2ban scans log files like /var/log/messages and bans IP addresses @@ -72,23 +82,50 @@ for i in fail2ban-client fail2ban-regex fail2ban-server; do done install -d -m755 $RPM_BUILD_ROOT/%{_initrddir} install -d -m755 $RPM_BUILD_ROOT/%{_sbindir} +%if 0%{?suse_version} < 1230 install -m755 %{SOURCE1} $RPM_BUILD_ROOT/%{_initrddir}/%{name} ln -sf %{_initrddir}/%{name} ${RPM_BUILD_ROOT}%{_sbindir}/rc%{name} +%endif install -d -m755 $RPM_BUILD_ROOT/var/adm/fillup-templates install -m 644 %{SOURCE2} $RPM_BUILD_ROOT/var/adm/fillup-templates/sysconfig.%{name} install -d -m755 $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d install -m 644 %{SOURCE3} $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/fail2ban +%if 0%{?suse_version} >= 1230 +install -d -m755 $RPM_BUILD_ROOT/%{_unitdir} +install -m644 %{SOURCE4} $RPM_BUILD_ROOT/%{_unitdir}/%{name}.service + +install -d -m755 $RPM_BUILD_ROOT/usr/lib/tmpfiles.d/ +install -m644 %{SOURCE5} $RPM_BUILD_ROOT/usr/lib/tmpfiles.d/%{name}.conf +%endif + +%pre +%if 0%{?suse_version} >= 1230 +%service_add_pre %{name}.service +%endif + %post %{fillup_only} +%if 0%{?suse_version} >= 1230 +systemd-tmpfiles --create /usr/lib/tmpfiles.d/%{name}.conf +%service_add_post %{name}.service +%endif %preun +%if 0%{?suse_version} >= 1230 +%service_del_preun %{name}.service +%else %stop_on_removal %{name} +%endif %postun +%if 0%{?suse_version} >= 1230 +%service_del_postun %{name}.service +%else %restart_on_update %{name} %insserv_cleanup +%endif %files %defattr(-, root, root) @@ -99,11 +136,16 @@ install -m 644 %{SOURCE3} $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/fail2ban %config(noreplace) %{_sysconfdir}/%{name}/action.d/*.conf %config(noreplace) %{_sysconfdir}/%{name}/filter.d/*.conf %config %{_sysconfdir}/logrotate.d/fail2ban +%if 0%{?suse_version} >= 1230 +%{_unitdir}/%{name}.service +/usr/lib/tmpfiles.d/%{name}.conf +%else %{_initrddir}/%{name} -%{_bindir}/%{name}* %{_sbindir}/rc%{name} -%{_datadir}/%{name} %dir %ghost /var/run/%{name} +%endif +%{_bindir}/%{name}* +%{_datadir}/%{name} /var/adm/fillup-templates/sysconfig.%{name} %doc %{_mandir}/man1/* %doc COPYING ChangeLog DEVELOP README.md TODO files/cacti diff --git a/fail2ban.tmpfiles b/fail2ban.tmpfiles new file mode 100644 index 0000000..106e114 --- /dev/null +++ b/fail2ban.tmpfiles @@ -0,0 +1 @@ +d /run/fail2ban 0755 root root