[Pkg-sysvinit-commits] r560 - in sysvinit/trunk/debian: . initscripts initscripts/etc/init.d

Thomas Hood jdthood-guest at costa.debian.org
Tue Jan 10 12:12:45 UTC 2006


Author: jdthood-guest
Date: 2006-01-10 12:12:44 +0000 (Tue, 10 Jan 2006)
New Revision: 560

Added:
   sysvinit/trunk/debian/initscripts/etc/init.d/bootclean
   sysvinit/trunk/debian/initscripts/postrm
Removed:
   sysvinit/trunk/debian/initscripts/etc/init.d/bootclean.sh
Modified:
   sysvinit/trunk/debian/changelog
   sysvinit/trunk/debian/initscripts/conffiles
   sysvinit/trunk/debian/initscripts/etc/init.d/mountall-bootclean.sh
   sysvinit/trunk/debian/initscripts/etc/init.d/mountnfs-bootclean.sh
   sysvinit/trunk/debian/initscripts/postinst
   sysvinit/trunk/debian/rules
Log:
Transform bootclean.sh into bootclean.  Because bootclean.sh needed to create a subshell, this doesn't add any more proceses.

Modified: sysvinit/trunk/debian/changelog
===================================================================
--- sysvinit/trunk/debian/changelog	2006-01-10 08:43:52 UTC (rev 559)
+++ sysvinit/trunk/debian/changelog	2006-01-10 12:12:44 UTC (rev 560)
@@ -1,10 +1,10 @@
-sysvinit (2.86.ds1-10~4) unstable; urgency=low 
+sysvinit (2.86.ds1-10~5) unstable; urgency=low 
 
   [ Thomas Hood ]
   * rcS(5): Reword
-  * bootclean.sh: Handle return status and messages more carefully;
-    print diagnostic messages on failures; eliminate some subshells;
-    add comments
+  * bootclean: Adapt from old bootclean.sh; handle return status more
+    carefully; print diagnostic messages on failures; eliminate use
+    if subshells; add comments
 
  -- Thomas Hood <jdthood at yahoo.co.uk>  Mon,  9 Jan 2006 14:16:02 +0100
 

Modified: sysvinit/trunk/debian/initscripts/conffiles
===================================================================
--- sysvinit/trunk/debian/initscripts/conffiles	2006-01-10 08:43:52 UTC (rev 559)
+++ sysvinit/trunk/debian/initscripts/conffiles	2006-01-10 12:12:44 UTC (rev 560)
@@ -1,4 +1,4 @@
-/etc/init.d/bootclean.sh
+/etc/init.d/bootclean
 /etc/init.d/bootlogd
 /etc/init.d/stop-bootlogd
 /etc/init.d/stop-bootlogd-single

