slitaz-boot-scripts view etc/init.d/rcS @ rev 157

Add option FAST_BOOT_X (fastbootx) to start X 4-6 sec earlier
author Christophe Lincoln <pankso@slitaz.org>
date Sun Apr 26 14:10:28 2009 +0200 (2009-04-26)
parents 965cc9d8722a
children 6d1034b2830e
line source
1 #!/bin/sh
2 # /etc/init.d/rcS - Initial boot script for SliTaz GNU/Linux.
3 # Config file is : /etc/rcS.conf
4 #
5 # rcS is the main initialization script used to check fs, mount, clean,
6 # run scripts and start daemons.
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 # Start Udev to populate /dev and handle hotplug events
21 if [ "$UDEV" = "yes" ]; then
22 echo -n "Starting udev daemon..."
23 /sbin/udevd --daemon
24 status
25 echo -n "Udevadm requesting events from the Kernel..."
26 udevadm trigger
27 status
28 echo -n "Udevadm waiting for the event queue to finish..."
29 udevadm settle
30 status
31 echo "/sbin/udevd" > /proc/sys/kernel/hotplug
32 fi
34 # Before mounting filesystems we check fs specified in the file
35 # /etc/rcS.conf and variable $CHECK_FS.
36 if [ -n "$CHECK_FS" ]; then
37 mount -o remount,ro /
38 for i in $CHECK_FS
39 do
40 echo "Checking filesystem on : $i"
41 /sbin/e2fsck -p $i
42 done
43 fi
45 # Remount rootfs rw.
46 echo "Remounting rootfs read/write... "
47 /bin/mount -o remount,rw /
49 # Mount filesystems in /etc/fstab.
50 echo "Mounting filesystems in fstab... "
51 /bin/mount -a
53 # Store boot messages to log files.
54 /bin/dmesg > /var/log/dmesg.log &
55 vcsa2txt < /dev/vcsa1 | awk 'BEGIN {s=0} /^Processing|^.witching/ {s=1} { if (s) print }' >/var/log/boot.log
56 script -a -q -c '/etc/init.d/rcS logged' /var/log/boot.log
58 else # logged
60 # Clean up the system.
61 if [ "$CLEAN_UP_SYSTEM" = "yes" ]; then
62 echo -n "Cleaning up the system... "
63 /bin/rm -rf /tmp /var/run/*.pid /var/run/dbus/* \
64 /var/run/hald/pid /var/lock/*
65 /bin/mkdir -p /tmp && /bin/chmod 1777 /tmp
66 status
67 else
68 echo "System clean up is disabled in /etc/rcS.conf... "
69 echo -n "Keeping all tmp and pid files... "
70 status
71 fi
73 # Set up tmp X11 and ICE dir.
74 echo -n "Setting up tmp X11 and ICE unix dir... "
75 /bin/mkdir -p /tmp/.X11-unix /tmp/.ICE-unix
76 /bin/chmod 1777 /tmp/.X11-unix /tmp/.ICE-unix
77 status
79 # Fast boot into X for HD install or custom Live system. We need
80 # keymap settings since Xvesa dump the console mapping and a correct
81 # slim configuration for screen resolution. DBUS and HAL must also start
82 # befor X session (manual login or autologin) to have devices in PCmanFM.
83 if [ "$FAST_BOOT_X" = "yes" ] || grep -q -w "fastbootx" /proc/cmdline; then
84 /etc/init.d/i18n.sh
85 /etc/init.d/dbus start
86 /etc/init.d/hald start
87 /etc/init.d/slim start &
88 fi
90 # Create /dev/cdrom if needed (symlink does not exist on LiveCD).
91 # Also add /dev/cdrom to fstab if entry does not exist.
92 if grep -q " cdrom=" /proc/cmdline; then
93 DRIVE_NAME=`cat /proc/cmdline | sed 's/.* cdrom=\([^ ]*\).*/\1/'`
94 else
95 DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3`
96 fi
97 if [ -n "$DRIVE_NAME" -a ! "`readlink /dev/cdrom`" ]; then
98 echo -n "Creating symlink : /dev/cdrom..."
99 ln -s /dev/$DRIVE_NAME /dev/cdrom
100 ln -s /dev/$DRIVE_NAME /dev/dvd
101 status
102 fi
103 if ! grep -q "/dev/cdrom" /etc/fstab; then
104 echo -n "Adding /dev/cdrom to fstab..."
105 echo '/dev/cdrom /media/cdrom iso9660 user,ro,noauto 0 0' \
106 >> /etc/fstab
107 status
108 fi
109 # Chmod hack on each boot for Asunder and burnbox. Allowing all users
110 # to burn/rip CD/DVD.
111 if [ -n "$DRIVE_NAME" -a "`readlink /dev/cdrom`" ]; then
112 echo -n "Chmoding cdrom device..."
113 chmod 0666 /dev/cdrom
114 chmod 0666 /dev/dvd
115 chmod 0666 /dev/$DRIVE_NAME
116 status
117 fi
119 # Handle kernel cmdline parameter modprobe=<module_list>
120 if grep -q " modprobe=" /proc/cmdline; then
121 MODULES=`sed -e 's/.* modprobe=\([^ ]*\).*/\1/' -e 's/,/\n/g' < /proc/cmdline`
122 for i in $MODULES; do
123 echo -n "Loading kernel module $i"
124 /sbin/modprobe $i
125 status
126 done
127 fi
129 # Handle kernel cmdline parameter config=<device>,<path> to source a
130 # disk init script
131 if grep -q " config=" /proc/cmdline; then
132 CONFIG=`cat /proc/cmdline | sed 's/.* config=\([^ ]*\).*/\1/'`
133 DEVICE=${CONFIG%,*}
134 SCRIPT=${CONFIG#*,}
135 echo "Probing $DEVICE... "
136 if ! /bin/mount -r $DEVICE /mnt; then
137 if echo $DEVICE | grep -q "/dev/sd"; then
138 USBDELAY=`cat /sys/module/usb_storage/parameters/delay_use`
139 USBDELAY=$((1+$USBDELAY))
140 echo "$DEVICE is potentially a USB device: sleep for $USBDELAY seconds"
141 sleep $USBDELAY
142 fi
143 if ! /bin/mount -r $DEVICE /mnt; then
144 CONFIG=""
145 fi
146 fi
147 echo -n "Source $SCRIPT from $DEVICE... "
148 if [ -n "$CONFIG" ]; then
149 . /mnt/$SCRIPT
150 /bin/umount /mnt
151 fi
152 status
153 fi
155 # Mount /proc/bus/usb.
156 if [ -d /proc/bus/usb ]; then
157 echo -n "Mounting /proc/bus/usb filesystem... "
158 /bin/mount -t usbfs usbfs /proc/bus/usb
159 status
160 fi
162 # Start syslogd and klogd.
163 if [ "$KERNEL_LOG_DAEMONS" = "yes" ]; then
164 echo -n "Starting system log deamon: syslogd... "
165 /sbin/syslogd -s $SYSLOGD_ROTATED_SIZE && status
166 echo -n "Starting kernel log daemon: klogd... "
167 /sbin/klogd && status
168 else
169 echo "Kernel log daemons are disabled in /etc/rc.conf... "
170 fi
172 # Load all modules listed in config file.
173 if [ -n "$LOAD_MODULES" ]; then
174 for mod in $LOAD_MODULES
175 do
176 modprobe $mod
177 done
178 fi
180 # Be quiet on configuration to avoid message overwriting ncurses dialog
181 echo "0 0 0 0" > /proc/sys/kernel/printk
183 # Detect PCI and USB devices with Tazhw from slitaz-tools. We load
184 # kernel module only at first boot or in LiveCD mode.
185 if [ ! -s /var/lib/detected-modules ]; then
186 /sbin/tazhw init
187 fi
189 # Start all scripts specified with $RUN_SCRIPTS.
190 echo "Executing all initialization scripts..."
191 for script in $RUN_SCRIPTS
192 do
193 if [ -x /etc/init.d/$script ]; then
194 /etc/init.d/$script
195 fi
196 done
198 # Re-source main config file. In Live mode, daemons list can be modified
199 # by boot options (screen=text will remove slim).
200 . /etc/rcS.conf
202 # Start all daemons specified with $RUN_DAEMONS.
203 echo "Starting all daemons specified in /etc/rcS.conf..."
204 for daemon in $RUN_DAEMONS
205 do
206 if [ -x /etc/init.d/$daemon ]; then
207 /etc/init.d/$daemon start
208 fi
209 done
211 # Back to a verbose mode.
212 echo "7 4 1 7" > /proc/sys/kernel/printk
214 # Reset screen and display a bold message.
215 if [ -n "$MESSAGE" ]; then
216 /usr/bin/reset
217 echo -e "\033[1m$MESSAGE\033[0m"
218 fi
220 fi # logged