Dr. Werner Fink 2014-01-14 18:31:08 +00:00 committed by Git OBS Bridge
parent 4bd2bdec68
commit 1639d113ed
6 changed files with 137 additions and 3 deletions

View File

@ -0,0 +1,90 @@
--- systemd-208/units/sigpwr.target
+++ systemd-208/units/sigpwr.target 2014-01-14 15:53:32.878735762 +0000
@@ -8,3 +8,5 @@
[Unit]
Description=Power Failure
Documentation=man:systemd.special(7)
+BindTo=powerfail.service
+DefaultDependencies=no
+RefuseManualStart=yes
--- systemd-208/units/powerfail.service
+++ systemd-208/units/powerfail.service 2014-01-14 16:11:41.802235712 +0000
@@ -0,0 +1,21 @@
+# This file is part of systemd.
+#
+# Copyright (c) 2014 SUSE LINUX Products GmbH, Germany.
+# Author: Werner Fink
+# Please send feedback to http://www.suse.de/feedback
+#
+# Description:
+#
+# Used to start the systemd-powerfail.service
+#
+
+[Unit]
+Description=powerfail handling
+BindTo=sigpwr.target
+DefaultDependencies=no
+RefuseManualStart=yes
+
+[Service]
+Type=oneshot
+ExecStart=/usr/lib/systemd/systemd-powerfail
+RemainAfterExit=false
--- systemd-208/man/systemd-powerfail.service.8
+++ systemd-208/man/systemd-powerfail.service.8 2014-01-14 18:22:21.286735810 +0000
@@ -0,0 +1,54 @@
+'\" t
+.TH "SYSTEMD\-POWERFAIL\&.SERVICE" "8" "" "systemd 208" "systemd-powerfail.service"
+.\" -----------------------------------------------------------------
+.\" * Define some portability stuff
+.\" -----------------------------------------------------------------
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.\" http://bugs.debian.org/507673
+.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.\" -----------------------------------------------------------------
+.\" * MAIN CONTENT STARTS HERE *
+.\" -----------------------------------------------------------------
+.SH "NAME"
+systemd-powerfail.service, systemd-powerfail \- Power Fail signal handling
+.SH "SYNOPSIS"
+.PP
+systemd\-powerfail\&.service
+.PP
+/usr/lib/systemd/systemd\-powerfail
+.SH "DESCRIPTION"
+.PP
+systemd\-powerfail
+is a system service that is used to evaulate the content of
+\fI/var/run/powerstatus\fR. Based on the content of this
+file:
+.IP F(AIL)
+Power is failing, UPS is providing the power. The
+systemd\-powerfail
+is now doing a timed shutdown.
+.IP O(K)
+The power has been restored, and pending shutdown
+will be cancled.
+.IP L(OW)
+The power is failing and the UPS has a low battery.
+The
+systemd\-powerfail
+is doing an immediate shutdown.
+.PP
+If \fI/var/run/powerstatus\fR doesn't exist or contains anything else then the letters
+F, O or L, systemd\-powerfail will behave as if it has read the letter F.
+.PP
+.SH "SEE ALSO"
+.PP
+\fBshutdown\fR(8),
+\fBpowerd\fR(8)

View File

@ -1,7 +1,7 @@
#
# spec file for package systemd-mini
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed

28
systemd-powerfail Normal file
View File

@ -0,0 +1,28 @@
#!/bin/bash
#
# /usr/lib/systemd/systemd-powerfail
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Germany.
# Author: Werner Fink
# Please send feedback to http://www.suse.de/feedback
#
# Description:
#
# Used to evaluate the status of /var/run/powerstatus
#
trap "echo" SIGINT SIGSEGV SIGTERM
POWERFAIL='THE POWER IS FAILED! SYSTEM GOING DOWN! PLEASE LOG OFF NOW!'
POWERFAILNOW='THE POWER IS FAILED! LOW BATTERY - EMERGENCY SYSTEM SHUTDOWN!'
POWERISBACK='THE POWER IS BACK'
typeset pwrstat=0
test -s /var/run/powerstatus && read pwrstat < /var/run/powerstatus
rm -f /var/run/powerstatus
case "$pwrstat" in
O*) exec /sbin/shutdown -c +0 "$POWERISBACK" ;;
L*) exec /sbin/shutdown -P +0 "$POWERFAILNOW" ;;
*) exec /sbin/shutdown -P +2 "$POWERFAIL" ;;
esac

View File

@ -1,7 +1,7 @@
#
# spec file for package systemd-rpm-macros
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Jan 14 18:28:09 UTC 2014 - werner@suse.de
- Add patch support-powerfail-with-powerstatus.patch and source
file systemd-powerfail to implement SIGPWR support with evaluation
of the file /var/run/powerstatus (bnc#737690)
-------------------------------------------------------------------
Fri Dec 20 12:06:18 UTC 2013 - werner@suse.de

View File

@ -1,7 +1,7 @@
#
# spec file for package systemd
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -112,6 +112,7 @@ Source8: systemd-journald.init
Source9: nss-myhostname-config
Source10: macros.systemd.upstream
Source11: after-local.service
Source12: systemd-powerfail
Source1060: boot.udev
Source1061: write_dev_root_rule
@ -271,6 +272,8 @@ Patch1013: U_logind_revert_lazy_session_activation_on_non_vt_seats.patch
Patch1014: 1014-journald-with-journaling-FS.patch
# PATCH-FIX-UPSTREAM build-sys-make-multi-seat-x-optional.patch
Patch1015: build-sys-make-multi-seat-x-optional.patch
# PATCH-FIX-SUSE support-powerfail-with-powerstatus.patch
Patch1016: support-powerfail-with-powerstatus.patch
%description
Systemd is a system and service manager, compatible with SysV and LSB
@ -553,6 +556,7 @@ cp %{SOURCE7} m4/
%patch1013 -p1
%patch1014 -p1
%patch1015 -p1
%patch1016 -p1
# ensure generate files are removed
rm -f units/emergency.service
@ -730,6 +734,11 @@ EOF
install -m 644 %{S:11} %{buildroot}/%{_prefix}/lib/systemd/system/
ln -s ../after-local.service %{buildroot}/%{_prefix}/lib/systemd/system/multi-user.target.wants/
# support for SIGPWR handling with /var/run/powerstatus of e.g. powerd
install -m 755 %{S:12} %{buildroot}/%{_prefix}/lib/systemd/
install -m 644 units/powerfail.service %{buildroot}/%{_prefix}/lib/systemd/system/
install -m 644 man/systemd-powerfail.service.8 %{buildroot}/%{_mandir}/man8/
%fdupes -s %{buildroot}%{_mandir}
# packaged in systemd-rpm-macros