Added: sysvinit/trunk/debian/initscripts/etc/init.d/bootclean
===================================================================
--- sysvinit/trunk/debian/initscripts/etc/init.d/bootclean	2006-01-10 08:43:52 UTC (rev 559)
+++ sysvinit/trunk/debian/initscripts/etc/init.d/bootclean	2006-01-10 12:12:44 UTC (rev 560)
@@ -0,0 +1,173 @@
+#!/bin/sh
+#
+# bootclean
+#
+# Clean /tmp, /var/run and /var/lock
+#
+# DO NOT RUN AFTER S:55bootmisc.sh and do not run this script directly
+# in runlevel S. Instead write an initscript to call it.
+#
+
+. /lib/init/vars.sh
+
+. /lib/lsb/init-functions
+
+# Should be called outside verbose message block
+mkflagfile()
+{
+	# Prevent symlink attack  (See #264234.)
+	[ -L "$1" ] && log_warning_msg "bootclean: Deleting symbolic link '$1'."
+	rm -f "$1" || { log_failure_msg "bootclean: Failure deleting '$1'." ; return 1 ; }
+	# No user processes should be running, so no one should be able to introduce
+	# a symlink here.  Just to be sure, set noclobber.
+	set -o noclobber
+	:> "$1" || { log_failure_msg "bootclean: Failure creating '$1'." ; return 1 ; }
+	return 0
+}
+
+clean_tmp() {
+	cd /tmp || { log_failure_msg "bootclean: Could not cd to /tmp." ; return 1 ; }
+
+	if [ ! "$TMPTIME" ]
+	then
+		log_warning_msg "Using default TMPTIME 0."
+		TMPTIME=0
+	fi
+
+	# Don't clean /tmp if TMPTIME < 0 or "infinite"
+	case "$TMPTIME" in
+	  -*|infinite|infinity)
+		return 0
+		;;
+	esac
+
+	# Wipe /tmp, but exclude system files.
+	# Note that files _in_ lost+found _are_ deleted.
+	#
+	# If $TMPTIME is set to 0, we do not use any ctime expression
+	# at all, so we can also delete files with timestamps
+	# in the future!
+	#
+	if [ "$TMPTIME" = 0 ] 
+	then
+		TEXPR=""
+		DEXPR=""
+	else
+		TEXPR="-mtime +$TMPTIME -ctime +$TMPTIME -atime +$TMPTIME"
+		DEXPR="-mtime +$TMPTIME -ctime +$TMPTIME"
+	fi
+
+	EXCEPT='! -name .
+		! ( -path ./lost+found -uid 0 )
+		! ( -path ./quota.user -uid 0 )
+		! ( -path ./aquota.user -uid 0 )
+		! ( -path ./quota.group -uid 0 )
+		! ( -path ./aquota.group -uid 0 )
+		! ( -path ./.journal -uid 0 )
+		! ( -path ./.clean -uid 0 )
+		! ( -path './...security*' -uid 0 )'
+
+	#
+	# Only clean out /tmp if it is world-writable. This ensures
+	# it really is a/the temp directory we're cleaning.
+	#
+	[ "$(find . -maxdepth 0 -perm -002)" = "." ] || return 0
+
+	mkflagfile /tmp/.clean || return 1
+
+	[ "$VERBOSE" != no ] && log_action_begin_msg "Cleaning /tmp"
+	report_err()
+	{
+		if [ "$VERBOSE" != no ]
+		then
+			log_action_end_msg 1 "bootclean: Failure cleaning /tmp"
+		else
+			log_failure_msg "bootclean: Failure cleaning /tmp."
+		fi
+	}
+	# First remove all old files...
+	# (Use xargs here so that only one additional process gets created)
+	find . -depth -xdev $TEXPR $EXCEPT ! -type d \
+		-print0 | xargs -0r rm -f -- \
+		|| { report_err ; return 1 ; }
+	# ...and then all empty directories
+	find . -depth -xdev $DEXPR $EXCEPT -type d -empty \
+		-print0 | xargs -0r rmdir --ignore-fail-on-non-empty -- \
+		|| { report_err ; return 1 ; }
+	rm -f .X*-lock \
+		|| { report_err ; return 1 ; }
+	[ "$VERBOSE" != no ] && log_action_end_msg 0
+	return 0
+}
+
+clean_lock() {
+	cd /var/lock || { log_failure_msg "bootclean: Could not cd to /var/lock." ; return 1 ; }
+
+	[ "$VERBOSE" != no ] && log_action_begin_msg "Cleaning /var/lock"
+	report_err()
+	{
+		if [ "$VERBOSE" != no ]
+		then
+			log_action_end_msg 1 "bootclean: Failure cleaning /var/lock"
+		else
+			log_failure_msg "bootclean: Failure cleaning /var/lock."
+		fi
+	}
+	find . ! -type d \
+		-print0 | xargs -0r rm -f -- \
+		|| { report_err ; return 1 ; }
+	[ "$VERBOSE" != no ] && log_action_end_msg 0
+	mkflagfile /var/lock/.clean || return 1
+	return 0
+}
+
+clean_run() {
+	cd /var/run || { log_action_end_msg 1 "bootclean: Could not cd to /var/run." ; return 1 ; }
+
+	[ "$VERBOSE" != no ] && log_action_begin_msg "Cleaning /var/run"
+	report_err()
+	{
+		if [ "$VERBOSE" != no ]
+		then
+			log_action_end_msg 1 "bootclean: Failure cleaning /var/run"
+		else
+			log_failure_msg "bootclean: Failure cleaning /var/run."
+		fi
+	}
+	find . ! -xtype d ! -name utmp ! -name innd.pid \
+		-print0 | xargs -0r rm -f -- \
+		|| { report_err ; return 1 ; }
+	[ "$VERBOSE" != no ] && log_action_end_msg 0
+	mkflagfile /var/run/.clean || return 1
+	return 0
+}
+
+which find >/dev/null 2>&1 || return 1
+which xargs >/dev/null 2>&1 || return 1
+
+# If there are flag files that have not been created by root
+# then remove them
+for D in /tmp /var/run /var/lock
+do
+	if [ -f $D/.clean ]
+	then
+		which stat >/dev/null 2>&1 && cleanuid="$(stat -c %u $D/.clean)"
+		# Poor's man stat %u, since stat (and /usr) might not be
+		# available in some bootup stages
+		[ "$cleanuid" ] || cleanuid="$(find $D/.clean -printf %U)"
+		[ "$cleanuid" ] || { log_failure_msg "bootclean: Could not stat '$D/.clean'." ; return 1 ; }
+		if [ "$cleanuid" -ne 0 ]
+		then
+			rm -f $D/.clean || { log_failure_msg "bootclean: Could not delete '$D/.clean'." ; return 1 ; }
+		fi
+	fi
+done
+
+[ -f /tmp/.clean ] && [ -f /var/run/.clean ] && [ -f /var/lock/.clean ] && return 0
+
+ES=0
+[ -d /tmp ] && ! [ -f /tmp/.clean ] && { clean_tmp || ES=1 ; }
+[ -d /var/run ] && ! [ -f /var/run/.clean ] && { clean_run || ES=1 ; }
+[ -d /var/lock ] && ! [ -f /var/lock/.clean ] && { clean_lock || ES=1 ; }
+exit $ES
+


