[Initscripts-ng-commits] r411 - in /trunk/src/insserv/debian: changelog insserv.postinst update-bootsystem-insserv

pere at users.alioth.debian.org pere at users.alioth.debian.org
Wed Jan 2 14:02:51 UTC 2008


Author: pere
Date: Wed Jan  2 14:02:51 2008
New Revision: 411

URL: http://svn.debian.org/wsvn/initscripts-ng/?sc=1&rev=411
Log:
  * Move code to divert update-rc.d from postinst to
    update-bootsystem-insserv, to make sure both ways to activate
    insserv are equivalent.

Modified:
    trunk/src/insserv/debian/changelog
    trunk/src/insserv/debian/insserv.postinst
    trunk/src/insserv/debian/update-bootsystem-insserv

Modified: trunk/src/insserv/debian/changelog
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/changelog?rev=411&op=diff
==============================================================================
--- trunk/src/insserv/debian/changelog (original)
+++ trunk/src/insserv/debian/changelog Wed Jan  2 14:02:51 2008
@@ -10,6 +10,9 @@
     insserv more helpful, and make sure to report the output from
     update-bootsystem-insserv when refusing to switch to dependency
     based boot (Closes: #458683).
+  * Move code to divert update-rc.d from postinst to
+    update-bootsystem-insserv, to make sure both ways to activate
+    insserv are equivalent.
 
  -- Petter Reinholdtsen <pere at debian.org>  Tue,  1 Jan 2008 21:57:58 +0100
 

Modified: trunk/src/insserv/debian/insserv.postinst
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/insserv.postinst?rev=411&op=diff
==============================================================================
--- trunk/src/insserv/debian/insserv.postinst (original)
+++ trunk/src/insserv/debian/insserv.postinst Wed Jan  2 14:02:51 2008
@@ -7,54 +7,6 @@
 flagfile=/etc/update-rc.d-insserv
 package=insserv
 
-# Based on code from dash postinst
-check_divert() {
-    div=$(dpkg-divert --list $2)
-    distrib=${4:-$2.distrib}
-    case "$1" in
-    true)
-        if [ -z "$div" ]; then
-	    dpkg-divert --package $package --divert $distrib --add $2
-	    cp -dp $2 $distrib
-	    ln -sf $3 $2
-	fi
-	;;
-    false)
-        if [ -n "$div" ] && [ -z "${div%%*by $package}" ]; then
-	    mv $distrib $2
-	    dpkg-divert --remove $2
-	fi
-	;;
-    esac
-}
-
-enable_insserv() {
-    # Reorder the boot sequence, and divert update-rc.d if it worked
-    if update-bootsystem-insserv ; then
-	: # All OK
-	echo "success: Boot system successfully converted"
-	touch $flagfile
-
-        # Divert update-rc.d to update-rc.d-insserv
-	check_divert true /usr/sbin/update-rc.d \
-	    /usr/sbin/update-rc.d-insserv
-    else
-	echo "error: Unable to enable dependency based boot system."
-    fi
-}
-
-disable_insserv() {
-    echo "info: Disabling dependency based boot system"
-    # Undo divert
-    check_divert false /usr/sbin/update-rc.d \
-	/usr/sbin/update-rc.d-insserv
-
-    # Revert to old boot order if possible
-    update-bootsystem-insserv restore
-
-    rm -f $flagfile
-}
-
 case "$1" in
     configure)
 
@@ -63,9 +15,19 @@
         if [ true = "$BAD_INSSERV_HACKER" ] ; then
 	    db_get insserv/enable || true
 	    if [ true = "$RET" ] && [ ! -f $flagfile ]; then
-		enable_insserv # Enable it, as it was not enabled already
+		# Enable it, as it was not enabled already.
+		# Reorder the boot sequence, and divert update-rc.d if
+		# it worked
+		if update-bootsystem-insserv ; then
+		    echo "success: Boot system successfully converted"
+		    : # All OK
+		else
+		    echo "error: Unable to enable dependency based boot system."
+		fi
 	    elif [ true != "$RET" ] && [ -f $flagfile ] ; then
-		disable_insserv
+		echo "info: Disabling dependency based boot system"
+		# Revert to old boot system if possible
+		update-bootsystem-insserv restore
 	    fi
 	fi
 	;;

Modified: trunk/src/insserv/debian/update-bootsystem-insserv
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/update-bootsystem-insserv?rev=411&op=diff
==============================================================================
--- trunk/src/insserv/debian/update-bootsystem-insserv (original)
+++ trunk/src/insserv/debian/update-bootsystem-insserv Wed Jan  2 14:02:51 2008
@@ -13,6 +13,7 @@
 listfile="$logdir/bootscripts-$now-after.list"
 logfile="$logdir/run-$now.log"
 flagfile="$logdir/using-insserv"
+rcflagfile=/etc/update-rc.d-insserv
 
 # Make sure insserv is in path
 PATH=/sbin:$PATH
@@ -58,7 +59,35 @@
     done
 }
 
-if [ restore = "$1" ] ; then
+# Based on code from dash postinst
+check_divert() {
+    div=$(dpkg-divert --list $2)
+    distrib=${4:-$2.distrib}
+    case "$1" in
+    true)
+        if [ -z "$div" ]; then
+	    dpkg-divert --package $package --divert $distrib --add $2
+	    cp -dp $2 $distrib
+	    ln -sf $3 $2
+	fi
+	;;
+    false)
+        if [ -n "$div" ] && [ -z "${div%%*by $package}" ]; then
+	    mv $distrib $2
+	    dpkg-divert --remove $2
+	fi
+	;;
+    esac
+}
+
+deactivate_inserv() {
+    if [ -f $rcflagfile ] ; then
+        # Undo divert
+	check_divert false /usr/sbin/update-rc.d \
+	    /usr/sbin/update-rc.d-insserv
+	rm $rcflagfile
+    fi
+
     if [ ! -f $flagfile ] ; then
 	echo "error: The boot system is not currently converted to insserv."
 	echo "error: Flag file $flagfile is missing."
@@ -96,8 +125,11 @@
 	echo "error: Unable to restore the boot sequence.  Invalid backup."
 	echo "error: Trying to recover by reconfiguring all packages with init.d scripts."
 	regenerate_sysv_sequence
+	rm -f $flagfile
     fi
-else
+}
+
+activate_insserv() {
     # Refuse to convert when there are obsolete init.d scripts left
     # behind, as these tend to confuse the boot sequence.
     echo "info: Checking if it is safe to convert to dependency based boot."
@@ -143,6 +175,17 @@
 
     echo "info: Use '$0 restore' to restore the old boot sequence."
     touch $flagfile
+
+    # Divert update-rc.d to update-rc.d-insserv
+    check_divert true /usr/sbin/update-rc.d \
+	/usr/sbin/update-rc.d-insserv
+    touch $rcflagfile
+}
+
+if [ restore = "$1" ] ; then
+    deactivate_inserv
+else
+    activate_insserv
 fi
 
 exit 0




More information about the Initscripts-ng-commits mailing list