Bug 53992 - ups stuff still fails 'cause it's not mounted anymore
Summary: ups stuff still fails 'cause it's not mounted anymore
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Raw Hide
Classification: Retired
Component: initscripts   
(Show other bugs)
Version: 1.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Bill Nottingham
QA Contact: Brock Organ
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-09-25 04:48 UTC by j. alan eldridge
Modified: 2014-03-17 02:23 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-04-28 19:11:05 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

Description j. alan eldridge 2001-09-25 04:49:00 UTC
Description of Problem:

I made the patch (rewrote) so that it's not as complex. It's still invasive, but it's 
all localized to 3 places now.

See what you think, anyway. It'd be nice if something like this actually went in, 
otherwise the ups won't get shut off. (I assume that anyone who's got a UPS 
also has partitioned /usr separate from /, as a matter of level of sophistication.)

--8<-----------------------------------------------------------------------------
--- halt.or     Tue Sep  4 23:18:34 2001
+++ halt        Mon Sep 24 19:42:04 2001
@@ -30,6 +30,61 @@
        awk '{ if ($3 ~ /^proc$/ && $2 !~ /^\/proc/) print $2; }' /proc/mounts
 }

+MODEL=
+
+POWERDOWNFLAG=
+DO_UPS_SHUTDOWN=
+
+_check_ups_shutdown() {
+    test -n "$MODEL" || {
+        ups_config=/etc/sysconfig/ups
+        test -r $ups_config || return 1
+        . $ups_config || return 1
+    }
+    test -n "$POWERDOWNFLAG" || {
+        ups_monconfig=/etc/ups/upsmon.conf
+        test -r $ups_monconfig || return 1
+        eval `grep -w ^POWERDOWNFLAG $ups_monconfig | tr -s '[:blank:]' '='`
+    }
+    test "$command" = "halt"   \
+        -a -n "$MODEL"                 \
+        -a -n "$POWERDOWNFLAG" \
+        -a -f "$POWERDOWNFLAG" \
+        -a -n "$DEVICE"        \
+        -a -c "$DEVICE"        \
+        -a "$SERVER" = "yes"   \
+        -a "$MODEL" != "NONE"  \
+        || return 1
+
+    rm -f $POWERDOWNFLAG
+    return 0
+}
+
+
+check_ups_shutdown() {
+    if test -z "$DO_UPS_SHUTDOWN"; then
+        _check_ups_shutdown; DO_UPS_SHUTDOWN=$?
+    fi
+    return $DO_UPS_SHUTDOWN
+}
+
+prepare_ups_shutdown() {
+    # added root@wwweasel
+    # if UPS initiated this shutdown, copy UPS driver to /
+    # so we have it after the file systems are unmounted ...
+    test -x /usr/bin/$MODEL    \
+        && /bin/cp -af /usr/bin/$MODEL /$MODEL 2>/dev/null \
+        && test -x "/$MODEL"   \
+        && MODEL=/$MODEL
+    test $? -eq 0 || {
+        test -n "$POWERDOWNFLAG" && rm -f $POWERDOWNFLAG; false
+    }
+}
+
+do_ups_shutdown() {
+    unset LOCALE; $MODEL -k $DEVICE
+}
+
 # See how we were called.
 case "$0" in
   *halt)
@@ -117,6 +172,9 @@

 runcmd $"Syncing hardware clock to system time" /sbin/hwclock 
$CLOCKFLAGS

+# prepare for UPS shutdown if needed
+check_ups_shutdown && runcmd $"Preparing for UPS shutdown" 
prepare_ups_shutdown+
 # Turn off swap, then unmount file systems.
 SWAPS=`awk '! /^Filename/ { print $1 }' /proc/swaps`
 [ -n "$SWAPS" ] && runcmd $"Turning off swap: " swapoff $SWAPS
@@ -197,11 +255,6 @@
  HALTARGS="$HALTARGS -p"
 fi

-if [ "$command" = halt ] ; then
-    if [ -r /etc/ups/upsmon.conf -a -f /etc/killpower -a -f /etc/sysconfig/ups
] ; then
-        . /etc/sysconfig/ups
-        [ "$SERVER" = "yes" -a "$MODEL" != "NONE" -a -n "$MODEL" -a -n 
"$DEVICE" ] && $MODEL -k $DEVICE
-    fi
-fi
+check_ups_shutdown && do_ups_shutdown

 eval $command $HALTARGS
--8<------------------------------------------------------------------------------




Version-Release number of selected component (if applicable):


How Reproducible:


Steps to Reproduce:
1. 
2. 
3. 

Actual Results:


Expected Results:


Additional Information:

Comment 1 j. alan eldridge 2001-09-25 04:50:11 UTC
BTW thank you for the great job of getting ext2 references out of halt. It makes all of 
us who use SGI XFS *very* happy. Thank you thank you thank you.

Comment 2 Bill Nottingham 2005-04-28 19:11:05 UTC
These are in /sbin now, so this shouldn't be an issue.


Note You need to log in before you can comment on or make changes to this bug.