Property changes on: sysvinit/trunk/debian/initscripts/etc/init.d/bootclean
___________________________________________________________________
Name: svn:executable
   + *

Deleted: sysvinit/trunk/debian/initscripts/etc/init.d/bootclean.sh
===================================================================
--- sysvinit/trunk/debian/initscripts/etc/init.d/bootclean.sh	2006-01-10 08:43:52 UTC (rev 559)
+++ sysvinit/trunk/debian/initscripts/etc/init.d/bootclean.sh	2006-01-10 12:12:44 UTC (rev 560)
@@ -1,174 +0,0 @@
-#
-# bootclean.sh
-#
-# Functions to clean /tmp, /var/run and /var/lock
-#
-# Environment variables must be set by the caller.
-# /lib/lsb/init-functions must be sourced by the caller.
-# DO NOT RUN THESE FUNCTIONS AFTER S:55bootmisc.sh!
-
-# Should be called outside verbose message block
-clean_mkflagfile()
-{
-	# Prevent symlink attack  (See #264234.)
-	[ -L "$1" ] && log_warning_msg "bootclean.sh: Deleting symbolic link '$1'."
-	rm -f "$1" || { log_failure_msg "bootclean.sh: Failure deleting '$1'." ; return 1 ; }
-	# No user processes should be running, so no one should be able to introduce
-	# a symlink here.  Just to be sure, set noclobber.
-	set -o noclobber
-	:> "$1" || { log_failure_msg "bootclean.sh: Failure creating '$1'." ; return 1 ; }
-	return 0
-}
-
-clean_tmp() {
-	cd /tmp || { log_failure_msg "bootclean.sh: Could not cd to /tmp." ; return 1 ; }
-
-	if [ ! "$TMPTIME" ]
-	then
-		log_warning_msg "Using default TMPTIME 0."
-		TMPTIME=0
-	fi
-
-	# Don't clean /tmp if TMPTIME < 0 or "infinite"
-	case "$TMPTIME" in
-	  -*|infinite|infinity)
-		return 0
-		;;
-	esac
-
-	# Wipe /tmp, but exclude system files.
-	# Note that files _in_ lost+found _are_ deleted.
-	#
-	# If $TMPTIME is set to 0, we do not use any ctime expression
-	# at all, so we can also delete files with timestamps
-	# in the future!
-	#
-	if [ "$TMPTIME" = 0 ] 
-	then
-		TEXPR=""
-		DEXPR=""
-	else
-		TEXPR="-mtime +$TMPTIME -ctime +$TMPTIME -atime +$TMPTIME"
-		DEXPR="-mtime +$TMPTIME -ctime +$TMPTIME"
-	fi
-
-	EXCEPT='! -name .
-		! ( -path ./lost+found -uid 0 )
-		! ( -path ./quota.user -uid 0 )
-		! ( -path ./aquota.user -uid 0 )
-		! ( -path ./quota.group -uid 0 )
-		! ( -path ./aquota.group -uid 0 )
-		! ( -path ./.journal -uid 0 )
-		! ( -path ./.clean -uid 0 )
-		! ( -path './...security*' -uid 0 )'
-
-	#
-	# Only clean out /tmp if it is world-writable. This ensures
-	# it really is a/the temp directory we're cleaning.
-	#
-	[ "$(find . -maxdepth 0 -perm -002)" = "." ] || return 0
-
-	clean_mkflagfile /tmp/.clean || return 1
-
-	[ "$VERBOSE" != no ] && log_action_begin_msg "Cleaning /tmp"
-	report_err()
-	{
-		if [ "$VERBOSE" != no ]
-		then
-			log_action_end_msg 1 "bootclean.sh: Failure cleaning /tmp"
-		else
-			log_failure_msg "bootclean.sh: Failure cleaning /tmp."
-		fi
-	}
-	# First remove all old files...
-	# (Use xargs here so that only one additional process gets created)
-	find . -depth -xdev $TEXPR $EXCEPT ! -type d \
-		-print0 | xargs -0r rm -f -- \
-		|| { report_err ; return 1 ; }
-	# ...and then all empty directories
-	find . -depth -xdev $DEXPR $EXCEPT -type d -empty \
-		-print0 | xargs -0r rmdir --ignore-fail-on-non-empty -- \
-		|| { report_err ; return 1 ; }
-	rm -f .X*-lock \
-		|| { report_err ; return 1 ; }
-	[ "$VERBOSE" != no ] && log_action_end_msg 0
-	return 0
-}
-
-clean_lock() {
-	cd /var/lock || { log_failure_msg "bootclean.sh: Could not cd to /var/lock." ; return 1 ; }
-
-	[ "$VERBOSE" != no ] && log_action_begin_msg "Cleaning /var/lock"
-	report_err()
-	{
-		if [ "$VERBOSE" != no ]
-		then
-			log_action_end_msg 1 "bootclean.sh: Failure cleaning /var/lock"
-		else
-			log_failure_msg "bootclean.sh: Failure cleaning /var/lock."
-		fi
-	}
-	find . ! -type d \
-		-print0 | xargs -0r rm -f -- \
-		|| { report_err ; return 1 ; }
-	[ "$VERBOSE" != no ] && log_action_end_msg 0
-	clean_mkflagfile /var/lock/.clean || return 1
-	return 0
-}
-
-clean_run() {
-	cd /var/run || { log_action_end_msg 1 "bootclean.sh: Could not cd to /var/run." ; return 1 ; }
-
-	[ "$VERBOSE" != no ] && log_action_begin_msg "Cleaning /var/run"
-	report_err()
-	{
-		if [ "$VERBOSE" != no ]
-		then
-			log_action_end_msg 1 "bootclean.sh: Failure cleaning /var/run"
-		else
-			log_failure_msg "bootclean.sh: Failure cleaning /var/run."
-		fi
-	}
-	find . ! -xtype d ! -name utmp ! -name innd.pid \
-		-print0 | xargs -0r rm -f -- \
-		|| { report_err ; return 1 ; }
-	[ "$VERBOSE" != no ] && log_action_end_msg 0
-	clean_mkflagfile /var/run/.clean || return 1
-	return 0
-}
-
-bootclean() {
-	which find >/dev/null 2>&1 || return 1
-	which xargs >/dev/null 2>&1 || return 1
-
-	# If there are flag files that have not been created by root
-	# then remove them
-	for cleandir in /tmp /var/run /var/lock
-	do
-		if [ -f $cleandir/.clean ]
-		then
-			which stat >/dev/null 2>&1 && cleanuid="$(stat -c %u $cleandir/.clean)"
-			# Poor's man stat %u, since stat (and /usr) might not be
-			# available in some bootup stages
-			[ "$cleanuid" ] || cleanuid="$(find $cleandir/.clean -printf %U)"
-			[ "$cleanuid" ] || { log_failure_msg "bootclean.sh: Could not stat '$cleandir/.clean'." ; return 1 ; }
-			if [ "$cleanuid" -ne 0 ]
-			then
-				rm -f $cleandir/.clean || { log_failure_msg "bootclean.sh: Could not delete '$cleandir/.clean'." ; return 1 ; }
-			fi
-		fi
-	done
-
-	[ -f /tmp/.clean ] && [ -f /var/run/.clean ] && [ -f /var/lock/.clean ] && return 0
-
-	# Run in subshell in order to restore environment before returning
-	(
-		ES=0
-		[ -d /tmp ] && ! [ -f /tmp/.clean ] && { clean_tmp || ES=1 ; }
-		[ -d /var/run ] && ! [ -f /var/run/.clean ] && { clean_run || ES=1 ; }
-		[ -d /var/lock ] && ! [ -f /var/lock/.clean ] && { clean_lock || ES=1 ; }
-		exit $ES  # from subshell
-	) || return 1
-	return 0
-}
-

