3cd8a4
%define _hardened_build 1
3cd8a4
Summary:          Software and/or Hardware watchdog daemon
3cd8a4
Name:             watchdog
3cd8a4
Version:          5.13
3cd8a4
Release:          12%{?dist}
3cd8a4
License:          GPLv2+
3cd8a4
3cd8a4
URL:              http://sourceforge.net/projects/watchdog/
3cd8a4
Source0:          http://downloads.sourceforge.net/watchdog/watchdog-%{version}.tar.gz
3cd8a4
Source1:          watchdog.init
3cd8a4
Source2:          README.watchdog.ipmi
3cd8a4
Source3:          README.Fedora
3cd8a4
Source4:          watchdog.service
3cd8a4
Source5:          watchdog-ping.service
3cd8a4
3cd8a4
# Documentation fixes (RHBZ#948883).
3cd8a4
# Sent upstream on 2013-05-16.
3cd8a4
Patch1:           0001-watchdog-Clearer-help-output.patch
3cd8a4
Patch2:           0002-wd_identify-wd_keepalive-Document-c-config-file-in-h.patch
3cd8a4
Patch3:           0003-watchdog-5.13-rhsel.patch
3cd8a4
Patch4:           0004-watchdog-5.13-rhseldoc.patch
3cd8a4
3cd8a4
BuildRequires:    systemd-units
3cd8a4
3cd8a4
Requires(post): systemd-units
3cd8a4
Requires(preun): systemd-units
3cd8a4
Requires(postun): systemd-units
3cd8a4
3cd8a4
3cd8a4
%description
3cd8a4
The watchdog program can be used as a powerful software watchdog daemon 
3cd8a4
or may be alternately used with a hardware watchdog device such as the 
3cd8a4
IPMI hardware watchdog driver interface to a resident Baseboard 
3cd8a4
Management Controller (BMC).  watchdog periodically writes to /dev/watchdog; 
3cd8a4
the interval between writes to /dev/watchdog is configurable through settings 
3cd8a4
in the watchdog sysconfig file.  This configuration file is also used to 
3cd8a4
set the watchdog to be used as a hardware watchdog instead of its default 
3cd8a4
software watchdog operation.  In either case, if the device is open but not 
3cd8a4
written to within the configured time period, the watchdog timer expiration 
3cd8a4
will trigger a machine reboot. When operating as a software watchdog, the 
3cd8a4
ability to reboot will depend on the state of the machine and interrupts.  
3cd8a4
When operating as a hardware watchdog, the machine will experience a hard 
3cd8a4
reset (or whatever action was configured to be taken upon watchdog timer 
3cd8a4
expiration) initiated by the BMC.
3cd8a4
3cd8a4
 
3cd8a4
%prep
3cd8a4
%setup -q -n %{name}-%{version}
3cd8a4
%patch1 -p1 -b .help
3cd8a4
%patch2 -p1 -b .keepalive
3cd8a4
%patch3 -p1 -b .rhsel
3cd8a4
%patch4 -p1 -b .rhseldoc
3cd8a4
3cd8a4
cp %{SOURCE2} .
3cd8a4
cp %{SOURCE3} .
3cd8a4
%if 0%{?rhel}
3cd8a4
mv README.Fedora README.RHEL
3cd8a4
%endif
3cd8a4
3cd8a4
mv README README.orig
3cd8a4
iconv -f ISO-8859-1 -t UTF-8 < README.orig > README
3cd8a4
3cd8a4
3cd8a4
%build
3cd8a4
%configure 
3cd8a4
make %{?_smp_mflags}
3cd8a4
3cd8a4
3cd8a4
%install
3cd8a4
install -d -m0755 ${RPM_BUILD_ROOT}%{_sysconfdir}
3cd8a4
install -d -m0755 ${RPM_BUILD_ROOT}%{_sysconfdir}/watchdog.d
3cd8a4
make DESTDIR=${RPM_BUILD_ROOT} install
3cd8a4
install -Dp -m0644 %{name}.sysconfig ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/watchdog
3cd8a4
install -Dp -m0644 %{SOURCE4} ${RPM_BUILD_ROOT}%{_unitdir}/watchdog.service
3cd8a4
install -Dp -m0644 %{SOURCE5} ${RPM_BUILD_ROOT}%{_unitdir}/watchdog-ping.service
3cd8a4
install -Dd -m0755 ${RPM_BUILD_ROOT}%{_libexecdir}/watchdog/scripts
3cd8a4
3cd8a4
3cd8a4
%post
3cd8a4
if [ $1 -eq 1 ] ; then 
3cd8a4
    # Initial installation 
3cd8a4
    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
3cd8a4
fi
3cd8a4
3cd8a4
3cd8a4
%preun 
3cd8a4
if [ $1 -eq 0 ] ; then
3cd8a4
    # Package removal, not upgrade
