diff options
author | Bill Nottingham <notting@redhat.com> | 2001-09-21 15:58:58 +0000 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 2001-09-21 15:58:58 +0000 |
commit | 8efba0500dd67a6bfe3b0a30a64061cf585dd293 (patch) | |
tree | 373025715db82c1a3de82efb0b137d0dca6357e7 | |
parent | 11f176d4896e418b12da2cb9c9d420390cd16cdc (diff) | |
download | initscripts-8efba0500dd67a6bfe3b0a30a64061cf585dd293.tar initscripts-8efba0500dd67a6bfe3b0a30a64061cf585dd293.tar.gz initscripts-8efba0500dd67a6bfe3b0a30a64061cf585dd293.tar.bz2 initscripts-8efba0500dd67a6bfe3b0a30a64061cf585dd293.tar.xz initscripts-8efba0500dd67a6bfe3b0a30a64061cf585dd293.zip |
Backport some fixes from the 7.2 branch:
- unmounting of loopback devices
- unmounting of /initrd
- don't blow up on ext3/reiserfs in /etc/init.d/halt
- module alias determination fixes
- quota tweaks
-rwxr-xr-x | rc.d/init.d/functions | 3 | ||||
-rwxr-xr-x | rc.d/init.d/halt | 32 | ||||
-rwxr-xr-x | rc.d/init.d/netfs | 8 | ||||
-rwxr-xr-x | rc.d/init.d/network | 2 | ||||
-rwxr-xr-x | rc.d/rc | 10 | ||||
-rwxr-xr-x | rc.d/rc.sysinit | 117 |
6 files changed, 116 insertions, 56 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions index ee2704c4..605f74d5 100755 --- a/rc.d/init.d/functions +++ b/rc.d/init.d/functions @@ -92,7 +92,8 @@ daemon() { shift 2 ;; --check=?*) - base=${1#--user=} + base=${1#--check=} + gotbase="yes" shift ;; --user) diff --git a/rc.d/init.d/halt b/rc.d/init.d/halt index 501ed0d3..be328d0c 100755 --- a/rc.d/init.d/halt +++ b/rc.d/init.d/halt @@ -25,6 +25,11 @@ runcmd() { echo } +halt_get_remaining() { + awk '!/(^#|proc|loopfs|autofs|^none|^\/dev\/root| \/ )/ {print $2}' /proc/mounts + awk '{ if ($3 ~ /^proc$/ && $2 !~ /^\/proc/) print $2; }' /proc/mounts +} + # See how we were called. case "$0" in *halt) @@ -84,7 +89,7 @@ if [ -f /etc/sysconfig/clock ]; then fi CLOCKDEF="" -CLOCKFLAGS="--systohc" +CLOCKFLAGS="$CLOCKFLAGS --systohc" case "$UTC" in yes|true) @@ -123,6 +128,7 @@ SWAPS=`awk '! /^Filename/ { print $1 }' /proc/swaps` # Unmount file systems, killing processes if we have to. # Unmount loopback stuff first remaining=`awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts` +devremaining=`awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $1}' /proc/mounts` [ -n "$remaining" ] && { sig= retry=3 @@ -131,9 +137,14 @@ remaining=`awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/moun if [ "$retry" -lt 3 ]; then runcmd $"Unmounting loopback filesystems (retry):" umount $remaining else - runcmd $"Unmounting loobpack filesystems: " umount $remaining + runcmd $"Unmounting loopback filesystems: " umount $remaining fi + for dev in $devremaining ; do + losetup $dev > /dev/null 2>&1 && \ + runcmd $"Detaching loopback device $dev: " losetup -d $device + done remaining=`awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts` + devremaining=`awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $1}' /proc/mounts` [ -z "$remaining" ] && break /sbin/fuser -k -m $sig $remaining >/dev/null sleep 5 @@ -144,33 +155,34 @@ remaining=`awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/moun sig= retry=3 -remaining=`awk '!/(^#|proc|loopfs|autofs|^none|^\/dev\/root| \/ )/ {print $2}' /proc/mounts` +remaining=`halt_get_remaining | sort -r` + while [ -n "$remaining" -a "$retry" -gt 0 ] do if [ "$retry" -lt 3 ]; then - LANG=C runcmd $"Unmounting file systems (retry): " umount -a -f -t noproc + LANG=C runcmd $"Unmounting file systems (retry): " umount -f $remaining else - LANG=C runcmd $"Unmounting file systems: " umount -a -f -t noproc + LANG=C runcmd $"Unmounting file systems: " umount -f $remaining fi sleep 2 - remaining=`awk '!/(^#|proc|loopfs|autofs|^none|^\/dev\/root| \/ )/ {print $2}' /proc/mounts` + remaining=`halt_get_remaining | sort -r` [ -z "$remaining" ] && break /sbin/fuser -k -m $sig $remaining >/dev/null sleep 5 retry=$(($retry-1)) sig=-9 done - [ -f /proc/bus/usb/devices ] && umount /proc/bus/usb +# Try them all, one last time. +umount -a -f + # Remount read only anything that's left mounted. #echo $"Remounting remaining filesystems (if any) readonly" -mount | awk '/ext2/ { print $3 }' | while read line; do +mount | awk '/( \/ |^\/dev\/root)/ { print $3 }' | while read line; do mount -n -o ro,remount $line done -runcmd $"Unmounting proc file system: " umount /proc - # Now halt or reboot. echo $"$message" if [ -f /fastboot ]; then diff --git a/rc.d/init.d/netfs b/rc.d/init.d/netfs index 97a46d1b..adea6665 100755 --- a/rc.d/init.d/netfs +++ b/rc.d/init.d/netfs @@ -20,7 +20,7 @@ fi . /etc/sysconfig/network # Check that networking is up. -[ ${NETWORKING} = "no" ] && exit 0 +[ "${NETWORKING}" = "no" ] && exit 0 NFSFSTAB=`grep -v '^#' /etc/fstab | awk '{ if ($3 ~ /^nfs$/ && $4 !~ /noauto/) print $2}'` SMBFSTAB=`grep -v '^#' /etc/fstab | awk '{ if ($3 ~ /^smbfs$/ && $4 !~ /noauto/) print $2}'` @@ -45,6 +45,7 @@ case "$1" in stop) # Unmount loopback stuff first remaining=`awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts` + devremaining=`awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $1}' /proc/mounts` [ -n "$remaining" ] && { sig= retry=3 @@ -55,7 +56,12 @@ case "$1" in else action $"Unmounting loopback filesystems: " umount $remaining fi + for dev in $devremaining ; do + losetup $dev >/dev/null 2>&1 && \ + action $"Detaching loopback device $dev: " losetup -d $dev + done remaining=`awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts` + devremaining=`awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $1}' /proc/mounts` [ -z "$remaining" ] && break /sbin/fuser -k -m $sig $remaining >/dev/null sleep 5 diff --git a/rc.d/init.d/network b/rc.d/init.d/network index 5407b878..fd69537a 100755 --- a/rc.d/init.d/network +++ b/rc.d/init.d/network @@ -31,7 +31,7 @@ fi # If IPv6 is explicitly configured, make sure it's available. if [ "$NETWORKING_IPV6" = "yes" ]; then - alias=`modprobe -c | grep net-pf-10 | awk '{ print $3 }'` + alias=`modprobe -c | awk '/^alias net-pf-10 / { print $3 }'` if [ "$alias" != "ipv6" -a ! -f /proc/net/if_inet6 ]; then echo "alias net-pf-10 ipv6" >> /etc/modules.conf fi @@ -98,7 +98,15 @@ if [ -d /etc/rc$runlevel.d ]; then # Bring the subsystem up. if egrep -q "(daemon |action )" $i ; then - $i start + if [ "$subsys" = "halt" -o "$subsys" = "reboot" ]; then + unset LANG + unset LC_ALL + unset TEXTDOMAIN + unset TEXTDOMAINDIR + exec $i start + else + $i start + fi else if [ "$subsys" = "halt" -o "$subsys" = "reboot" -o "$subsys" = "single" -o "$subsys" = "local" ]; then if [ "$subsys" = "halt" -o "$subsys" = "reboot" ]; then diff --git a/rc.d/rc.sysinit b/rc.d/rc.sysinit index 2df69bcd..36027ed8 100755 --- a/rc.d/rc.sysinit +++ b/rc.d/rc.sysinit @@ -52,6 +52,12 @@ fi action $"Mounting proc filesystem: " mount -n -t proc /proc /proc +# Unmount the initrd, if necessary +if grep -q /initrd /proc/mounts ; then + action $"Unmounting initrd: " umount /initrd + /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1 +fi + # Configure kernel parameters action $"Configuring kernel parameters: " sysctl -e -p /etc/sysctl.conf @@ -73,11 +79,11 @@ if [ -f /etc/sysconfig/clock ]; then fi CLOCKDEF="" -CLOCKFLAGS="--hctosys" +CLOCKFLAGS="$CLOCKFLAGS --hctosys" case "$UTC" in yes|true) - CLOCKFLAGS="$CLOCKFLAGS -u"; + CLOCKFLAGS="$CLOCKFLAGS --utc"; CLOCKDEF="$CLOCKDEF (utc)"; ;; no|false) @@ -88,13 +94,13 @@ esac case "$ARC" in yes|true) - CLOCKFLAGS="$CLOCKFLAGS -A"; + CLOCKFLAGS="$CLOCKFLAGS --arc"; CLOCKDEF="$CLOCKDEF (arc)"; ;; esac case "$SRM" in yes|true) - CLOCKFLAGS="$CLOCKFLAGS -S"; + CLOCKFLAGS="$CLOCKFLAGS --srm"; CLOCKDEF="$CLOCKDEF (srm)"; ;; esac @@ -154,12 +160,12 @@ action $"Setting hostname ${HOSTNAME}: " hostname ${HOSTNAME} # Initialize USB controller and HID devices usb=0 if ! grep -iq "nousb" /proc/cmdline 2>/dev/null && ! grep -q "usb" /proc/devices 2>/dev/null ; then - aliases=`/sbin/modprobe -c | egrep -s "^alias[[:space:]]+usb-controller" | awk '{ print $3 }'` + aliases=`/sbin/modprobe -c | awk '/^alias usb-controller/ { print $3 }'` if [ -n "$aliases" -a "$aliases" != "off" ] ; then modprobe usbcore action $"Mounting USB filesystem: " mount -t usbdevfs usbdevfs /proc/bus/usb for alias in $aliases ; do - action $"Initializing USB controller ($alias): " modprobe $alias + [ "$alias" != "off" ] && action $"Initializing USB controller ($alias): " modprobe $alias done [ $? -eq 0 -a -n "$aliases" ] && usb=1 fi @@ -255,20 +261,20 @@ _ROOT_HAS_QUOTA=$? if [ X"$_RUN_QUOTACHECK" = X1 -a \ "$_ROOT_HAS_QUOTA" -a \ -x /sbin/quotacheck ]; then - if [ -x /sbin/convertquota ]; then - if [ -f /quota.user ]; then - action $"Converting old user quota files: " \ - /sbin/convertquota -u / && rm -f /quota.user - fi - if [ -f /quota.group ]; then - action $"Converting old group quota files: " \ - /sbin/convertquota -g / && rm -f /quota.group - fi - fi - action $"Checking root filesystem quotas: " /sbin/quotacheck -n / + if [ -x /sbin/convertquota ]; then + if [ -f /quota.user ]; then + action $"Converting old user quota files: " \ + /sbin/convertquota -u / && rm -f /quota.user + fi + if [ -f /quota.group ]; then + action $"Converting old group quota files: " \ + /sbin/convertquota -g / && rm -f /quota.group + fi + fi + action $"Checking root filesystem quotas: " /sbin/quotacheck -nug / fi -# check for arguments +# check for arguments passed from kernel if grep -iq nopnp /proc/cmdline >/dev/null 2>&1 ; then PNP= @@ -395,12 +401,12 @@ fi # Load sound modules iff they need persistent DMA buffers if grep -q "options sound dmabuf=1" /etc/modules.conf 2>/dev/null ; then RETURN=0 - alias=`/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound[[:space:]]+" | awk '{ print $3 }'` + alias=`/sbin/modprobe -c | awk '/^alias sound / { print $3 }'` if [ -n "$alias" -a "$alias" != "off" ] ; then action $"Loading sound module ($alias): " modprobe $alias RETURN=$? fi - alias=`/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound-slot-0[[:space:]]+" | awk '{ print $3 }'` + alias=`/sbin/modprobe -c | awk '/^alias sound-slot-0 / { print $3 }'` if [ -n "$alias" -a "$alias" != "off" ] ; then action $"Loading sound module ($alias): " modprobe $alias RETURN=$? @@ -439,16 +445,24 @@ if [ -f /proc/mdstat -a -f /etc/raidtab ]; then rc=0 - for i in `grep "^raiddev" /etc/raidtab | awk '{print $2}'` + for i in `grep "^[^*]*raiddev" /etc/raidtab | awk '{print $2}'` do RAIDDEV=`basename $i` RAIDSTAT=`grep "^$RAIDDEV : active" /proc/mdstat` if [ -z "$RAIDSTAT" ]; then - # Try raidstart first...if that fails then + # First scan the /etc/fstab for the "noauto"-flag + # for this device. If found, skip the initialization + # for it to avoid dropping to a shell on errors. + # If not, try raidstart...if that fails then # fall back to raidadd, raidrun. If that # also fails, then we drop to a shell RESULT=1 - if [ -x /sbin/raidstart ]; then + NOAUTO=`grep "^$i" /etc/fstab | grep -c "noauto"` + if [ $NOAUTO -gt 0 ]; then + RESULT=0 + RAIDDEV="$RAIDDEV(skipped)" + fi + if [ $RESULT -gt 0 -a -x /sbin/raidstart ]; then /sbin/raidstart $i RESULT=$? fi @@ -532,25 +546,26 @@ fi # filesystems are NOT unmounted in single user mode. action $"Mounting local filesystems: " mount -a -t nonfs,smbfs,ncpfs +# check remaining quotas other than root if [ X"$_RUN_QUOTACHECK" = X1 -a -x /sbin/quotacheck ]; then - if [ -x /sbin/convertquota ]; then - # try to convert old quotas - for mountpt in `cat /etc/mtab | awk '$4 ~ /quota/{print $2}'`; do - if [ -f "$mountpt/quota.user" ]; then - action $"Converting old user quota files: " \ - /sbin/convertquota -u $mountpt && \ - rm -f $mountpt/quota.user - fi - if [ -f "$mountpt/quota.group" ]; then - action $"Converting old group quota files: " \ - /sbin/convertquota -g $mountpt && \ - rm -f $mountpt/quota.group - fi - done - fi - action $"Checking local filesystem quotas: " /sbin/quotacheck -aR + if [ -x /sbin/convertquota ]; then + # try to convert old quotas + for mountpt in `cat /etc/mtab | awk '$4 ~ /quota/{print $2}'`; do + if [ -f "$mountpt/quota.user" ]; then + action $"Converting old user quota files: " \ + /sbin/convertquota -u $mountpt && \ + rm -f $mountpt/quota.user + fi + if [ -f "$mountpt/quota.group" ]; then + action $"Converting old group quota files: " \ + /sbin/convertquota -g $mountpt && \ + rm -f $mountpt/quota.group + fi + done + fi + action $"Checking local filesystem quotas: " /sbin/quotacheck -aRnug fi - + if [ -x /sbin/quotaon ]; then action $"Enabling local filesystem quotas: " /sbin/quotaon -aug fi @@ -571,6 +586,9 @@ if [ -f /.unconfigured ]; then if [ -x /usr/sbin/timeconfig ]; then /usr/sbin/timeconfig fi + if [ -x /usr/sbin/kbdconfig ]; then + /usr/sbin/kbdconfig + fi if [ -x /usr/sbin/authconfig ]; then /usr/sbin/authconfig --nostart fi @@ -605,6 +623,7 @@ for afile in /var/lock/* /var/run/*; do rm -f $afile fi done +rm -f /var/lib/rpm/__db* # Reset pam_console permissions [ -x /sbin/pam_console_apply ] && /sbin/pam_console_apply -r @@ -664,7 +683,8 @@ fi # Adjust symlinks as necessary in /boot to keep system services from # spewing messages about mismatched System maps and so on. -if [ -L /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then +if [ -L /boot/System.map -a -r /boot/System.map-`uname -r` -a \ + ! /boot/System.map -ef /boot/System.map-`uname -r` ] ; then ln -s -f System.map-`uname -r` /boot/System.map fi if [ ! -e /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then @@ -673,7 +693,20 @@ fi # Now that we have all of our basic modules loaded and the kernel going, # let's dump the syslog ring somewhere so we can find it later -dmesg > /var/log/dmesg +dmesg -s 131072 > /var/log/dmesg +# Also keep kernel symbols around in case we need them for debugging +i=5 +while [ $i -ge 0 ] ; do + if [ -f /var/log/ksyms.$i ] ; then + mv /var/log/ksyms.$i /var/log/ksyms.$(($i+1)) + fi + i=$(($i-1)) +done +(/bin/date; + /bin/uname -a; + /bin/cat /proc/cpuinfo; + /bin/cat /proc/modules; + /bin/cat /proc/ksyms) >/var/log/ksyms.0 sleep 1 kill -TERM `/sbin/pidof getkey` >/dev/null 2>&1 } & |