slitaz-boot-scripts annotate etc/init.d/rcS @ rev 143

-4 sec for boot time ans less Kernel messages
author Christophe Lincoln <pankso@slitaz.org>
date Sun Mar 08 00:13:04 2009 +0100 (2009-03-08)
parents b2a46128ff7b
children 979868f40866
rev   line source
pankso@5 1 #!/bin/sh
pankso@5 2 # /etc/init.d/rcS - Initial boot script for SliTaz GNU/Linux. rcS is the main
MikeDSmith25@107 3 # initialization script used to check fs, mount, clean, run scripts and start
pankso@5 4 # daemons.
pankso@5 5 #
pankso@5 6 # Config file is : /etc/rcS.conf
pankso@5 7 #
pankso@5 8 . /etc/init.d/rc.functions
pankso@5 9 . /etc/rcS.conf
pankso@5 10
pascal@41 11 if [ "$1" != "logged" ]; then #logged
pascal@41 12
pankso@5 13 echo "Processing /etc/init.d/rcS... "
pankso@5 14
pankso@5 15 # Mount /proc.
pankso@5 16 echo -n "Mounting proc filesystem... "
pankso@5 17 /bin/mount proc
pankso@143 18 status
pankso@5 19
pankso@5 20 # Before mounting filesystems we check fs specified in the file
pankso@5 21 # /etc/rcS.conf and variable $CHECK_FS.
pankso@5 22 if [ ! "$CHECK_FS" = "" ]; then
pankso@5 23 mount -o remount,ro /
pankso@5 24 for i in $CHECK_FS
pankso@5 25 do
pankso@5 26 echo "Checking filesystem on : $i"
pankso@5 27 /sbin/e2fsck -p $i
pankso@5 28 done
pankso@5 29 fi
pankso@5 30
pankso@5 31 # Remount rootfs rw.
pankso@5 32 echo "Remounting rootfs read/write... "
pankso@5 33 /bin/mount -o remount,rw /
pankso@5 34
MikeDSmith25@107 35 # Mount filesystems in /etc/fstab.
MikeDSmith25@107 36 echo "Mounting filesystems in fstab... "
pankso@5 37 /bin/mount -a
pankso@5 38
pankso@5 39 # Start Udev to populate /dev and handle hotplug events
pankso@5 40 if [ "$UDEV" = "yes" ]; then
pankso@5 41 echo -n "Starting udev daemon..."
pankso@5 42 /sbin/udevd --daemon
pankso@5 43 status
pankso@143 44 echo -n "Udevadm requesting events from the Kernel..."
pankso@143 45 udevadm trigger
pankso@143 46 status
pankso@143 47 echo -n "Udevadm waiting for the event queu to finish..."
pankso@143 48 udevadm settle
pankso@143 49 status
pankso@5 50 echo "/sbin/udevd" > /proc/sys/kernel/hotplug
pankso@5 51 fi
pankso@5 52
pascal@41 53 /bin/dmesg > /var/log/dmesg.log
pascal@122 54 vcsa2txt < /dev/vcsa1 | awk 'BEGIN {s=0} /^Processing|^.witching/ {s=1} { if (s) print }' >/var/log/boot.log
pascal@47 55 script -a -q -c '/etc/init.d/rcS logged' /var/log/boot.log
pascal@41 56
pascal@41 57 else #logged
pascal@41 58
MikeDSmith25@107 59 # Create /dev/cdrom if needed (symlink does not exist on LiveCD).
MikeDSmith25@107 60 # Also add /dev/cdrom to fstab if entry does not exist.
pankso@19 61 #
pankso@19 62 DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3`
pascal@91 63 if grep -q " cdrom=" /proc/cmdline; then
pascal@91 64 DRIVE_NAME=`cat /proc/cmdline | sed 's/.* cdrom=\([^ ]*\).*/\1/'`
pascal@91 65 fi
pascal@45 66 if [ -n "$DRIVE_NAME" -a ! "`readlink /dev/cdrom`" ]; then
pankso@19 67 echo -n "Creating symlink : /dev/cdrom..."
pankso@19 68 ln -s /dev/$DRIVE_NAME /dev/cdrom
pankso@66 69 ln -s /dev/$DRIVE_NAME /dev/dvd
pankso@19 70 status
pankso@19 71 fi
pankso@19 72 if ! grep -q "/dev/cdrom" /etc/fstab; then
pankso@19 73 echo -n "Adding /dev/cdrom to fstab..."
pascal@63 74 echo '/dev/cdrom /media/cdrom iso9660 user,ro,noauto 0 0' \
pankso@19 75 >> /etc/fstab
pankso@19 76 status
pankso@19 77 fi
pankso@49 78 # Chmod hack on each boot for Asunder and burnbox. Allowing all users
pankso@49 79 # to burn/rip CD/DVD.
pankso@49 80 if [ -n "$DRIVE_NAME" -a "`readlink /dev/cdrom`" ]; then
pankso@49 81 echo -n "Chmoding cdrom device..."
pankso@49 82 chmod 0666 /dev/cdrom
pankso@66 83 chmod 0666 /dev/dvd
pankso@49 84 chmod 0666 /dev/$DRIVE_NAME
pankso@49 85 status
pankso@49 86 fi
pankso@19 87
pankso@15 88 # Handle kernel cmdline parameter modprobe=<module_list>
pankso@17 89 if grep -q " modprobe=" /proc/cmdline; then
pankso@15 90 MODULES=`sed -e 's/.* modprobe=\([^ ]*\).*/\1/' -e 's/,/\n/g' < /proc/cmdline`
pankso@15 91 for i in $MODULES; do
pankso@15 92 echo -n "Loading kernel module $i"
pankso@15 93 /sbin/modprobe $i
pankso@15 94 status
pankso@15 95 done
pankso@15 96 fi
pankso@15 97
pankso@5 98 # Handle kernel cmdline parameter config=<device>,<path> to source a
pankso@5 99 # disk init script
pankso@5 100 if grep -q " config=" /proc/cmdline; then
pankso@5 101 CONFIG=`cat /proc/cmdline | sed 's/.* config=\([^ ]*\).*/\1/'`
pankso@5 102 DEVICE=${CONFIG%,*}
pankso@5 103 SCRIPT=${CONFIG#*,}
pascal@110 104 echo "Probing $DEVICE... "
pascal@110 105 if ! /bin/mount -r $DEVICE /mnt; then
pascal@110 106 if echo $DEVICE | grep -q "/dev/sd"; then
pascal@110 107 USBDELAY=`cat /sys/module/usb_storage/parameters/delay_use`
pascal@110 108 USBDELAY=$((1+$USBDELAY))
pascal@110 109 echo "$DEVICE is potentially a USB device: sleep for $USBDELAY seconds"
pascal@110 110 sleep $USBDELAY
pascal@110 111 fi
pascal@110 112 if ! /bin/mount -r $DEVICE /mnt; then
pascal@110 113 CONFIG=""
pascal@110 114 fi
pascal@110 115 fi
pankso@5 116 echo -n "Source $SCRIPT from $DEVICE... "
pascal@110 117 if [ -n "$CONFIG" ]; then
pankso@5 118 . /mnt/$SCRIPT
pankso@5 119 /bin/umount /mnt
pankso@5 120 fi
pankso@5 121 status
pankso@5 122 fi
pankso@5 123
pankso@55 124 # Eject option
pankso@55 125 if grep -q -w "eject" /proc/cmdline; then
pankso@55 126 eject /dev/cdrom
pankso@55 127 fi
pankso@55 128
pascal@124 129 # Mount /proc/bus/usb.
pascal@124 130 if [ -d /proc/bus/usb ]; then
pascal@124 131 echo -n "Mounting /proc/bus/usb filesystem... "
pascal@124 132 /bin/mount -t usbfs usbfs /proc/bus/usb
pascal@124 133 status
pascal@124 134 fi
pascal@124 135
pankso@5 136 # Start syslogd and klogd.
pankso@5 137 if [ "$KERNEL_LOG_DAEMONS" = "yes" ]; then
pankso@5 138 echo -n "Starting system log deamon: syslogd... "
pankso@5 139 /sbin/syslogd -s $SYSLOGD_ROTATED_SIZE && status
pankso@5 140 echo -n "Starting kernel log daemon: klogd... "
pankso@5 141 /sbin/klogd && status
pankso@5 142 else
pankso@5 143 echo "Kernel log daemons are disabled in /etc/rc.conf... "
pankso@5 144 fi
pankso@5 145
pankso@5 146 # Clean up the system.
pankso@5 147 if [ "$CLEAN_UP_SYSTEM" = "yes" ]; then
pankso@5 148 echo -n "Cleaning up the system... "
pascal@106 149 rm -rf /tmp/* /tmp/.* 2> /dev/null
pankso@94 150 rm -f /var/run/*.pid /var/run/dbus/* /var/run/hald/pid
pankso@39 151 rm -f /var/lock/*
pankso@5 152 status
pankso@5 153 else
pankso@5 154 echo "System clean up is disabled in /etc/rcS.conf... "
pankso@5 155 echo "Keeping all tmp and pid files... "
pankso@5 156 status
pankso@5 157 fi
pankso@5 158
pankso@5 159 # Set up tmp X11 and ICE dir.
pankso@5 160 echo -n "Setting up tmp X11 and ICE unix dir... "
pankso@5 161 /bin/mkdir -p /tmp/.X11-unix
pankso@5 162 /bin/mkdir -p /tmp/.ICE-unix
pankso@5 163 /bin/chmod 1777 /tmp/.X11-unix
pankso@5 164 /bin/chmod 1777 /tmp/.ICE-unix
pankso@5 165 status
pankso@5 166
pankso@5 167 # Load all modules listed in config file.
pankso@5 168 if [ ! "$LOAD_MODULES" = "" ]; then
pankso@5 169 for mod in $LOAD_MODULES
pankso@5 170 do
pankso@5 171 modprobe $mod
pankso@5 172 done
pankso@5 173 fi
pankso@5 174
pankso@143 175 # Be quit on configuration to avoid message overwriting ncrurses dialog
pankso@143 176 echo "0 0 0 0" > /proc/sys/kernel/printk
pankso@143 177
pankso@5 178 # Start all scripts specified with $RUN_SCRIPTS.
MikeDSmith25@107 179 echo "Executing all initialization scripts..."
pankso@5 180 for script in $RUN_SCRIPTS
pankso@5 181 do
pankso@55 182 if [ -x /etc/init.d/$script ]; then
pankso@32 183 /etc/init.d/$script
pankso@32 184 fi
pankso@5 185 done
pankso@5 186
MikeDSmith25@107 187 # Re-source main config file. In Live mode, daemons list can be modified
pankso@32 188 # by boot options.
pankso@32 189 . /etc/rcS.conf
pankso@32 190
pankso@5 191 # Start all daemons specified with $RUN_DAEMONS.
pankso@5 192 echo "Starting all daemons specified in /etc/rcS.conf..."
pankso@5 193 for daemon in $RUN_DAEMONS
pankso@5 194 do
pankso@32 195 if [ -x /etc/init.d/$daemon ]; then
pankso@32 196 /etc/init.d/$daemon start
pankso@32 197 fi
pankso@5 198 done
pankso@5 199
pankso@143 200 # Back to a verbose mode.
pankso@143 201 echo "7 4 1 7" > /proc/sys/kernel/printk
pankso@143 202
pankso@5 203 # Reset screen and display a bold message.
pankso@5 204 if [ -n "$MESSAGE" ]; then
pankso@5 205 /usr/bin/reset
pankso@5 206 echo -e "\033[1m$MESSAGE\033[0m"
pankso@5 207 fi
pankso@5 208
pascal@41 209 fi #logged