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

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