slitaz-boot-scripts view etc/init.d/rcS @ rev 254
Huge change in boot... we start X as soon as possible by default, for this we have to config keymap, locale, user and home before, let do that in rcS. Also some fixes such as TZ
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Fri Apr 29 16:06:08 2011 +0200 (2011-04-29) |
parents | 9fdf071862a6 |
children | c76406c5b7c5 |
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 XARG="$XARG ${opt#xarg=}" ;;
53 screen=text)
54 echo -n "Text mode option detected..."
55 SCREEN=text
56 status ;;
57 screen=[0-9]*)
58 SCREEN=${opt#screen=} ;;
59 autologin)
60 # Autologin option to skip first graphic login prompt.
61 echo "auto_login yes" >> /etc/slim.conf ;;
62 lang=*)
63 # Check for a specified locale (lang=*).
64 LANG=${opt#lang=}
65 echo -n "Setting system locale to: $LANG... "
66 tazlocale init $LANG
67 status ;;
68 kmap=*)
69 # Check for a specified keymap (kmap=*).
70 KEYMAP=${opt#kmap=}
71 echo -n "Setting system keymap to: $KEYMAP..."
72 tazkeymap init $KEYMAP
73 status ;;
74 *)
75 continue ;;
76 esac
77 done
79 [ "$FBSPLASH" == "yes" ] && echo "40" > /etc/fbsplash/fifo
81 # Before mounting filesystems we check fs specified in the file
82 # /etc/rcS.conf and variable $CHECK_FS.
83 if [ -n "$CHECK_FS" ]; then
84 mount -o remount,ro /
85 for i in $CHECK_FS
86 do
87 echo "Checking filesystem on : $i"
88 /sbin/e2fsck -p $i
89 done
90 fi
92 # Remount rootfs rw.
93 echo "Remounting rootfs read/write..."
94 /bin/mount -o remount,rw /
96 # Trigger Udev and handle hotplug events
97 if [ "$UDEV" = "yes" ]; then
98 echo -n "Starting udev daemon..."
99 /sbin/udevd --daemon
100 status
101 echo -n "Udevadm waiting for the event queue to finish..."
102 udevadm settle
103 status
104 echo -n "Using Udev for hotplugging..."
105 echo "/sbin/udevd" > /proc/sys/kernel/hotplug
106 status
107 fi
109 [ "$FBSPLASH" == "yes" ] && echo "60" > /etc/fbsplash/fifo
111 # Mount filesystems in /etc/fstab.
112 echo "Mounting filesystems in fstab..."
113 /bin/mount -a
115 # Store boot messages to log files.
116 /bin/dmesg > /var/log/dmesg.log &
117 conspy -d | sed 's/ *$//;/^$/d;/^Processi\|^.witchi/,$!d' > /var/log/boot.log
118 script -a -q -c '/etc/init.d/rcS logged' /var/log/boot.log
120 else # logged
122 # Clean up the system.
123 if [ "$CLEAN_UP_SYSTEM" = "yes" ]; then
124 echo -n "Cleaning up the system..."
125 find /var/run -name "*.pid" -type f | xargs /bin/rm -f
126 /bin/rm -rf /tmp /var/run/dbus/* /var/run/hald/pid /var/lock/*
127 /bin/mkdir -p /tmp && /bin/chmod 1777 /tmp
128 status
129 else
130 echo "System clean up is disabled in /etc/rcS.conf..."
131 echo -n "Keeping all tmp and pid files..."
132 status
133 fi
135 [ "$FBSPLASH" == "yes" ] && echo "70" > /etc/fbsplash/fifo
137 # Set up tmp X11 and ICE dir.
138 echo -n "Setting up tmp X11 and ICE unix dir..."
139 /bin/mkdir -p /tmp/.X11-unix /tmp/.ICE-unix
140 /bin/chmod 1777 /tmp/.X11-unix /tmp/.ICE-unix
141 status
143 # Start DBUS and HAL deamon so we can use Xorg and a WM to configure
144 # system locale and keybord on first boot.
145 [ -x /etc/init.d/dbus ] && /etc/init.d/dbus start
146 [ -x /etc/init.d/hald ] && /etc/init.d/hald start
148 # Requested screen is not text mode and keymap.conf is empty so go
149 # for an i18n configuration in GUI mode. In cas of screen=text we
150 # configure locale and keymap just after via i18n.sh
151 if [ "$SCREEN" != "text" -a ! -s "/etc/locale.conf" -a -x /usr/bin/Xorg ]; then
152 tazbox boot
153 fi
155 [ "$FBSPLASH" == "yes" ] && echo "80" > /etc/fbsplash/fifo
157 # Set the console keymap and configure i18n in case of screen=text and
158 # no locale.conf or keymap.conf. Add default user for live mode and
159 # mount an eventual /home partition.
160 /etc/init.d/i18n.sh
161 /etc/init.d/user-home.sh
163 [ "$FBSPLASH" == "yes" ] && echo "100" > /etc/fbsplash/fifo
165 # Now that we have a keymap configuration we can auto configure Xorg.
166 # We need to set $HOME.
167 if [ "$SCREEN" != "text" -a ! -s /etc/X11/xorg.conf -a -x /usr/bin/Xorg ]; then
168 echo "Configuring Xorg..."
169 HOME=/root
170 tazx config-xorg
171 fi
173 # Here we finish bootsplash since we start Xorg session.
174 [ "$FBSPLASH" == "yes" ] && sleep 1 && echo "exit" > /etc/fbsplash/fifo
176 # No text mode requested, we have i18n and Xorg settings as well as a
177 # user, so start a desktop and let boot process finih in backgroud.
178 if [ "$screen" != "text" -a -x /etc/init.d/slim ]; then
179 /etc/init.d/slim start
180 fi
182 # Create /dev/cdrom if needed (symlink does not exist on LiveCD).
183 # Also add /dev/cdrom to fstab if entry does not exist.
184 if [ -n "$CDROM" ]; then
185 DRIVE_NAME=${CDROM#/dev/}
186 else
187 DRIVE_NAME=$(grep -s "drive name" /proc/sys/dev/cdrom/info | cut -f 3)
188 fi
189 if [ -n "$DRIVE_NAME" -a ! "`readlink /dev/cdrom`" ]; then
190 echo -n "Creating symlink : /dev/cdrom..."
191 ln -s /dev/$DRIVE_NAME /dev/cdrom
192 ln -s /dev/$DRIVE_NAME /dev/dvd
193 status
194 fi
195 if ! grep -q "/dev/cdrom" /etc/fstab; then
196 echo -n "Adding /dev/cdrom to fstab..."
197 echo '/dev/cdrom /media/cdrom iso9660 user,ro,noauto 0 0' \
198 >> /etc/fstab
199 status
200 fi
202 # Chmod hack on each boot for Asunder and burnbox. Allowing all users
203 # to burn/rip CD/DVD.
204 if [ -n "$DRIVE_NAME" -a "`readlink /dev/cdrom`" ]; then
205 echo -n "Chmoding cdrom device..."
206 chmod 0666 /dev/cdrom
207 chmod 0666 /dev/dvd
208 chmod 0666 /dev/$DRIVE_NAME
209 status
210 fi
212 # Handle kernel cmdline parameter modprobe=<module_list>
213 if [ -n "$MODPROBE" ]; then
214 MODULES=`sed -e 's/.* modprobe=\([^ ]*\).*/\1/' -e 's/,/\n/g' < /proc/cmdline`
215 for i in $MODULES; do
216 echo -n "Loading kernel module $i"
217 /sbin/modprobe $i
218 status
219 done
220 fi
222 # Handle kernel cmdline parameter config=<device>,<path> to source a
223 # disk init script
224 if [ -n "$CONFIG" ]; then
225 DEVICE=${CONFIG%,*}
226 SCRIPT=${CONFIG#*,}
227 echo "Probing $DEVICE... "
228 if ! /bin/mount -r $DEVICE /mnt; then
229 if echo $DEVICE | grep -Eq "/dev/sd|UUID=|LABEL="; then
230 USBDELAY=`cat /sys/module/usb_storage/parameters/delay_use`
231 USBDELAY=$((1+$USBDELAY))
232 echo "$DEVICE is potentially a USB device: sleep for $USBDELAY seconds"
233 sleep $USBDELAY
234 fi
235 if ! /bin/mount -r $DEVICE /mnt; then
236 CONFIG=""
237 fi
238 fi
239 echo -n "Source $SCRIPT from $DEVICE..."
240 if [ -n "$CONFIG" ]; then
241 . /mnt/$SCRIPT
242 /bin/umount /mnt 2> /dev/null || true
243 fi
244 status
245 fi
247 # Mount /proc/bus/usb.
248 if [ -d /proc/bus/usb ]; then
249 echo -n "Mounting /proc/bus/usb filesystem..."
250 /bin/mount -t usbfs usbfs /proc/bus/usb
251 status
252 fi
254 # Start syslogd and klogd.
255 if [ "$KERNEL_LOG_DAEMONS" = "yes" ]; then
256 echo -n "Starting system log deamon: syslogd..."
257 /sbin/syslogd -s $SYSLOGD_ROTATED_SIZE && status
258 echo -n "Starting kernel log daemon: klogd..."
259 /sbin/klogd && status
260 else
261 echo "Kernel log daemons are disabled in /etc/rc.conf..."
262 fi
264 # Load all modules listed in config file.
265 if [ -n "$LOAD_MODULES" ]; then
266 for mod in $LOAD_MODULES
267 do
268 modprobe $mod
269 done
270 fi
272 # Be quiet on configuration to avoid messages overwriting ncurses dialog
273 echo "0 0 0 0" > /proc/sys/kernel/printk
275 # Detect PCI and USB devices with Tazhw from slitaz-tools. We load
276 # kernel modules only at first boot or in LiveCD mode.
277 if [ ! -s /var/lib/detected-modules ]; then
278 /sbin/tazhw init
279 fi
281 # Auto recharge packages list (after network connection of course)
282 [ "$RECHARGE_PACKAGES_LIST" == "yes" ] && tazpkg recharge &
284 # Start all scripts specified with $RUN_SCRIPTS.
285 echo "Executing all initialization scripts..."
286 for script in $RUN_SCRIPTS
287 do
288 if [ -x /etc/init.d/$script ]; then
289 /etc/init.d/$script
290 fi
291 done
293 # Start all daemons specified with $RUN_DAEMONS.
294 echo "Starting all daemons specified in /etc/rcS.conf..."
295 for daemon in $RUN_DAEMONS
296 do
297 if [ -x /etc/init.d/$daemon ]; then
298 /etc/init.d/$daemon start
299 fi
300 done
302 # Back to a verbose mode.
303 echo "7 4 1 7" > /proc/sys/kernel/printk
305 # Reset screen and display a bold message.
306 if [ -n "$MESSAGE" ]; then
307 /usr/bin/reset
308 echo -e "\033[1m$MESSAGE\033[0m"
309 fi
311 # Display and log boot time.
312 time=$((`date +%s` - $bootdate))
313 echo $time > /var/log/boot-time
314 echo "SliTaz boot time: ${time}s"
316 fi # logged