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