Modified: sysvinit/trunk/debian/initscripts/etc/init.d/mountall-bootclean.sh
===================================================================
--- sysvinit/trunk/debian/initscripts/etc/init.d/mountall-bootclean.sh	2006-01-10 08:43:52 UTC (rev 559)
+++ sysvinit/trunk/debian/initscripts/etc/init.d/mountall-bootclean.sh	2006-01-10 12:12:44 UTC (rev 560)
@@ -9,12 +9,6 @@
 # Description:
 ### END INIT INFO
 
-NAME=mountall-bootclean
-. /lib/init/vars.sh
-
-. /etc/init.d/bootclean.sh
-. /lib/lsb/init-functions
-
 case "$1" in
   start|"")
 	# Clean /tmp, /var/lock, /var/run

Modified: sysvinit/trunk/debian/initscripts/etc/init.d/mountnfs-bootclean.sh
===================================================================
--- sysvinit/trunk/debian/initscripts/etc/init.d/mountnfs-bootclean.sh	2006-01-10 08:43:52 UTC (rev 559)
+++ sysvinit/trunk/debian/initscripts/etc/init.d/mountnfs-bootclean.sh	2006-01-10 12:12:44 UTC (rev 560)
@@ -9,12 +9,6 @@
 # Description:
 ### END INIT INFO
 
