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

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