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

Rollback rev 238 to release 4.1.2: it screw usb plug (mouse doesn't works into X)
author Antoine Bodin <gokhlayeh@slitaz.org>
date Sun Mar 27 01:46:32 2011 +0100 (2011-03-27)
parents 68435a9c0843
children 0afa56775784
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 # Boot time.
12 bootdate=`date +%s`
14 # Graphical boot start.
15 if [ "$FBSPLASH" == "yes" ]; then
16 reset && fbsplash -c \
17 -s /etc/fbsplash/$FBSPLASH_THEME/fbsplash.ppm \
18 -i /etc/fbsplash/$FBSPLASH_THEME/fbsplash.cfg \
19 -f /etc/fbsplash/fifo &
20 echo "0" > /etc/fbsplash/fifo
21 fi
23 if [ "$1" != "logged" ]; then # logged
25 echo "Processing /etc/init.d/rcS..."
27 # Mount /proc.
28 echo -n "Mounting proc filesystem..."
29 /bin/mount proc
30 status
32 [ "$FBSPLASH" == "yes" ] && echo "10" > /etc/fbsplash/fifo
34 # Parse cmdline args for earlier boot options. All other boot options
35 # are in /etc/init./bootopts.sh.
36 echo -n "Searching for early boot options..."
37 for opt in `cat /proc/cmdline`
38 do
39 case $opt in
40 fastbootx|fbx)
41 export FAST_BOOT_X="yes" ;;
42 cdrom=*)
43 export CDROM=${opt#cdrom=} ;;
44 modprobe=*)
45 export MODPROBE="yes" ;;
46 config=*)
47 export CONFIG=${opt#config=} ;;
48 *)
49 continue ;;
50 esac
51 done
52 status
54 [ "$FBSPLASH" == "yes" ] && echo "20" > /etc/fbsplash/fifo
56 # Trigger Udev and handle hotplug events
57 if [ "$UDEV" = "yes" ]; then
58 echo -n "Udevadm requesting events from the Kernel..."
59 udevadm trigger
60 status
61 echo -n "Using Udev for hotplugging..."
62 echo "/sbin/udevd" > /proc/sys/kernel/hotplug
63 status
64 fi
66 # Before mounting filesystems we check fs specified in the file
67 # /etc/rcS.conf and variable $CHECK_FS.
68 if [ -n "$CHECK_FS" ]; then
69 mount -o remount,ro /
70 for i in $CHECK_FS
71 do
72 echo "Checking filesystem on : $i"
73 /sbin/e2fsck -p $i
74 done
75 fi
77 # Remount rootfs rw.
78 echo "Remounting rootfs read/write..."
79 /bin/mount -o remount,rw /
81 [ "$FBSPLASH" == "yes" ] && echo "30" > /etc/fbsplash/fifo
83 # Mount filesystems in /etc/fstab.
84 echo "Mounting filesystems in fstab..."
85 /bin/mount -a
87 # Store boot messages to log files.
88 /bin/dmesg > /var/log/dmesg.log &
89 conspy -d | sed 's/ *$//;/^$/d;/^Processi\|^.witchi/,$!d' > /var/log/boot.log
90 script -a -q -c '/etc/init.d/rcS logged' /var/log/boot.log
92 else # logged
94 # Clean up the system.
95 if [ "$CLEAN_UP_SYSTEM" = "yes" ]; then
96 echo -n "Cleaning up the system..."
97 find /var/run -name "*.pid" -type f | xargs /bin/rm -f
98 /bin/rm -rf /tmp /var/run/dbus/* /var/run/hald/pid /var/lock/*
99 /bin/mkdir -p /tmp && /bin/chmod 1777 /tmp
100 status
101 else
102 echo "System clean up is disabled in /etc/rcS.conf..."
103 echo -n "Keeping all tmp and pid files..."
104 status
105 fi
107 [ "$FBSPLASH" == "yes" ] && echo "40" > /etc/fbsplash/fifo
109 # Set up tmp X11 and ICE dir.
110 echo -n "Setting up tmp X11 and ICE unix dir..."
111 /bin/mkdir -p /tmp/.X11-unix /tmp/.ICE-unix
112 /bin/chmod 1777 /tmp/.X11-unix /tmp/.ICE-unix
113 status
115 # Fast boot into X for HD install or custom Live system. We need
116 # keymap settings since Xvesa dumps the console mapping and a correct
117 # slim configuration for screen resolution. DBUS and HAL must also start
118 # before X session (manual login or autologin) to have devices in PCmanFM.
119 if [ "$FAST_BOOT_X" = "yes" ]; then
120 /etc/init.d/i18n.sh
121 /etc/init.d/dbus start
122 /etc/init.d/hald start
123 /etc/init.d/slim start &
124 fi
126 # Create /dev/cdrom if needed (symlink does not exist on LiveCD).
127 # Also add /dev/cdrom to fstab if entry does not exist.
128 if [ -n "$CDROM" ]; then
129 DRIVE_NAME=${CDROM#/dev/}
130 else
131 DRIVE_NAME=`grep -s "drive name" /proc/sys/dev/cdrom/info | cut -f 3`
132 fi
133 if [ -n "$DRIVE_NAME" -a ! "`readlink /dev/cdrom`" ]; then
134 echo -n "Creating symlink : /dev/cdrom..."
135 ln -s /dev/$DRIVE_NAME /dev/cdrom
136 ln -s /dev/$DRIVE_NAME /dev/dvd
137 status
138 fi
139 if ! grep -q "/dev/cdrom" /etc/fstab; then
140 echo -n "Adding /dev/cdrom to fstab..."
141 echo '/dev/cdrom /media/cdrom iso9660 user,ro,noauto 0 0' \
142 >> /etc/fstab
143 status
144 fi
145 # Chmod hack on each boot for Asunder and burnbox. Allowing all users
146 # to burn/rip CD/DVD.
147 if [ -n "$DRIVE_NAME" -a "`readlink /dev/cdrom`" ]; then
148 echo -n "Chmoding cdrom device..."
149 chmod 0666 /dev/cdrom
150 chmod 0666 /dev/dvd
151 chmod 0666 /dev/$DRIVE_NAME
152 status
153 fi
155 [ "$FBSPLASH" == "yes" ] && echo "50" > /etc/fbsplash/fifo
157 # Handle kernel cmdline parameter modprobe=<module_list>
158 if [ -n "$MODPROBE" ]; then
159 MODULES=`sed -e 's/.* modprobe=\([^ ]*\).*/\1/' -e 's/,/\n/g' < /proc/cmdline`
160 for i in $MODULES; do
161 echo -n "Loading kernel module $i"
162 /sbin/modprobe $i
163 status
164 done
165 fi
167 # Handle kernel cmdline parameter config=<device>,<path> to source a
168 # disk init script
169 if [ -n "$CONFIG" ]; then
170 DEVICE=${CONFIG%,*}
171 SCRIPT=${CONFIG#*,}
172 echo "Probing $DEVICE... "
173 if ! /bin/mount -r $DEVICE /mnt; then
174 if echo $DEVICE | grep -Eq "/dev/sd|UUID=|LABEL="; then
175 USBDELAY=`cat /sys/module/usb_storage/parameters/delay_use`
176 USBDELAY=$((1+$USBDELAY))
177 echo "$DEVICE is potentially a USB device: sleep for $USBDELAY seconds"
178 sleep $USBDELAY
179 fi
180 if ! /bin/mount -r $DEVICE /mnt; then
181 CONFIG=""
182 fi
183 fi
184 echo -n "Source $SCRIPT from $DEVICE..."
185 if [ -n "$CONFIG" ]; then
186 . /mnt/$SCRIPT
187 /bin/umount /mnt 2> /dev/null || true
188 fi
189 status
190 fi
192 # Mount /proc/bus/usb.
193 if [ -d /proc/bus/usb ]; then
194 echo -n "Mounting /proc/bus/usb filesystem..."
195 /bin/mount -t usbfs usbfs /proc/bus/usb
196 status
197 fi
199 [ "$FBSPLASH" == "yes" ] && echo "60" > /etc/fbsplash/fifo
201 # Start syslogd and klogd.
202 if [ "$KERNEL_LOG_DAEMONS" = "yes" ]; then
203 echo -n "Starting system log deamon: syslogd..."
204 /sbin/syslogd -s $SYSLOGD_ROTATED_SIZE && status
205 echo -n "Starting kernel log daemon: klogd..."
206 /sbin/klogd && status
207 else
208 echo "Kernel log daemons are disabled in /etc/rc.conf..."
209 fi
211 # Load all modules listed in config file.
212 if [ -n "$LOAD_MODULES" ]; then
213 for mod in $LOAD_MODULES
214 do
215 modprobe $mod
216 done
217 fi
219 # Be quiet on configuration to avoid messages overwriting ncurses dialog
220 echo "0 0 0 0" > /proc/sys/kernel/printk
222 [ "$FBSPLASH" == "yes" ] && echo "70" > /etc/fbsplash/fifo
224 # Detect PCI and USB devices with Tazhw from slitaz-tools. We load
225 # kernel modules only at first boot or in LiveCD mode.
226 if [ ! -s /var/lib/detected-modules ]; then
227 /sbin/tazhw init
228 fi
230 # Call udevadm trigger to ensure /dev is fully populate now that all
231 # modules are loaded.
232 if [ "$UDEV" = "yes" ]; then
233 echo -n "Requesting events from the Kernel..."
234 udevadm trigger
235 status
236 fi
238 # Start all scripts specified with $RUN_SCRIPTS.
239 echo "Executing all initialization scripts..."
240 for script in $RUN_SCRIPTS
241 do
242 if [ -x /etc/init.d/$script ]; then
243 /etc/init.d/$script
244 fi
245 done
247 [ "$FBSPLASH" == "yes" ] && echo "80" > /etc/fbsplash/fifo
249 # Re-source main config file. In Live mode, daemons list can be modified
250 # by boot options (screen=text will remove slim).
251 . /etc/rcS.conf
253 # Start all daemons specified with $RUN_DAEMONS.
254 echo "Starting all daemons specified in /etc/rcS.conf..."
255 for daemon in $RUN_DAEMONS
256 do
257 if [ -x /etc/init.d/$daemon ]; then
258 /etc/init.d/$daemon start
259 fi
260 done
262 [ "$FBSPLASH" == "yes" ] && echo "90" > /etc/fbsplash/fifo
264 # Back to a verbose mode.
265 echo "7 4 1 7" > /proc/sys/kernel/printk
267 # Reset screen and display a bold message.
268 if [ -n "$MESSAGE" ]; then
269 /usr/bin/reset
270 echo -e "\033[1m$MESSAGE\033[0m"
271 fi
273 [ "$FBSPLASH" == "yes" ] && echo "100" > /etc/fbsplash/fifo
275 # Display and log boot time.
276 time=$((`date +%s` - $bootdate))
277 echo $time > /var/log/boot-time
278 echo "SliTaz boot time: ${time}s"
279 [ "$FBSPLASH" == "yes" ] && echo "exit" > /etc/fbsplash/fifo
281 fi # logged