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