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

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