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

rcS: export SCREEN and source functions in user-home.sh
author Christophe Lincoln <pankso@slitaz.org>
date Fri Apr 29 17:43:22 2011 +0200 (2011-04-29)
parents a14abff6be90
children 63eaa6ed9233
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 waiting for the event queue to finish..."
98 udevadm settle
99 status
100 echo -n "Using Udev for hotplugging..."
101 echo "/sbin/udevd" > /proc/sys/kernel/hotplug
102 status
103 fi
105 [ "$FBSPLASH" == "yes" ] && echo "60" > /etc/fbsplash/fifo
107 # Mount filesystems in /etc/fstab.
108 echo "Mounting filesystems in fstab..."
109 /bin/mount -a
111 # Store boot messages to log files.
112 /bin/dmesg > /var/log/dmesg.log &
113 conspy -d | sed 's/ *$//;/^$/d;/^Processi\|^.witchi/,$!d' > /var/log/boot.log
114 script -a -q -c '/etc/init.d/rcS logged' /var/log/boot.log
116 else # logged
118 # Clean up the system.
119 if [ "$CLEAN_UP_SYSTEM" = "yes" ]; then
120 echo -n "Cleaning up the system..."
121 find /var/run -name "*.pid" -type f | xargs /bin/rm -f
122 /bin/rm -rf /tmp /var/run/dbus/* /var/run/hald/pid /var/lock/*
123 /bin/mkdir -p /tmp && /bin/chmod 1777 /tmp
124 status
125 else
126 echo "System clean up is disabled in /etc/rcS.conf..."
127 echo -n "Keeping all tmp and pid files..."
128 status
129 fi
131 [ "$FBSPLASH" == "yes" ] && echo "70" > /etc/fbsplash/fifo
133 # Set up tmp X11 and ICE dir.
134 echo -n "Setting up tmp X11 and ICE unix dir..."
135 /bin/mkdir -p /tmp/.X11-unix /tmp/.ICE-unix
136 /bin/chmod 1777 /tmp/.X11-unix /tmp/.ICE-unix
137 status
139 # Start DBUS and HAL deamon so we can use Xorg and a WM to configure
140 # system locale and keybord on first boot.
141 [ -x /etc/init.d/dbus ] && /etc/init.d/dbus start
142 [ -x /etc/init.d/hald ] && /etc/init.d/hald start
144 # Requested screen is not text mode and keymap.conf is empty so go
145 # for an i18n configuration in GUI mode. In cas of screen=text we
146 # configure locale and keymap just after via i18n.sh
147 if [ "$SCREEN" != "text" -a ! -s "/etc/locale.conf" -a -x /usr/bin/Xorg ]; then
148 tazbox boot
149 fi
151 [ "$FBSPLASH" == "yes" ] && echo "80" > /etc/fbsplash/fifo
153 # Set the console keymap and configure i18n in case of screen=text and
154 # no locale.conf or keymap.conf. Add default user for live mode and
155 # mount an eventual /home partition.
156 /etc/init.d/i18n.sh
157 /etc/init.d/user-home.sh
159 [ "$FBSPLASH" == "yes" ] && echo "100" > /etc/fbsplash/fifo
161 # Now that we have a keymap configuration we can auto configure Xorg.
162 # We need to set $HOME.
163 if [ "$SCREEN" != "text" -a ! -s /etc/X11/xorg.conf -a -x /usr/bin/Xorg ]; then
164 echo "Configuring Xorg..."
165 HOME=/root
166 tazx config-xorg
167 fi
169 # Here we finish bootsplash since we start Xorg session.
170 [ "$FBSPLASH" == "yes" ] && sleep 1 && echo "exit" > /etc/fbsplash/fifo
172 # No text mode requested, we have i18n and Xorg settings as well as a
173 # user, so start a desktop and let boot process finih in backgroud.
174 if [ "$SCREEN" != "text" -a -x /etc/init.d/slim ]; then
175 /etc/init.d/slim start
176 fi
178 # Create /dev/cdrom if needed (symlink does not exist on LiveCD).
179 # Also add /dev/cdrom to fstab if entry does not exist.
180 if [ -n "$CDROM" ]; then
181 DRIVE_NAME=${CDROM#/dev/}
182 else
183 DRIVE_NAME=$(grep -s "drive name" /proc/sys/dev/cdrom/info | cut -f 3)
184 fi
185 if [ -n "$DRIVE_NAME" -a ! "`readlink /dev/cdrom`" ]; then
186 echo -n "Creating symlink : /dev/cdrom..."
187 ln -s /dev/$DRIVE_NAME /dev/cdrom
188 ln -s /dev/$DRIVE_NAME /dev/dvd
189 status
190 fi
191 if ! grep -q "/dev/cdrom" /etc/fstab; then
192 echo -n "Adding /dev/cdrom to fstab..."
193 echo '/dev/cdrom /media/cdrom iso9660 user,ro,noauto 0 0' \
194 >> /etc/fstab
195 status
196 fi
198 # Chmod hack on each boot for Asunder and burnbox. Allowing all users
199 # to burn/rip CD/DVD.
200 if [ -n "$DRIVE_NAME" -a "`readlink /dev/cdrom`" ]; then
201 echo -n "Chmoding cdrom device..."
202 chmod 0666 /dev/cdrom
203 chmod 0666 /dev/dvd
204 chmod 0666 /dev/$DRIVE_NAME
205 status
206 fi
208 # Handle kernel cmdline parameter modprobe=<module_list>
209 if [ -n "$MODPROBE" ]; then
210 MODULES=`sed -e 's/.* modprobe=\([^ ]*\).*/\1/' -e 's/,/\n/g' < /proc/cmdline`
211 for i in $MODULES; do
212 echo -n "Loading kernel module $i"
213 /sbin/modprobe $i
214 status
215 done
216 fi
218 # Handle kernel cmdline parameter config=<device>,<path> to source a
219 # disk init script
220 if [ -n "$CONFIG" ]; then
221 DEVICE=${CONFIG%,*}
222 SCRIPT=${CONFIG#*,}
223 echo "Probing $DEVICE... "
224 if ! /bin/mount -r $DEVICE /mnt; then
225 if echo $DEVICE | grep -Eq "/dev/sd|UUID=|LABEL="; then
226 USBDELAY=`cat /sys/module/usb_storage/parameters/delay_use`
227 USBDELAY=$((1+$USBDELAY))
228 echo "$DEVICE is potentially a USB device: sleep for $USBDELAY seconds"
229 sleep $USBDELAY
230 fi
231 if ! /bin/mount -r $DEVICE /mnt; then
232 CONFIG=""
233 fi
234 fi
235 echo -n "Source $SCRIPT from $DEVICE..."
236 if [ -n "$CONFIG" ]; then
237 . /mnt/$SCRIPT
238 /bin/umount /mnt 2> /dev/null || true
239 fi
240 status
241 fi
243 # Mount /proc/bus/usb.
244 if [ -d /proc/bus/usb ]; then
245 echo -n "Mounting /proc/bus/usb filesystem..."
246 /bin/mount -t usbfs usbfs /proc/bus/usb
247 status
248 fi
250 # Start syslogd and klogd.
251 if [ "$KERNEL_LOG_DAEMONS" = "yes" ]; then
252 echo -n "Starting system log deamon: syslogd..."
253 /sbin/syslogd -s $SYSLOGD_ROTATED_SIZE && status
254 echo -n "Starting kernel log daemon: klogd..."
255 /sbin/klogd && status
256 else
257 echo "Kernel log daemons are disabled in /etc/rc.conf..."
258 fi
260 # Load all modules listed in config file.
261 if [ -n "$LOAD_MODULES" ]; then
262 for mod in $LOAD_MODULES
263 do
264 modprobe $mod
265 done
266 fi
268 # Be quiet on configuration to avoid messages overwriting ncurses dialog
269 echo "0 0 0 0" > /proc/sys/kernel/printk
271 # Detect PCI and USB devices with Tazhw from slitaz-tools. We load
272 # kernel modules only at first boot or in LiveCD mode.
273 if [ ! -s /var/lib/detected-modules ]; then
274 /sbin/tazhw init
275 fi
277 # Auto recharge packages list (after network connection of course)
278 [ "$RECHARGE_PACKAGES_LIST" == "yes" ] && tazpkg recharge &
280 # Start all scripts specified with $RUN_SCRIPTS.
281 echo "Executing all initialization scripts..."
282 for script in $RUN_SCRIPTS
283 do
284 if [ -x /etc/init.d/$script ]; then
285 /etc/init.d/$script
286 fi
287 done
289 # Start all daemons specified with $RUN_DAEMONS.
290 echo "Starting all daemons specified in /etc/rcS.conf..."
291 for daemon in $RUN_DAEMONS
292 do
293 if [ -x /etc/init.d/$daemon ]; then
294 /etc/init.d/$daemon start
295 fi
296 done
298 # Back to a verbose mode.
299 echo "7 4 1 7" > /proc/sys/kernel/printk
301 # Reset screen and display a bold message.
302 if [ -n "$MESSAGE" ]; then
303 /usr/bin/reset
304 echo -e "\033[1m$MESSAGE\033[0m"
305 fi
307 # Display and log boot time.
308 time=$((`date +%s` - $bootdate))
309 echo $time > /var/log/boot-time
310 echo "SliTaz boot time: ${time}s"
312 fi # logged