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

rcS: fix config= for usb
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Jul 23 10:19:50 2008 +0000 (2008-07-23)
parents 58cc6775e0f0
children 17c69f17fb52
line source
1 #!/bin/sh
2 # /etc/init.d/rcS - Initial boot script for SliTaz GNU/Linux. rcS is the main
3 # initialization script used to check fs, mount, clean, run scripts and start
4 # daemons.
5 #
6 # Config file is : /etc/rcS.conf
7 #
8 . /etc/init.d/rc.functions
9 . /etc/rcS.conf
11 if [ "$1" != "logged" ]; then #logged
13 # Start by sleeping a bit.
14 echo "Processing /etc/init.d/rcS... "
15 sleep 1
17 # Mount /proc.
18 echo -n "Mounting proc filesystem... "
19 /bin/mount proc
20 status && sleep 1
22 # Before mounting filesystems we check fs specified in the file
23 # /etc/rcS.conf and variable $CHECK_FS.
24 if [ ! "$CHECK_FS" = "" ]; then
25 mount -o remount,ro /
26 for i in $CHECK_FS
27 do
28 echo "Checking filesystem on : $i"
29 /sbin/e2fsck -p $i
30 sleep 2
31 done
32 fi
34 # Remount rootfs rw.
35 echo "Remounting rootfs read/write... "
36 /bin/mount -o remount,rw /
38 # Mount filesystems in /etc/fstab.
39 echo "Mounting filesystems in fstab... "
40 /bin/mount -a
42 # Start Udev to populate /dev and handle hotplug events
43 if [ "$UDEV" = "yes" ]; then
44 echo -n "Starting udev daemon..."
45 /sbin/udevd --daemon
46 status
47 echo "/sbin/udevd" > /proc/sys/kernel/hotplug
48 fi
50 /bin/dmesg > /var/log/dmesg.log
51 vcsa2txt < /dev/vcsa1 | awk 'BEGIN {s=0} /^Processing/ {s=1} { if (s) print }' >/var/log/boot.log
52 script -a -q -c '/etc/init.d/rcS logged' /var/log/boot.log
54 else #logged
56 # Create /dev/cdrom if needed (symlink does not exist on LiveCD).
57 # Also add /dev/cdrom to fstab if entry does not exist.
58 #
59 DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3`
60 if grep -q " cdrom=" /proc/cmdline; then
61 DRIVE_NAME=`cat /proc/cmdline | sed 's/.* cdrom=\([^ ]*\).*/\1/'`
62 fi
63 if [ -n "$DRIVE_NAME" -a ! "`readlink /dev/cdrom`" ]; then
64 echo -n "Creating symlink : /dev/cdrom..."
65 ln -s /dev/$DRIVE_NAME /dev/cdrom
66 ln -s /dev/$DRIVE_NAME /dev/dvd
67 status
68 fi
69 if ! grep -q "/dev/cdrom" /etc/fstab; then
70 echo -n "Adding /dev/cdrom to fstab..."
71 echo '/dev/cdrom /media/cdrom iso9660 user,ro,noauto 0 0' \
72 >> /etc/fstab
73 status
74 fi
75 # Chmod hack on each boot for Asunder and burnbox. Allowing all users
76 # to burn/rip CD/DVD.
77 if [ -n "$DRIVE_NAME" -a "`readlink /dev/cdrom`" ]; then
78 echo -n "Chmoding cdrom device..."
79 chmod 0666 /dev/cdrom
80 chmod 0666 /dev/dvd
81 chmod 0666 /dev/$DRIVE_NAME
82 status
83 fi
85 # Handle kernel cmdline parameter modprobe=<module_list>
86 if grep -q " modprobe=" /proc/cmdline; then
87 MODULES=`sed -e 's/.* modprobe=\([^ ]*\).*/\1/' -e 's/,/\n/g' < /proc/cmdline`
88 for i in $MODULES; do
89 echo -n "Loading kernel module $i"
90 /sbin/modprobe $i
91 status
92 done
93 fi
95 # Handle kernel cmdline parameter config=<device>,<path> to source a
96 # disk init script
97 if grep -q " config=" /proc/cmdline; then
98 CONFIG=`cat /proc/cmdline | sed 's/.* config=\([^ ]*\).*/\1/'`
99 DEVICE=${CONFIG%,*}
100 SCRIPT=${CONFIG#*,}
101 echo "Probing $DEVICE... "
102 if ! /bin/mount -r $DEVICE /mnt; then
103 if echo $DEVICE | grep -q "/dev/sd"; then
104 USBDELAY=`cat /sys/module/usb_storage/parameters/delay_use`
105 USBDELAY=$((1+$USBDELAY))
106 echo "$DEVICE is potentially a USB device: sleep for $USBDELAY seconds"
107 sleep $USBDELAY
108 fi
109 if ! /bin/mount -r $DEVICE /mnt; then
110 CONFIG=""
111 fi
112 fi
113 echo -n "Source $SCRIPT from $DEVICE... "
114 if [ -n "$CONFIG" ]; then
115 . /mnt/$SCRIPT
116 /bin/umount /mnt
117 fi
118 status
119 fi
121 # Eject option
122 if grep -q -w "eject" /proc/cmdline; then
123 eject /dev/cdrom
124 fi
126 # Start syslogd and klogd.
127 if [ "$KERNEL_LOG_DAEMONS" = "yes" ]; then
128 echo -n "Starting system log deamon: syslogd... "
129 /sbin/syslogd -s $SYSLOGD_ROTATED_SIZE && status
130 echo -n "Starting kernel log daemon: klogd... "
131 /sbin/klogd && status
132 else
133 echo "Kernel log daemons are disabled in /etc/rc.conf... "
134 fi
136 # Clean up the system.
137 if [ "$CLEAN_UP_SYSTEM" = "yes" ]; then
138 echo -n "Cleaning up the system... "
139 rm -rf /tmp/* /tmp/.* 2> /dev/null
140 rm -f /var/run/*.pid /var/run/dbus/* /var/run/hald/pid
141 rm -f /var/lock/*
142 status
143 else
144 echo "System clean up is disabled in /etc/rcS.conf... "
145 echo "Keeping all tmp and pid files... "
146 status
147 fi
149 # Set up tmp X11 and ICE dir.
150 echo -n "Setting up tmp X11 and ICE unix dir... "
151 /bin/mkdir -p /tmp/.X11-unix
152 /bin/mkdir -p /tmp/.ICE-unix
153 /bin/chmod 1777 /tmp/.X11-unix
154 /bin/chmod 1777 /tmp/.ICE-unix
155 status
157 # Load all modules listed in config file.
158 if [ ! "$LOAD_MODULES" = "" ]; then
159 for mod in $LOAD_MODULES
160 do
161 modprobe $mod
162 done
163 fi
165 # Start all scripts specified with $RUN_SCRIPTS.
166 echo "Executing all initialization scripts..."
167 for script in $RUN_SCRIPTS
168 do
169 if [ -x /etc/init.d/$script ]; then
170 /etc/init.d/$script
171 fi
172 done
174 # Re-source main config file. In Live mode, daemons list can be modified
175 # by boot options.
176 . /etc/rcS.conf
178 # Start all daemons specified with $RUN_DAEMONS.
179 echo "Starting all daemons specified in /etc/rcS.conf..."
180 for daemon in $RUN_DAEMONS
181 do
182 if [ -x /etc/init.d/$daemon ]; then
183 /etc/init.d/$daemon start
184 fi
185 done
187 # Reset screen and display a bold message.
188 if [ -n "$MESSAGE" ]; then
189 /usr/bin/reset
190 echo -e "\033[1m$MESSAGE\033[0m"
191 fi
193 fi #logged