3cd8a4
    /bin/systemctl --no-reload disable watchdog.service > /dev/null 2>&1 || :
3cd8a4
    /bin/systemctl --no-reload disable watchdog-ping.service > /dev/null 2>&1 || :
3cd8a4
    /bin/systemctl stop watchdog.service > /dev/null 2>&1 || :
3cd8a4
    /bin/systemctl stop watchdog-ping.service > /dev/null 2>&1 || :
3cd8a4
fi
3cd8a4
3cd8a4
3cd8a4
%postun 
3cd8a4
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
3cd8a4
if [ $1 -ge 1 ] ; then
3cd8a4
    # Package upgrade, not uninstall
3cd8a4
    /bin/systemctl try-restart watchdog.service >/dev/null 2>&1 || :
3cd8a4
    /bin/systemctl try-restart watchdog-ping.service >/dev/null 2>&1 || :
3cd8a4
fi
3cd8a4
3cd8a4
%triggerun -- watchdog < 5.9-4
3cd8a4
# Save the current service runlevel info
3cd8a4
# User must manually run systemd-sysv-convert --apply watchdog
3cd8a4
# to migrate them to systemd targets
3cd8a4
/usr/bin/systemd-sysv-convert --save watchdog >/dev/null 2>&1 ||:
3cd8a4
3cd8a4
# Run these because the SysV package being removed won't do them
3cd8a4
/sbin/chkconfig --del watchdog >/dev/null 2>&1 || :
3cd8a4
/bin/systemctl try-restart watchdog.service >/dev/null 2>&1 || :
3cd8a4
/bin/systemctl try-restart watchdog-ping.service >/dev/null 2>&1 || :
3cd8a4
3cd8a4
3cd8a4
%files
3cd8a4
%doc AUTHORS ChangeLog COPYING examples/ IAFA-PACKAGE NEWS README TODO README.watchdog.ipmi
3cd8a4
%if 0%{?rhel}
3cd8a4
%doc README.RHEL
3cd8a4
%else
3cd8a4
%doc README.Fedora
3cd8a4
%endif
3cd8a4
%config(noreplace) %{_sysconfdir}/watchdog.conf
3cd8a4
%config(noreplace) %{_sysconfdir}/sysconfig/watchdog
3cd8a4
%{_sysconfdir}/watchdog.d
3cd8a4
%{_sbindir}/watchdog
3cd8a4
%{_sbindir}/wd_identify
3cd8a4
%{_sbindir}/wd_keepalive
3cd8a4
%{_mandir}/man5/watchdog.conf.5*
3cd8a4
%{_mandir}/man8/watchdog.8*
3cd8a4
%{_mandir}/man8/wd_identify.8*
3cd8a4
%{_mandir}/man8/wd_keepalive.8*
3cd8a4
%{_unitdir}/watchdog.service
3cd8a4
%{_unitdir}/watchdog-ping.service
3cd8a4
%{_libexecdir}/watchdog/scripts
3cd8a4
3cd8a4
3cd8a4
%changelog
3cd8a4
* Tue Jun 19 2018 Josef Ridky <jridky@redhat.com> - 5.13-12
3cd8a4
- Resolves: #1092523 - add PIE and RELRO check 
3cd8a4
- Resolves: #1133135 - add ipmi.service dependency to watchdog.service file
3cd8a4
- Resolves: #1259816 - remove deprecated stanza in unit files
3cd8a4
3cd8a4
* Fri Jan 24 2014 Daniel Mach <dmach@redhat.com> - 5.13-11
3cd8a4
- Mass rebuild 2014-01-24
3cd8a4
3cd8a4
* Fri Dec 27 2013 Daniel Mach <dmach@redhat.com> - 5.13-10
3cd8a4
- Mass rebuild 2013-12-27
3cd8a4
3cd8a4
* Thu Nov  7 2013 Ales Ledvinka <aledvink@redhat.com> - 5.13-9
3cd8a4
- SELinux: Add /usr/libexec/watchdog/scripts/ for test-bin and repair-bin to inherit from.
3cd8a4
- systemd: service with network available dependency
3cd8a4
- systemd: correct cgroup for realtime settings
3cd8a4
- Document SELinux and systemd.
3cd8a4
3cd8a4
* Thu Oct 24 2013 Ales Ledvinka <aledvink@redhat.com> - 5.13-5
3cd8a4
- SELinux: do not reopen descriptors for reading when only appending.
3cd8a4
3cd8a4
* Fri Aug  9 2013 Richard W.M. Jones <rjones@redhat.com> - 5.13-4
3cd8a4
- Fix License field (software is GPLv2+, not "GPL+").
3cd8a4
3cd8a4
* Thu Aug  8 2013 Richard W.M. Jones <rjones@redhat.com> - 5.13-3
3cd8a4
- Rename README.Fedora to README.RHEL on RHEL.
3cd8a4
3cd8a4
* Tue Jul 30 2013 Richard W.M. Jones <rjones@redhat.com> - 5.13-2
3cd8a4
- Enable /etc/watchdog.d directory for storing test binaries
3cd8a4
  (RHBZ#657750, RHBZ#831190).
3cd8a4
- Missing BR systemd-units.
3cd8a4
- Update .gitignore.
3cd8a4
- Drop Group line, not required by modern RPM.
3cd8a4
3cd8a4
* Thu May 16 2013 Richard W.M. Jones <rjones@redhat.com> - 5.13-1
3cd8a4
- New upstream version 5.13.
3cd8a4
- Various documentation fixes (RHBZ#948883).
3cd8a4
3cd8a4
* Fri Feb 15 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.12-3
3cd8a4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
3cd8a4
3cd8a4
* Sun Jul 22 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.12-2
3cd8a4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
3cd8a4
3cd8a4
* Fri Jul 06 2012 Richard W.M. Jones <rjones@redhat.com> - 5.12-1
3cd8a4
- New upstream version 5.12 (RHBZ#837949).
3cd8a4
- Bring specfile up to modern standards.
3cd8a4
- Remove commented sections from previous commit.
3cd8a4
- Remove both patches (equivalent changes now upstream).
3cd8a4
3cd8a4
* Wed Mar 14 2012 Jon Ciesla <limburgher@gmail.com> - 5.9-4
3cd8a4
- Migrate to systemd, BZ 661220.
3cd8a4
3cd8a4
* Sat Jan 14 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.9-3
3cd8a4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
3cd8a4
3cd8a4
* Mon Feb 07 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.9-2
3cd8a4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
3cd8a4
3cd8a4
* Mon Jan 17 2011 Richard W.M. Jones <rjones@redhat.com> - 5.9-1
3cd8a4
- New upstream version 5.9 (RHBZ#645541).
3cd8a4
- Package new wd_identify program.
3cd8a4
- Drop old cleanup patch, most of it is now upstream.
3cd8a4
- Add newer cleanup patch, sent upstream.
3cd8a4
- Fix some problems with the initscript (RHBZ#523391).
3cd8a4
- Add systemd service (file installed but not used) (RHBZ#661220).
3cd8a4
3cd8a4
* Wed Jan 13 2010 Richard W.M. Jones <rjones@redhat.com> - 5.5-7
3cd8a4
- Fix Source0 URL.
3cd8a4
3cd8a4
* Mon Jul 27 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.5-6
3cd8a4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
3cd8a4
3cd8a4
* Fri Mar 13 2009 Richard W.M. Jones <rjones@redhat.com> - 5.5-5
3cd8a4
- Updated the cleanup patch and sent upstream.
3cd8a4
3cd8a4
* Fri Mar 13 2009 Richard W.M. Jones <rjones@redhat.com> - 5.5-3
3cd8a4
- Remove dubious "cleanup-nfs" patch.
3cd8a4
3cd8a4
* Thu Mar  5 2009 Richard W.M. Jones <rjones@redhat.com> - 5.5-2
3cd8a4
- Use '-' in defattr line instead of explicit file mode.
3cd8a4
3cd8a4
* Thu Feb 26 2009 Richard W.M. Jones <rjones@redhat.com> - 5.5-1
3cd8a4
- New upstream version 5.5.
3cd8a4
- Prepared the package for Fedora review.
3cd8a4
3cd8a4
* Mon Jun 11  2007 Lon Hohberger <lhh@redhat.com> - 5.3.1-7
3cd8a4
- Rebuild for RHEL5 Update 1 - Resolves: 227401
3cd8a4
3cd8a4
* Wed May 30  2007 Konrad Rzeszutek <konradr@redhat.com> - 5.3.1-6
3cd8a4
- Fixed the init script file.
3cd8a4
3cd8a4
* Tue May 29  2007 Konrad Rzeszutek <konradr@redhat.com> - 5.3.1-5
3cd8a4
- Fixed a compile warning in nfsmount_xdr file.
3cd8a4
3cd8a4
* Wed May 23  2007 Konrad Rzeszutek <konradr@redhat.com> - 5.3.1-4
3cd8a4
- Fixed rpmlint warnings.
3cd8a4
3cd8a4
* Wed May 16  2007 Konrad Rzeszutek <konradr@redhat.com> - 5.3.1-3
3cd8a4
- Changes to spec, init script and README file per Carol Hebert recommendation.
3cd8a4
3cd8a4
* Thu Apr 19  2007 Konrad Rzeszutek <konradr@redhat.com> - 5.3.1-2
3cd8a4
- Added README.watchdog.ipmi
3cd8a4
3cd8a4
* Mon Apr 16  2007 Konrad Rzeszutek <konradr@redhat.com> - 5.3.1-1
3cd8a4
- Initial copy.