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

rcS: create missing devices
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Aug 05 08:45:37 2008 +0000 (2008-08-05)
parents d6f7d8765539
children 992e3ee958ad
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 missing devices
57 mdev -s 2> /dev/null
59 # Create /dev/cdrom if needed (symlink does not exist on LiveCD).
60 # Also add /dev/cdrom to fstab if entry does not exist.
61 #
62 DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3`
63 if grep -q " cdrom=" /proc/cmdline; then
64 DRIVE_NAME=`cat /proc/cmdline | sed 's/.* cdrom=\([^ ]*\).*/\1/'`
65 fi
66 if [ -n "$DRIVE_NAME" -a ! "`readlink /dev/cdrom`" ]; then
67 echo -n "Creating symlink : /dev/cdrom..."
68 ln -s /dev/$DRIVE_NAME /dev/cdrom
69 ln -s /dev/$DRIVE_NAME /dev/dvd
70 status
71 fi
72 if ! grep -q "/dev/cdrom" /etc/fstab; then
73 echo -n "Adding /dev/cdrom to fstab..."
74 echo '/dev/cdrom /media/cdrom iso9660 user,ro,noauto 0 0' \
75 >> /etc/fstab
76 status
77 fi
78 # Chmod hack on each boot for Asunder and burnbox. Allowing all users
79 # to burn/rip CD/DVD.
80 if [ -n "$DRIVE_NAME" -a "`readlink /dev/cdrom`" ]; then
81 echo -n "Chmoding cdrom device..."
82 chmod 0666 /dev/cdrom
83 chmod 0666 /dev/dvd
84 chmod 0666 /dev/$DRIVE_NAME
85 status
86 fi
88 # Handle kernel cmdline parameter modprobe=<module_list>
89 if grep -q " modprobe=" /proc/cmdline; then
90 MODULES=`sed -e 's/.* modprobe=\([^ ]*\).*/\1/' -e 's/,/\n/g' < /proc/cmdline`
91 for i in $MODULES; do
92 echo -n "Loading kernel module $i"
93 /sbin/modprobe $i
94 status
95 done
96 fi
98 # Handle kernel cmdline parameter config=<device>,<path> to source a
99 # disk init script
100 if grep -q " config=" /proc/cmdline; then
101 CONFIG=`cat /proc/cmdline | sed 's/.* config=\([^ ]*\).*/\1/'`
102 DEVICE=${CONFIG%,*}
103 SCRIPT=${CONFIG#*,}
104 echo "Probing $DEVICE... "
105 if ! /bin/mount -r $DEVICE /mnt; then
106 if echo $DEVICE | grep -q "/dev/sd"; then
107 USBDELAY=`cat /sys/module/usb_storage/parameters/delay_use`
108 USBDELAY=$((1+$USBDELAY))
109 echo "$DEVICE is potentially a USB device: sleep for $USBDELAY seconds"
110 sleep $USBDELAY
111 fi
112 if ! /bin/mount -r $DEVICE /mnt; then
113 CONFIG=""
114 fi
115 fi
116 echo -n "Source $SCRIPT from $DEVICE... "
117 if [ -n "$CONFIG" ]; then
118 . /mnt/$SCRIPT
119 /bin/umount /mnt
120 fi
121 status
122 fi
124 # Eject option
125 if grep -q -w "eject" /proc/cmdline; then
126 eject /dev/cdrom
127 fi
129 # Start syslogd and klogd.
130 if [ "$KERNEL_LOG_DAEMONS" = "yes" ]; then
131 echo -n "Starting system log deamon: syslogd... "
132 /sbin/syslogd -s $SYSLOGD_ROTATED_SIZE && status
133 echo -n "Starting kernel log daemon: klogd... "
134 /sbin/klogd && status
135 else
136 echo "Kernel log daemons are disabled in /etc/rc.conf... "
137 fi
139 # Clean up the system.
140 if [ "$CLEAN_UP_SYSTEM" = "yes" ]; then
141 echo -n "Cleaning up the system... "
142 rm -rf /tmp/* /tmp/.* 2> /dev/null
143 rm -f /var/run/*.pid /var/run/dbus/* /var/run/hald/pid
144 rm -f /var/lock/*
145 status
146 else
147 echo "System clean up is disabled in /etc/rcS.conf... "
148 echo "Keeping all tmp and pid files... "
149 status
150 fi
152 # Set up tmp X11 and ICE dir.
153 echo -n "Setting up tmp X11 and ICE unix dir... "
154 /bin/mkdir -p /tmp/.X11-unix
155 /bin/mkdir -p /tmp/.ICE-unix
156 /bin/chmod 1777 /tmp/.X11-unix
157 /bin/chmod 1777 /tmp/.ICE-unix
158 status
160 # Load all modules listed in config file.
161 if [ ! "$LOAD_MODULES" = "" ]; then
162 for mod in $LOAD_MODULES
163 do
164 modprobe $mod
165 done
166 fi
168 # Start all scripts specified with $RUN_SCRIPTS.
169 echo "Executing all initialization scripts..."
170 for script in $RUN_SCRIPTS
171 do
172 if [ -x /etc/init.d/$script ]; then
173 /etc/init.d/$script
174 fi
175 done
177 # Re-source main config file. In Live mode, daemons list can be modified
178 # by boot options.
179 . /etc/rcS.conf
181 # Start all daemons specified with $RUN_DAEMONS.
182 echo "Starting all daemons specified in /etc/rcS.conf..."
183 for daemon in $RUN_DAEMONS
184 do
185 if [ -x /etc/init.d/$daemon ]; then
186 /etc/init.d/$daemon start
187 fi
188 done
190 # Reset screen and display a bold message.
191 if [ -n "$MESSAGE" ]; then
192 /usr/bin/reset
193 echo -e "\033[1m$MESSAGE\033[0m"
194 fi
196 fi #logged