[Pkg-sysvinit-commits] r931 - in sysvinit/trunk/debian: .
initscripts initscripts/etc/init.d initscripts/lib/init
Petter Reinholdtsen
pere at costa.debian.org
Sat Sep 16 09:03:27 UTC 2006
Author: pere
Date: 2006-09-16 09:03:26 +0000 (Sat, 16 Sep 2006)
New Revision: 931
Modified:
sysvinit/trunk/debian/changelog
sysvinit/trunk/debian/initscripts/etc/init.d/bootclean
sysvinit/trunk/debian/initscripts/etc/init.d/bootmisc.sh
sysvinit/trunk/debian/initscripts/etc/init.d/mountkernfs.sh
sysvinit/trunk/debian/initscripts/etc/init.d/mtab.sh
sysvinit/trunk/debian/initscripts/etc/init.d/umountfs
sysvinit/trunk/debian/initscripts/etc/init.d/umountnfs.sh
sysvinit/trunk/debian/initscripts/lib/init/mount-functions.sh
sysvinit/trunk/debian/initscripts/postinst
Log:
* Mount /var/run/ as tmpfs in mountkernfs.sh, to have some place to
write state information very early in the boot, and thus avoid a
lot of cludges in scripts running before partitions are checked
and mounted. Mount /var/lock/ as tmpfs to avoid having to clean
it during boot, and to have some place to store locks for the
things running before partitions are checked and mounted.
Packages need to create the directories they expect to find in
these directories from now on. Patch from Scott James Remnant and
Ubuntu.
Modified: sysvinit/trunk/debian/changelog
===================================================================
--- sysvinit/trunk/debian/changelog 2006-09-16 07:47:52 UTC (rev 930)
+++ sysvinit/trunk/debian/changelog 2006-09-16 09:03:26 UTC (rev 931)
@@ -9,6 +9,15 @@
* Split killall5, last, lastb, mesg and pidof out of the sysvinit
package into a new sysvinit-utils package to make it easier to
replace sysvinit. (Closes: #385722)
+ * Mount /var/run/ as tmpfs in mountkernfs.sh, to have some place to
+ write state information very early in the boot, and thus avoid a
+ lot of cludges in scripts running before partitions are checked
+ and mounted. Mount /var/lock/ as tmpfs to avoid having to clean
+ it during boot, and to have some place to store locks for the
+ things running before partitions are checked and mounted.
+ Packages need to create the directories they expect to find in
+ these directories from now on. Patch from Scott James Remnant and
+ Ubuntu.
-- Petter Reinholdtsen <pere at debian.org> Thu, 14 Sep 2006 15:13:40 +0200
Modified: sysvinit/trunk/debian/initscripts/etc/init.d/bootclean
===================================================================
--- sysvinit/trunk/debian/initscripts/etc/init.d/bootclean 2006-09-16 07:47:52 UTC (rev 930)
+++ sysvinit/trunk/debian/initscripts/etc/init.d/bootclean 2006-09-16 09:03:26 UTC (rev 931)
@@ -2,7 +2,7 @@
#
# bootclean
#
-# Clean /tmp, /var/run and /var/lock
+# Clean /tmp
#
# DO NOT RUN AFTER S:55bootmisc.sh and do not run this script directly
# in runlevel S. Instead write an initscript to call it.
@@ -116,54 +116,12 @@
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_failure_msg "bootclean: Failure cleaning /var/lock."
- else
- log_action_end_msg 1 "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_failure_msg "bootclean: Failure cleaning /var/run."
- else
- log_action_end_msg 1 "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 || exit 1
which xargs >/dev/null 2>&1 || exit 1
# If there are flag files that have not been created by root
# then remove them
-for D in /tmp /var/run /var/lock
+for D in /tmp
do
if [ -f $D/.clean ]
then
@@ -179,11 +137,9 @@
fi
done
-[ -f /tmp/.clean ] && [ -f /var/run/.clean ] && [ -f /var/lock/.clean ] && exit 0
+[ -f /tmp/.clean ] && exit 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
Modified: sysvinit/trunk/debian/initscripts/etc/init.d/bootmisc.sh
===================================================================
--- sysvinit/trunk/debian/initscripts/etc/init.d/bootmisc.sh 2006-09-16 07:47:52 UTC (rev 930)
+++ sysvinit/trunk/debian/initscripts/etc/init.d/bootmisc.sh 2006-09-16 09:03:26 UTC (rev 931)
@@ -68,7 +68,7 @@
# Remove bootclean's flag files.
# Don't run bootclean again after this!
- rm -f /tmp/.clean /var/run/.clean /var/lock/.clean
+ rm -f /tmp/.clean
}
case "$1" in
Modified: sysvinit/trunk/debian/initscripts/etc/init.d/mountkernfs.sh
===================================================================
--- sysvinit/trunk/debian/initscripts/etc/init.d/mountkernfs.sh 2006-09-16 07:47:52 UTC (rev 930)
+++ sysvinit/trunk/debian/initscripts/etc/init.d/mountkernfs.sh 2006-09-16 09:03:26 UTC (rev 931)
@@ -31,6 +31,10 @@
domount sysfs "" /sys sysfs -onodev,noexec,nosuid
fi
+ # Mount /var/run and /var/lock as tmpfs.
+ domount tmpfs "" /var/run varrun -omode=0755,nodev,noexec,nosuid
+ domount tmpfs "" /var/lock varlock -omode=1777,nodev,noexec,nosuid
+
#
# Mount usbfs/usbdevfs if /proc/bus/usb is present.
#
Modified: sysvinit/trunk/debian/initscripts/etc/init.d/mtab.sh
===================================================================
--- sysvinit/trunk/debian/initscripts/etc/init.d/mtab.sh 2006-09-16 07:47:52 UTC (rev 930)
+++ sysvinit/trunk/debian/initscripts/etc/init.d/mtab.sh 2006-09-16 09:03:26 UTC (rev 931)
@@ -111,9 +111,11 @@
# S02mountkernfs.sh
domtab proc /proc "proc" -onodev,noexec,nosuid
if grep -E -qs "sysfs\$" /proc/filesystems
- then
+ then
domtab sysfs /sys "sys" -onodev,noexec,nosuid
fi
+ domtab tmpfs /var/run "varrun" -omode=0755,nodev,noexec,nosuid
+ domtab tmpfs /var/lock "varlock" -omode=1777,nodev,noexec,nosuid
if [ -d /proc/bus/usb ]
then
domtab usbfs /proc/bus/usb "procbususb"
Modified: sysvinit/trunk/debian/initscripts/etc/init.d/umountfs
===================================================================
--- sysvinit/trunk/debian/initscripts/etc/init.d/umountfs 2006-09-16 07:47:52 UTC (rev 930)
+++ sysvinit/trunk/debian/initscripts/etc/init.d/umountfs 2006-09-16 09:03:26 UTC (rev 931)
@@ -66,7 +66,7 @@
while read DEV MTPT FSTYPE REST
do
case "$MTPT" in
- /|/proc|/dev|/.dev|/dev/pts|/dev/shm|/proc/*|/sys)
+ /|/proc|/dev|/.dev|/dev/pts|/dev/shm|/proc/*|/sys|/var/run|/var/lock)
continue
;;
esac
Modified: sysvinit/trunk/debian/initscripts/etc/init.d/umountnfs.sh
===================================================================
--- sysvinit/trunk/debian/initscripts/etc/init.d/umountnfs.sh 2006-09-16 07:47:52 UTC (rev 930)
+++ sysvinit/trunk/debian/initscripts/etc/init.d/umountnfs.sh 2006-09-16 09:03:26 UTC (rev 931)
@@ -48,7 +48,7 @@
while read DEV MTPT FSTYPE OPTS REST
do
case "$MTPT" in
- /|/proc|/dev|/dev/pts|/dev/shm|/proc/*|/sys)
+ /|/proc|/dev|/dev/pts|/dev/shm|/proc/*|/sys|/var/run|/var/lock)
continue
;;
esac
Modified: sysvinit/trunk/debian/initscripts/lib/init/mount-functions.sh
===================================================================
--- sysvinit/trunk/debian/initscripts/lib/init/mount-functions.sh 2006-09-16 07:47:52 UTC (rev 930)
+++ sysvinit/trunk/debian/initscripts/lib/init/mount-functions.sh 2006-09-16 09:03:26 UTC (rev 931)
@@ -113,12 +113,35 @@
mount -n -t $FSTYPE $OPTS $5 $DEVNAME $MTPT
}
+#
+# Preserve /var/run and /var/lock mountpoints
+#
pre_mountall ()
{
- :
+ # We may end up mounting something over top of /var, either directly
+ # or because /var is a symlink to something that's mounted. So keep
+ # copies of the /var/run and /var/lock mounts elsewhere on the root
+ # filesystem so they can be moved back.
+ mkdir /dev/shm/var.run /dev/shm/var.lock
+ mount -n --bind /var/run /dev/shm/var.run
+ mount -n --bind /var/lock /dev/shm/var.lock
}
+#
+# Restore /var/run and /var/lock mountpoints
+#
post_mountall ()
{
- :
+ # Make sure the new filesystem has a /var/run and /var/lock
+ [ -d /var/run ] || mkdir /var/run
+ [ -d /var/lock ] || mkdir /var/lock
+
+ # Move the mountpoints back. Fortunately mount seems to not care
+ # if these are the same thing (ie. /var didn't get changed) so we
+ # do this regardless
+ mount -n --move /dev/shm/var.run /var/run
+ mount -n --move /dev/shm/var.lock /var/lock
+
+ # Clean up after ourselves
+ rmdir /dev/shm/var.run /dev/shm/var.lock
}
Modified: sysvinit/trunk/debian/initscripts/postinst
===================================================================
--- sysvinit/trunk/debian/initscripts/postinst 2006-09-16 07:47:52 UTC (rev 930)
+++ sysvinit/trunk/debian/initscripts/postinst 2006-09-16 09:03:26 UTC (rev 931)
@@ -154,6 +154,58 @@
done
#
+# Create /var/run and /var/lock
+#
+if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-22"
+then
+ # We need to quickly bind / to another location so we can make them
+ # just in case /var is a mountpoint or a symlink to one.
+ mkdir /.root
+ mount -n --bind / /.root
+
+ mkdir -p /.root/var/run /.root/var/lock
+
+ umount /.root
+ rmdir /.root
+fi
+
+#
+# Mount /var/run and /var/lock
+#
+if [ "$PREV_VER" ] && dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-22"
+then
+ # Make /var/run a tmpfs, and move everything onto it. This will
+ # probably break a few running things. If already a tmpfs, try
+ # cleaning up the one underneath
+ mkdir /tmp/.var.run
+ if mountpoint -q /var/run; then
+ mount -n --move /var/run /tmp/.var.run
+ else
+ mount -n -t tmpfs varrun /tmp/.var.run
+ (cd /var/run && find -print0 | cpio -p0dm /tmp/.var.run) 2>/dev/null || true
+ fi
+ find /var/run ! -type d -exec rm -f -- {} \; || true
+ mount -n --move /tmp/.var.run /var/run
+ rmdir /tmp/.var.run
+
+ # And do the same for /var/lock
+ mkdir /tmp/.var.lock
+ if mountpoint -q /var/lock; then
+ mount -n --move /var/lock /tmp/.var.lock
+ else
+ mount -n -t tmpfs varlock /tmp/.var.lock
+ (cd /var/lock && find -print0 | cpio -p0dm /tmp/.var.lock) 2>/dev/null || true
+ fi
+ find /var/lock ! -type d -exec rm -f -- {} \; || true
+ mount -n --move /tmp/.var.lock /var/lock
+ rmdir /tmp/.var.lock
+
+ if [ -x /usr/share/update-notifier/notify-reboot-required ]; then
+ /usr/share/update-notifier/notify-reboot-required
+ fi
+fi
+
+#
# Create initial log files
#
[ "$PREV_VER" ] || chmod 755 /var/log/fsck || :
More information about the Pkg-sysvinit-commits
mailing list