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

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