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

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