From f8ce1b187562b06bcc2f9acd4f55b82923cbce39 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Mon, 2 Apr 2001 20:17:15 +0000 Subject: do explicitly load usb-storage; it's the simplest solution for now fix /boot/kernel.h generation (#32081) tweak raid startup slightly to deal with /etc/raitab but no raid in the kernel (#25291) avoid some error messages from USB startup (#31040) run pam_console_apply on startup to reset permissions insert multiple USB controllers correctly mount usbdevfs before loading host controller module don't run isapnp on isapnp-enabled 2.4 kernels initialize multiple USB controllers if necessary disable hotplug if 'nomodules' is specified mon has a subdirectory in odd places as well. (#26924) do USB initialization even if we don't need to load a host-controller module (#26318) fix raid start if it's all modular, and no initrd (#25291) add sleep 1 to avoid race (#17842) add devfs to mtab (#20261) deal with new location of console-tools stuff turn on accounting at bootup use modprobe -c to handle possible conditional modules.conf constructs (#21283) don't exclude proc when you're doing mount -a -t nonfs... don't remount r/w if it is r/w (#12097) don't try and load fonts and keymaps on a serial console. Duh. --- rc.d/rc.sysinit | 115 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 84 insertions(+), 31 deletions(-) (limited to 'rc.d/rc.sysinit') diff --git a/rc.d/rc.sysinit b/rc.d/rc.sysinit index 0dfedcdc..d4b1f196 100755 --- a/rc.d/rc.sysinit +++ b/rc.d/rc.sysinit @@ -103,8 +103,9 @@ esac action "Setting clock $CLOCKDEF: `date`" date -# Load keymap -if [ -x /bin/loadkeys ]; then +if [ "`/sbin/consoletype`" == "vt" ]; then + # Load keymap + if [ -x /bin/loadkeys ]; then KEYTABLE= KEYMAP= if [ -f /etc/sysconfig/console/default.kmap ]; then @@ -113,7 +114,7 @@ if [ -x /bin/loadkeys ]; then if [ -f /etc/sysconfig/keyboard ]; then . /etc/sysconfig/keyboard fi - if [ -n "$KEYTABLE" -a -d "/usr/lib/kbd/keymaps" ]; then + if [ -n "$KEYTABLE" -a -d "/usr/lib/kbd/keymaps" -o -d "/lib/kbd/keymaps" ]; then KEYMAP=$KEYTABLE fi fi @@ -128,17 +129,20 @@ if [ -x /bin/loadkeys ]; then success "Loading default keymap" || failure "Loading default keymap" echo fi -fi + fi -# Load system font -if [ -x /sbin/setsysfont ]; then + # Load system font + if [ -x /sbin/setsysfont ]; then [ -f /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n if [ -f /etc/sysconfig/console/$SYSFONT.psf.gz -o \ -f /usr/lib/kbd/consolefonts/$SYSFONT.psf.gz -o \ -f /etc/sysconfig/console/$SYSFONT.gz -o \ - -f /usr/lib/kbd/consolefonts/$SYSFONT.gz ]; then + -f /usr/lib/kbd/consolefonts/$SYSFONT.gz -o \ + -f /lib/kbd/consolefonts/$SYSFONT.gz -o \ + -f /lib/kbd/consolefonts/$SYSFONT.psf.gz ]; then action "Setting default font ($SYSFONT): " /sbin/setsysfont fi + fi fi # Start up swapping. @@ -147,21 +151,37 @@ action "Activating swap partitions: " swapon -a # Set the hostname. action "Setting hostname ${HOSTNAME}: " hostname ${HOSTNAME} +# Set the NIS domain name +if [ -n "$NISDOMAIN" ]; then + action "Setting NIS domain name $NISDOMAIN: " domainname $NISDOMAIN +else + domainname "" +fi + # 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 - alias=`egrep -s "^alias[[:space:]]+usb-controller[[:space:]]+" /etc/modules.conf | awk '{ print $3 }'` - if [ -n "$alias" -a "$alias" != "off" ] ; then - action "Initializing USB controller ($alias): " modprobe $alias - [ $? -eq 0 ] && usb=1 + aliases=`/sbin/modprobe -c | egrep -s "^alias[[:space:]]+usb-controller" | awk '{ 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 + done + [ $? -eq 0 -a -n "$aliases" ] && usb=1 fi fi +if ! grep -iq "nousb" /proc/cmdline 2>/dev/null && grep -q "usb" /proc/devices 2>/dev/null ; then + usb=1 +fi + +needusbstorage= if [ $usb = "1" ]; then sleep 5 - action "Mounting USB filesystem: " mount -t usbdevfs usbdevfs /proc/bus/usb - mouseoutput=`cat /proc/bus/usb/devices|grep -E "^I.*Cls=03.*Prot=02"` - kbdoutput=`cat /proc/bus/usb/devices|grep -E "^I.*Cls=03.*Prot=01"` + mouseoutput=`cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02"` + kbdoutput=`cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01"` + needusbstorage=`cat /proc/bus/usb/devices 2>/dev/null|grep -e "^I.*Cls=08"` if [ -n "$kbdoutput" ] || [ -n "$mouseoutput" ]; then action "Initializing USB HID interface: " modprobe hid 2> /dev/null fi @@ -243,7 +263,7 @@ else fi # set up pnp -if [ -x /sbin/isapnp -a -f /etc/isapnp.conf ]; then +if [ -x /sbin/isapnp -a -f /etc/isapnp.conf -a ! -f /proc/isapnp ]; then if [ -n "$PNP" ]; then action "Setting up ISA PNP devices: " /sbin/isapnp /etc/isapnp.conf else @@ -252,7 +272,9 @@ if [ -x /sbin/isapnp -a -f /etc/isapnp.conf ]; then fi # Remount the root filesystem read-write. -action "Remounting root filesystem in read-write mode: " mount -n -o remount,rw / +state=`awk '/(^\/dev\/root| \/ )/ { print $4 }' /proc/mounts` +[ "$state" != "rw" ] && \ + action "Remounting root filesystem in read-write mode: " mount -n -o remount,rw / # Clear mtab >/etc/mtab @@ -260,10 +282,11 @@ action "Remounting root filesystem in read-write mode: " mount -n -o remount,rw # Remove stale backups rm -f /etc/mtab~ /etc/mtab~~ -# Enter root and /proc and /proc/bus/usb into mtab. +# Enter root, /proc and (potentially) /proc/bus/usb and devfs into mtab. mount -f / mount -f /proc [ -f /proc/bus/usb/devices ] && mount -f -t usbdevfs usbdevfs /proc/bus/usb +[ -e /dev/.devfsd ] && mount -f -t devfs devfs /dev # Turn on harddisk optimization if [ -f /etc/sysconfig/harddisks ] && [ -x /sbin/hdparm ]; then @@ -339,32 +362,36 @@ fi # # I think this now qualifies as over-engineered. RETURN=0 -alias=`egrep -s "^alias[[:space:]]+sound[[:space:]]+" /etc/modules.conf | awk '{ print $3 }'` +alias=`/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound[[:space:]]+" | awk '{ print $3 }'` if [ -n "$alias" -a "$alias" != "off" ] ; then action "Loading sound module ($alias): " modprobe $alias RETURN=$? fi -alias=`egrep -s "^alias[[:space:]]+sound-slot-0[[:space:]]+" /etc/modules.conf | awk '{ print $3 }'` +alias=`/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound-slot-0[[:space:]]+" | awk '{ print $3 }'` if [ -n "$alias" -a "$alias" != "off" ] ; then action "Loading sound module ($alias): " modprobe $alias RETURN=$? fi -alias=`egrep -s "^alias[[:space:]]+midi[[:space:]]+" /etc/modules.conf | awk '{ print $3 }'` +alias=`/sbin/modprobe -c | egrep -s "^alias[[:space:]]+midi[[:space:]]+" | awk '{ print $3 }'` if [ -n "$alias" -a "$alias" != "off" ]; then action "Loading midi module ($alias): " modprobe $alias fi # Load mixer settings -if grep -q "\(sparcaudio\|sound\)" /proc/devices 2>/dev/null && [ $RETURN -eq 0 -a -f /etc/.aumixrc -a -x /bin/aumix-minimal ]; then +if grep -q "\(sparcaudio\|sound\)" /proc/devices 2>/dev/null ; then + if [ $RETURN -eq 0 -a -f /etc/.aumixrc -a -x /bin/aumix-minimal ]; then action "Loading mixer settings: " /bin/aumix-minimal -f /etc/.aumixrc -L + fi fi if [ -f /proc/sys/kernel/modprobe ]; then if [ -n "$USEMODULES" ]; then sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1 + sysctl -w kernel.hotplug="/sbin/hotplug" >/dev/null 2>&1 else # We used to set this to NULL, but that causes 'failed to exec' messages" sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1 + sysctl -w kernel.hotplug="/bin/true" >/dev/null 2>&1 fi fi @@ -374,6 +401,10 @@ if [ -f /etc/rc.modules ]; then fi # Add raid devices +if [ ! -f /proc/mdstat ]; then + modprobe md >/dev/null 2>&1 +fi + if [ -f /proc/mdstat -a -f /etc/raidtab ]; then echo -n "Starting up RAID devices: " @@ -382,7 +413,7 @@ if [ -f /proc/mdstat -a -f /etc/raidtab ]; then for i in `grep "^raiddev" /etc/raidtab | awk '{print $2}'` do RAIDDEV=`basename $i` - RAIDSTAT=`grep "^$RAIDDEV : active" /proc/mdstat` + RAIDSTAT=`grep "^$RAIDDEV : active" /proc/mdstat` if [ -z "$RAIDSTAT" ]; then # Try raidstart first...if that fails then # fall back to raidadd, raidrun. If that @@ -470,12 +501,17 @@ fi # Mount all other filesystems (except for NFS and /proc, which is already # mounted). Contrary to standard usage, # filesystems are NOT unmounted in single user mode. -action "Mounting local filesystems: " mount -a -t nonfs,smbfs,ncpfs,proc +action "Mounting local filesystems: " mount -a -t nonfs,smbfs,ncpfs if [ X"$_RUN_QUOTACHECK" = X1 -a -x /sbin/quotacheck ]; then action "Checking filesystem quotas: " /sbin/quotacheck -v -R -a fi +# Turn on process accounting +if [ -x /sbin/accton ] ; then + action "Turning on process accounting" /sbin/accton /var/log/pacct +fi + # Configure machine if necessary. if [ -f /.unconfigured ]; then if [ -x /usr/bin/passwd ]; then @@ -501,6 +537,12 @@ if [ -f /.unconfigured ]; then # Reset the hostname. action "Resetting hostname ${HOSTNAME}: " hostname ${HOSTNAME} + # Reset the NIS domain name. + if [ -n "$NISDOMAIN" ]; then + action "Resetting NIS domain name $NISDOMAIN: " domainname $NISDOMAIN + else + domainname "" + fi fi rm -f /.unconfigured @@ -521,12 +563,15 @@ _NEED_XFILES= # I'd use find, but /usr may not be mounted. for afile in /var/lock/* /var/run/*; do if [ -d "$afile" ]; then - [ "`basename $afile`" != "news" -a "`basename $afile`" != "sudo" ] && rm -f $afile/* + [ "`basename $afile`" != "news" -a "`basename $afile`" != "sudo" -a "`basename $afile`" != "mon" ] && rm -f $afile/* else rm -f $afile fi done +# Reset pam_console permissions +[ -x /sbin/pam_console_apply ] && /sbin/pam_console_apply -r + { # Clean up utmp/wtmp >/var/run/utmp @@ -566,6 +611,11 @@ if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi fi fi +# Load usb storage here, to match most other things +if [ -n "$needusbstorage" ]; then + modprobe usb-storage >/dev/null 2>&1 +fi + # Load agpgart here. This is a hack, and will probably go away soon. if grep "driver: agpgart" /etc/sysconfig/hwconf >/dev/null 2>&1 ; then modprobe agpgart >/dev/null 2>&1 @@ -574,16 +624,18 @@ fi # Generate a header that defines the boot kernel. KERNEL_TYPE=`uname -r | sed 's_^[^se]*\(\|smp\|enterprise\)$_-\1_;s_^-$__'` KERNEL_RELEASE=`uname -r | sed 's|smp\|enterprise||g'` -KERNEL_ARCH=`rpm -q --qf '%{ARCH}' kernel$KERNEL_TYPE-$KERNEL_RELEASE 2>/dev/null` + +rpm -q kernel$KERNEL_TYPE-$KERNEL_RELEASE >/dev/null 2>&1 && KERNEL_ARCH=`rpm -q --qf '%{ARCH}' kernel$KERNEL_TYPE-$KERNEL_RELEASE 2>/dev/null` || KERNEL_ARCH=`uname -m` + OLD_KERNEL_ARCH_TYPE=`sed -n 's_^/\* Kernel type \(.*\) \*/_\1_p' /boot/kernel.h 2>/dev/null` if [ -n "$KERNEL_ARCH" -a "$KERNEL_ARCH$KERNEL_TYPE" != "$OLD_KERNEL_ARCH_TYPE" ]; then - ENTERPRISE="0" - SMP="0" - UP="0" + ENTERPRISE='0' + SMP='0' + UP='0' case "$KERNEL_TYPE" in - -smp) SMP="1";; - -enterprise) ENTERPRISE="1";; - *) UP="1";; + -smp) SMP='1';; + -enterprise) ENTERPRISE='1';; + *) UP='1';; esac cat > /boot/kernel.h << EOF /* This file is automatically generated at boot time. */ @@ -624,6 +676,7 @@ 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 +sleep 1 kill -TERM `/sbin/pidof getkey` >/dev/null 2>&1 } & if [ "$PROMPT" != "no" ]; then -- cgit v1.2.1