Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/etc/rc.d Adapt /etc/rc.d/swap1 and swap2 scripts to the new ...



details:   https://anonhg.NetBSD.org/src/rev/7dec6f5a6517
branches:  trunk
changeset: 747615:7dec6f5a6517
user:      apb <apb%NetBSD.org@localhost>
date:      Thu Sep 24 16:45:48 2009 +0000

description:
Adapt /etc/rc.d/swap1 and swap2 scripts to the new meaning of
exit status 2 from swapctl(8).

diffstat:

 etc/rc.d/swap1 |   9 ++++++---
 etc/rc.d/swap2 |  23 ++++++++++++++++-------
 2 files changed, 22 insertions(+), 10 deletions(-)

diffs (83 lines):

diff -r eef266dc883c -r 7dec6f5a6517 etc/rc.d/swap1
--- a/etc/rc.d/swap1    Thu Sep 24 16:15:20 2009 +0000
+++ b/etc/rc.d/swap1    Thu Sep 24 16:45:48 2009 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: swap1,v 1.10 2009/04/21 16:08:57 joerg Exp $
+# $NetBSD: swap1,v 1.11 2009/09/24 16:45:48 apb Exp $
 #
 
 # PROVIDE: localswap
@@ -18,8 +18,11 @@
 #
 swap1_start()
 {
+       # Treat exit status 2 from swapctl(8) as successful; it means
+       # "no error, but no suitable swap devices were configured".
+       #
        if ! checkyesno no_swap; then
-               swapctl -A -t blk
+               swapctl -A -t blk || [ $? = 2 ]
        fi
 }
 
@@ -29,7 +32,7 @@
 {
        if checkyesno swapoff || [ -n "$rc_force" ]; then
                echo "Removing block-type swap devices"
-               swapctl -U -t blk
+               swapctl -U -t blk || [ $? = 2 ]
        fi
 }
 
diff -r eef266dc883c -r 7dec6f5a6517 etc/rc.d/swap2
--- a/etc/rc.d/swap2    Thu Sep 24 16:15:20 2009 +0000
+++ b/etc/rc.d/swap2    Thu Sep 24 16:45:48 2009 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: swap2,v 1.7 2004/08/13 18:08:03 mycroft Exp $
+# $NetBSD: swap2,v 1.8 2009/09/24 16:45:48 apb Exp $
 #
 
 # PROVIDE: nonlocalswap
@@ -14,23 +14,32 @@
 
 swap2_start()
 {
-       #       "Critical" file systems are now mounted.  Go ahead and swap
-       #       to files now, since they will be residing in the critical file
-       #       systems (or, at least, they should be...).
-       #       Check for no swap, and warn about it unless that is desired.
+       # "Critical" file systems are now mounted.  Go ahead and swap
+       # to files now, since they will be residing in the critical file
+       # systems (or, at least, they should be...).
+       #
+       # Treat exit status 2 from swapctl(8) as successful; it means
+       # "no error, but no suitable swap devices were configured".
        #
-       swapctl -A -t noblk;
+       # Check for no swap, and warn about it unless that is desired.
+       #
+       local es
+       swapctl -A -t noblk
+       es=$?
+       [ $es = 2 ] && es=0
        if ! checkyesno no_swap; then
                if swapctl -s | grep "no swap devices configured" > /dev/null;
                then
                        warn "No swap space configured!"
+                       es=1
                fi
        fi
+       return $es
 }
 
 #              Remove all non-block-type swap devices
 #
-stop_cmd="swapctl -U -t noblk"
+stop_cmd="swapctl -U -t noblk || [ $? = 2 ]"
 
 load_rc_config swap
 run_rc_command "$1"



Home | Main Index | Thread Index | Old Index