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

pere at users.alioth.debian.org pere at users.alioth.debian.org
Sun Sep 10 17:54:07 UTC 2006


Author: pere
Date: Sun Sep 10 17:54:07 2006
New Revision: 197

URL: http://svn.debian.org/wsvn/initscripts-ng/?sc=1&rev=197
Log:
  * Try to make update-bootsystem-insserv more robust on restores.
    Move conversion logs and related files to /var/lib/insserv.

Added:
    trunk/src/insserv/debian/insserv.dirs
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=197&op=diff
==============================================================================
--- trunk/src/insserv/debian/changelog (original)
+++ trunk/src/insserv/debian/changelog Sun Sep 10 17:54:07 2006
@@ -14,6 +14,8 @@
   * Correct override file for hotplut, it should stop before $local_fs.
   * Modify patch 31_debian_conf to also list ifupdown as part of the
     $network facility, to make $network available in runlevel 0 and 6.
+  * Try to make update-bootsystem-insserv more robust on restores.
+    Move conversion logs and related files to /var/lib/insserv.
 
  -- Petter Reinholdtsen <pere at debian.org>  Sat,  9 Sep 2006 20:32:28 +0200
 

Added: trunk/src/insserv/debian/insserv.dirs
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/insserv.dirs?rev=197&op=file
==============================================================================
--- trunk/src/insserv/debian/insserv.dirs (added)
+++ trunk/src/insserv/debian/insserv.dirs Sun Sep 10 17:54:07 2006
@@ -1,0 +1,3 @@
+/var/lib/insserv
+/usr/share/insserv/overrides
+/usr/sbin

Modified: trunk/src/insserv/debian/insserv.postinst
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/insserv.postinst?rev=197&op=diff
==============================================================================
--- trunk/src/insserv/debian/insserv.postinst (original)
+++ trunk/src/insserv/debian/insserv.postinst Sun Sep 10 17:54:07 2006
@@ -28,38 +28,45 @@
     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)
 
 	# Only enable this code if environment variable
 	# BAD_INSSERV_HACKER=true is set
-	[ true = "$BAD_INSSERV_HACKER" ] || break
-
-	db_get insserv/enable || true
-	if [ true = "$RET" ] && [ ! -f $flagfile ]; then
-	    # 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
-		: # 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."
+        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
+	    elif [ true != "$RET" ] && [ -f $flagfile ] ; then
+		disable_insserv
 	    fi
-	elif [ true != "$RET" ] && [ -f $flagfile ] ; then # Disable it
-	    # 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
 	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=197&op=diff
==============================================================================
--- trunk/src/insserv/debian/update-bootsystem-insserv (original)
+++ trunk/src/insserv/debian/update-bootsystem-insserv Sun Sep 10 17:54:07 2006
@@ -8,15 +8,17 @@
 set -e
 
 now=`date +%Y%m%dT%H%M`
-logdir=/var/log
-backupfile="$logdir/insserv-bootscripts-$now.tar.gz"
-logfile="$logdir/insserv-run-$now.log"
+logdir=/var/lib/insserv
+backupfile="$logdir/bootscripts-$now.tar.gz"
+listfile="$logdir/bootscripts-$now-after.list"
+logfile="$logdir/run-$now.log"
+flagfile="$logdir/using-insserv"
 
 # Make sure insserv is in path
 PATH=/sbin:$PATH
 
 convert_rc_s_to_k() {
-  runlevel=$1 # Use level N to disable on all levels
+  runlevel=$1
   for link in $(cd $target/etc/rc$runlevel.d; ls S* || true); do
       set `echo $link|sed "s%S\(..\)\(.*\)%\1 \2%"`
       seq=$1
@@ -26,14 +28,41 @@
 }
 
 if [ restore = "$1" ] ; then
-    for backup in $logdir/insserv-bootscripts-*.tar.gz ; do
-	file=$backup
+    if [ ! -f $flagfile ] ; then
+	echo "error: The boot system is not currently converted to insserv."
+	echo "error: Flag file $flagfile is missing."
+	echo "error: Unable to remove the use of insserv."
+	exit 1
+    fi
+
+    # Check if there has been changes, or if it is safe to restore
+    # from backup
+
+    # Pick the last list of symlinks.
+    for file in $logdir/bootscripts-*-after.list ; do
+	listfile=$file
     done
-    if [ -f "$file" ] ; then
-	(cd /etc; rm -rf init.d rc*.d; tar zxf $file)
-	echo "info: successfully restored backup of init.d scripts"
+    ls /etc/init.d /etc/rc*.d > "$logdir/current.list"
+
+    # If the rc.d scripts order look like it did when we converted, it
+    # is safe to restore.
+    if [ -f $listfile ] && cmp $logdir/current.list $listfile ; then
+	rm "$logdir/current.list"
+	echo "info: Restoring using backed up copy of init.d/ and rc*.d/."
+	for backup in $logdir/bootscripts-*.tar.gz ; do
+	    backupfile=$backup
+	done
+	if [ -f "$backupfile" ] ; then
+	    (cd /etc; rm -rf init.d rc*.d; tar zxf $backupfile)
+	    echo "info: successfully restored backup of init.d scripts"
+	    rm $flagfile
+	else
+	    echo "error: Unable to locate backup file"
+	    exit 1
+	fi
     else
-	echo "error: Unable to locate backup file"
+	rm "$logdir/current.list"
+	echo "error: Unable to restore the boot sequence.  Invalid backup."
 	exit 1
     fi
 else
@@ -59,7 +88,11 @@
 	insserv -v
     ) > $logfile 2>&1
 
+    echo "info: Recording new boot sequence in $listfile"
+    ls /etc/init.d /etc/rc*.d > $listfile
+
     echo "info: Use '$0 restore' to restore the old boot sequence."
+    touch $flagfile
 fi
 
 exit 0




More information about the Initscripts-ng-commits mailing list