Name: reboot-guard Version: 1.0.1 Release: 2%{?dist} BuildArch: noarch Group: System/Utilities License: GPLv3+ URL: "http://github.com/ryran/reboot-guard" Source0: https://github.com/ryran/reboot-guard/%{name}-%{version}.tar.gz Source1: rguard.sysconfig Patch0: rguard-sysconfig.patch BuildRequires: systemd Requires: python >= 2.7 Requires: systemd >= 219 Summary: Block systemd-initiated shutdown until configurable condition checks pass %description reboot-guard consists of a python executable (rguard) which can be run directly or launched as a systemd service. Command-line arguments can be used to define optional condition checks that must pass in order to allow reboot/poweroff/halt. As long as at least one condition check fails, shutdown is completely blocked. The default ExecStart line in the provided service unit blocks shutdown as long as it's running; however, this can of course be customized as desired. rguard can also be called directly with a -1/-0 option to execute a simple block/unblock operation and then exit. %prep %setup -q %patch0 -p1 -b .bkp %install # binary mkdir -p $RPM_BUILD_ROOT%{_sbindir} install -m 0755 -p rguard $RPM_BUILD_ROOT%{_sbindir}/rguard # systemd files mkdir -p $RPM_BUILD_ROOT%{_unitdir} install -m 0644 -p rguard.service $RPM_BUILD_ROOT%{_unitdir}/rguard.service # sysconfig file mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig install -m 0644 -p %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/rguard %clean rm -r -f "$RPM_BUILD_ROOT" %pre %post if [ $1 -eq 1 ]; then # Initial installation systemctl daemon-reload >/dev/null 2>&1 || : fi %preun if [ $1 -eq 0 ]; then # Package removal, not upgrade systemctl --no-reload disable rguard.service >/dev/null 2>&1 || : systemctl stop rguard.service >/dev/null 2>&1 || : fi %postun systemctl daemon-reload >/dev/null 2>&1 || : if [ $1 -ge 1 ] ; then # Package upgrade, not uninstall # Typical behavior for upgrade would be try-restart # systemctl try-restart rguard.service >/dev/null 2>&1 || : # Let's not do that by default though : fi %files %defattr(-,root,root,-) %doc LICENSE README.md %config(noreplace) %{_sysconfdir}/sysconfig/rguard %{_unitdir}/rguard.service %{_sbindir}/rguard %changelog * Mon Dec 03 2018 Aram Minasyan aram.minasyan@agilent.com - 1.0.1-2 - Configurable service/daemon from /etc/sysconfig * Wed Apr 26 2017 Ryan Sawhill Aroha 1.0.1-1 - Explicitly specify `python2` on shebang line #6 * Sat Apr 08 2017 Ryan Sawhill Aroha 1.0.0-1 - Change `Exiting due to -1 or -0 option` message to `INFO` loglevel #1 - Set a default `ExecStart=` in `rguard.service` that blocks shutdown #2 - rpm: add `systemctl` commands to rpm scriptlets like a normal package #3 - rpm: switch arch to x86_64 #4 * Wed Sep 02 2015 Ryan Sawhill Aroha 0.2.2-1 - Initial rpm build