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

Add udevadm trigger back since without Xorg will not run at all. Still need to get keyboard and mouse to work.
author Christopher Rogers <slaxemulator@gmail.com>
date Sat Apr 30 03:37:09 2011 +0000 (2011-04-30)
parents 63eaa6ed9233
children 1cb12350353b
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 # Graphical boot start.
17 if [ "$FBSPLASH" == "yes" ]; then
18 reset && fbsplash -c \
19 -s /etc/fbsplash/$FBSPLASH_THEME/fbsplash.ppm \
20 -i /etc/fbsplash/$FBSPLASH_THEME/fbsplash.cfg \
21 -f /etc/fbsplash/fifo &
22 echo "0" > /etc/fbsplash/fifo && sleep 1
23 fi
25 echo "Processing /etc/init.d/rcS..."
27 # Mount /proc.
28 echo -n "Mounting proc filesystem..."
29 /bin/mount proc
30 status
32 # Set time zone now to get system events at local time
33 if [ -s /etc/TZ ]; then
34 export TZ=$(cat /etc/TZ)
35 fi
37 [ "$FBSPLASH" == "yes" ] && echo "20" > /etc/fbsplash/fifo
39 # Parse cmdline args for earlier boot options. All other boot options
40 # are in /etc/init./bootopts.sh.
41 echo "Checking for early boot options..."
42 for opt in `cat /proc/cmdline`
43 do
44 case $opt in
45 cdrom=*)
46 export CDROM=${opt#cdrom=} ;;
47 modprobe=*)
48 export MODPROBE="yes" ;;
49 config=*)
50 export CONFIG=${opt#config=} ;;
51 xarg=*)
52 export XARG="$XARG ${opt#xarg=}" ;;
53 screen=*)
54 export SCREEN=${opt#screen=} ;;
55 autologin)
56 # Autologin option to skip first graphic login prompt.
57 echo "auto_login yes" >> /etc/slim.conf ;;
58 lang=*)
59 # Check for a specified locale (lang=*).
60 LANG=${opt#lang=}
61 echo -n "Setting system locale to: $LANG... "
62 tazlocale init $LANG
63 status ;;
64 kmap=*)
65 # Check for a specified keymap (kmap=*).
66 KEYMAP=${opt#kmap=}
67 echo -n "Setting system keymap to: $KEYMAP..."
68 tazkeymap init $KEYMAP
69 status ;;
70 *)
71 continue ;;
72 esac
73 done
75 [ "$FBSPLASH" == "yes" ] && echo "40" > /etc/fbsplash/fifo
77 # Before mounting filesystems we check fs specified in the file
78 # /etc/rcS.conf and variable $CHECK_FS.
79 if [ -n "$CHECK_FS" ]; then
80 mount -o remount,ro /
81 for i in $CHECK_FS
82 do
83 echo "Checking filesystem on : $i"
84 /sbin/e2fsck -p $i
85 done
86 fi
88 # Remount rootfs rw.
89 echo "Remounting rootfs read/write..."
90 /bin/mount -o remount,rw /
92 # Trigger Udev and handle hotplug events
93 if [ "$UDEV" = "yes" ]; then
94 echo -n "Starting udev daemon..."
95 /sbin/udevd --daemon
96 status
97 echo -n "Udevadm requesting events from the Kernel..."
98 udevadm trigger
99 status
100 echo -n "Udevadm waiting for the event queue to finish..."
101 udevadm settle
102 status
103 echo -n "Using Udev for hotplugging..."
104 echo "/sbin/udevd" > /proc/sys/kernel/hotplug
105 status
106 fi
108 [ "$FBSPLASH" == "yes" ] && echo "60" > /etc/fbsplash/fifo
110 # Mount filesystems in /etc/fstab.
111 echo "Mounting filesystems in fstab..."
112 /bin/mount -a
114 # Store boot messages to log files.
115 /bin/dmesg > /var/log/dmesg.log &
116 conspy -d | sed 's/ *$//;/^$/d;/^Processi\|^.witchi/,$!d' > /var/log/boot.log
117 script -a -q -c '/etc/init.d/rcS logged' /var/log/boot.log
119 else # logged
121 # Clean up the system.
122 if [ "$CLEAN_UP_SYSTEM" = "yes" ]; then
123 echo -n "Cleaning up the system..."
124 find /var/run -name "*.pid" -type f | xargs /bin/rm -f
125 /bin/rm -rf /tmp /var/run/dbus/* /var/run/hald/pid /var/lock/*
126 /bin/mkdir -p /tmp && /bin/chmod 1777 /tmp
127 status
128 else
129 echo "System clean up is disabled in /etc/rcS.conf..."
130 echo -n "Keeping all tmp and pid files..."
131 status
132 fi
134 [ "$FBSPLASH" == "yes" ] && echo "70" > /etc/fbsplash/fifo
136 # Set up tmp X11 and ICE dir.
137 echo -n "Setting up tmp X11 and ICE unix dir..."
138 /bin/mkdir -p /tmp/.X11-unix /tmp/.ICE-unix
139 /bin/chmod 1777 /tmp/.X11-unix /tmp/.ICE-unix
140 status
142 # Start DBUS and HAL deamon so we can use Xorg and a WM to configure
143 # system locale and keybord on first boot.
144 [ -x /etc/init.d/dbus ] && /etc/init.d/dbus start
145 [ -x /etc/init.d/hald ] && /etc/init.d/hald start
147 # Requested screen is not text mode and keymap.conf is empty so go
148 # for an i18n configuration in GUI mode. In cas of screen=text we
149 # configure locale and keymap just after via i18n.sh
150 if [ "$SCREEN" != "text" -a ! -s "/etc/keymap.conf" -a -x /usr/bin/Xorg ]; then
151 DISPLAY=:1 tazbox boot
152 fi
154 [ "$FBSPLASH" == "yes" ] && echo "80" > /etc/fbsplash/fifo
156 # Set the console keymap and configure i18n in case of screen=text and
157 # no locale.conf or keymap.conf. Add default user for live mode and
158 # mount an eventual /home partition.
159 /etc/init.d/i18n.sh
160 /etc/init.d/user-home.sh
162 [ "$FBSPLASH" == "yes" ] && echo "100" > /etc/fbsplash/fifo
164 # Now that we have a keymap configuration we can auto configure Xorg.
165 # We need to set $HOME.
166 if [ "$SCREEN" != "text" -a ! -s /etc/X11/xorg.conf -a -x /usr/bin/Xorg ]; then
167 echo "Configuring Xorg..."
168 HOME=/root
169 tazx config-xorg
170 fi
172 # Here we finish bootsplash since we start Xorg session.
173 [ "$FBSPLASH" == "yes" ] && sleep 1 && echo "exit" > /etc/fbsplash/fifo
175 # No text mode requested, we have i18n and Xorg settings as well as a
176 # user, so start a desktop and let boot process finih in backgroud.
177 if [ "$SCREEN" != "text" -a -x /etc/init.d/slim ]; then
178 /etc/init.d/slim start
179 fi
181 # Create /dev/cdrom if needed (symlink does not exist on LiveCD).
182 # Also add /dev/cdrom to fstab if entry does not exist.
183 if [ -n "$CDROM" ]; then
184 DRIVE_NAME=${CDROM#/dev/}
185 else
186 DRIVE_NAME=$(grep -s "drive name" /proc/sys/dev/cdrom/info | cut -f 3)
187 fi
188 if [ -n "$DRIVE_NAME" -a ! "`readlink /dev/cdrom`" ]; then
189 echo -n "Creating symlink : /dev/cdrom..."
190 ln -s /dev/$DRIVE_NAME /dev/cdrom
191 ln -s /dev/$DRIVE_NAME /dev/dvd
192 status
193 fi
194 if ! grep -q "/dev/cdrom" /etc/fstab; then
195 echo -n "Adding /dev/cdrom to fstab..."
196 echo '/dev/cdrom /media/cdrom iso9660 user,ro,noauto 0 0' \
197 >> /etc/fstab
198 status
199 fi
201 # Chmod hack on each boot for Asunder and burnbox. Allowing all users
202 # to burn/rip CD/DVD.
203 if [ -n "$DRIVE_NAME" -a "`readlink /dev/cdrom`" ]; then
204 echo -n "Chmoding cdrom device..."
205 chmod 0666 /dev/cdrom
206 chmod 0666 /dev/dvd
207 chmod 0666 /dev/$DRIVE_NAME
208 status
209 fi
211 # Handle kernel cmdline parameter modprobe=<module_list>
212 if [ -n "$MODPROBE" ]; then
213 MODULES=`sed -e 's/.* modprobe=\([^ ]*\).*/\1/' -e 's/,/\n/g' < /proc/cmdline`
214 for i in $MODULES; do
215 echo -n "Loading kernel module $i"
216 /sbin/modprobe $i
217 status
218 done
219 fi
221 # Handle kernel cmdline parameter config=<device>,<path> to source a
222 # disk init script
223 if [ -n "$CONFIG" ]; then
224 DEVICE=${CONFIG%,*}
225 SCRIPT=${CONFIG#*,}
226 echo "Probing $DEVICE... "
227 if ! /bin/mount -r $DEVICE /mnt; then
228 if echo $DEVICE | grep -Eq "/dev/sd|UUID=|LABEL="; then
229 USBDELAY=`cat /sys/module/usb_storage/parameters/delay_use`
230 USBDELAY=$((1+$USBDELAY))
231 echo "$DEVICE is potentially a USB device: sleep for $USBDELAY seconds"
232 sleep $USBDELAY
233 fi
234 if ! /bin/mount -r $DEVICE /mnt; then
235 CONFIG=""
236 fi
237 fi
238 echo -n "Source $SCRIPT from $DEVICE..."
239 if [ -n "$CONFIG" ]; then
240 . /mnt/$SCRIPT
241 /bin/umount /mnt 2> /dev/null || true
242 fi
243 status
244 fi
246 # Mount /proc/bus/usb.
247 if [ -d /proc/bus/usb ]; then
248 echo -n "Mounting /proc/bus/usb filesystem..."
249 /bin/mount -t usbfs usbfs /proc/bus/usb
250 status
251 fi
253 # Start syslogd and klogd.
254 if [ "$KERNEL_LOG_DAEMONS" = "yes" ]; then
255 echo -n "Starting system log deamon: syslogd..."
256 /sbin/syslogd -s $SYSLOGD_ROTATED_SIZE && status
257 echo -n "Starting kernel log daemon: klogd..."
258 /sbin/klogd && status
259 else
260 echo "Kernel log daemons are disabled in /etc/rc.conf..."
261 fi
263 # Load all modules listed in config file.
264 if [ -n "$LOAD_MODULES" ]; then
265 for mod in $LOAD_MODULES
266 do
267 modprobe $mod
268 done
269 fi
271 # Be quiet on configuration to avoid messages overwriting ncurses dialog
272 echo "0 0 0 0" > /proc/sys/kernel/printk
274 # Detect PCI and USB devices with Tazhw from slitaz-tools. We load
275 # kernel modules only at first boot or in LiveCD mode.
276 if [ ! -s /var/lib/detected-modules ]; then
277 /sbin/tazhw init
278 fi
280 if [ "$UDEV" = "yes" ]; then
281 echo -n "Udevadm requesting events from the Kernel..."
282 udevadm trigger
283 status
284 fi
286 # Auto recharge packages list (after network connection of course)
287 [ "$RECHARGE_PACKAGES_LIST" == "yes" ] && tazpkg recharge &
289 # Start all scripts specified with $RUN_SCRIPTS.
290 echo "Executing all initialization scripts..."
291 for script in $RUN_SCRIPTS
292 do
293 if [ -x /etc/init.d/$script ]; then
294 /etc/init.d/$script
295 fi
296 done
298 # Start all daemons specified with $RUN_DAEMONS.
299 echo "Starting all daemons specified in /etc/rcS.conf..."
300 for daemon in $RUN_DAEMONS
301 do
302 if [ -x /etc/init.d/$daemon ]; then
303 /etc/init.d/$daemon start
304 fi
305 done
307 # Back to a verbose mode.
308 echo "7 4 1 7" > /proc/sys/kernel/printk
310 # Reset screen and display a bold message.
311 if [ -n "$MESSAGE" ]; then
312 /usr/bin/reset
313 echo -e "\033[1m$MESSAGE\033[0m"
314 fi
316 # Display and log boot time.
317 time=$((`date +%s` - $bootdate))
318 echo $time > /var/log/boot-time
319 echo "SliTaz boot time: ${time}s"
321 fi # logged