-NAME=mountnfs-bootclean
-. /lib/init/vars.sh
-
-. /etc/init.d/bootclean.sh
-. /lib/lsb/init-functions
-
 case "$1" in
   start|"")
 	# Clean /tmp, /var/lock, /var/run

Modified: sysvinit/trunk/debian/initscripts/postinst
===================================================================
--- sysvinit/trunk/debian/initscripts/postinst	2006-01-10 08:43:52 UTC (rev 559)
+++ sysvinit/trunk/debian/initscripts/postinst	2006-01-10 12:12:44 UTC (rev 560)
@@ -131,6 +131,16 @@
 updatercd stop-bootlogd          start 99 2 3 4 5 .
 
 #
+# Indicate that bootclean.sh is no longer used
+# (It has been replaced by bootclean.)
+#
+if [ -f /etc/init.d/bootclean.sh ]
+then
+	chmod ugo-x /etc/init.d/bootclean.sh
+	mv /etc/init.d/bootclean.sh /etc/init.d/bootclean.sh.dpkg-old
+fi
+
+#
 # Remove scripts that were left behind by older glibc (<< 2.3.2.ds1-12)
 # versions. We have the same functionality in mountvirtfs.
 #

Added: sysvinit/trunk/debian/initscripts/postrm
===================================================================
--- sysvinit/trunk/debian/initscripts/postrm	2006-01-10 08:43:52 UTC (rev 559)
+++ sysvinit/trunk/debian/initscripts/postrm	2006-01-10 12:12:44 UTC (rev 560)
@@ -0,0 +1,15 @@
+#! /bin/sh
+#
+# initscripts postrm
+#
+
+set -e
+ 
+case "$1" in
+  purge)
+	# Remove abandoned conffile
+	rm -f /etc/init.d/bootclean.sh /etc/init.d/bootclean.sh.dpkg-old
+	;;
+esac
+
+exit 0


Property changes on: sysvinit/trunk/debian/initscripts/postrm
___________________________________________________________________
Name: svn:executable
   + *

Modified: sysvinit/trunk/debian/rules
===================================================================
--- sysvinit/trunk/debian/rules	2006-01-10 08:43:52 UTC (rev 559)
+++ sysvinit/trunk/debian/rules	2006-01-10 12:12:44 UTC (rev 560)
@@ -117,7 +117,6 @@
 	cp -afv debian/initscripts/etc/* $(tmp)/etc
 	cp -afv debian/initscripts/lib/* $(tmp)/lib
 	chmod 755 $(tmp)/etc/init.d/[a-z]*
-	chmod 644 $(tmp)/etc/init.d/bootclean.sh
 	chmod 644 $(tmp)/lib/init/*.sh
 	chmod -R g-w $(tmp)
 	chown -R root.root $(tmp)
@@ -147,6 +146,7 @@
 	  $(tmp)$(doc)/initscripts/copyright
 	install -g root -m 755 debian/initscripts/preinst  $(tmp)/DEBIAN
 	install -g root -m 755 debian/initscripts/postinst $(tmp)/DEBIAN
+	install -g root -m 755 debian/initscripts/postrm $(tmp)/DEBIAN
 	install -g root -m 644 -o root debian/initscripts/conffiles \
 	  $(tmp)/DEBIAN/conffiles
 	dpkg-shlibdeps debian/readlink




More information about the Pkg-sysvinit-commits mailing list