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

etc/init.d/rcS: fix "Searching for early boot options..." status.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu Oct 05 15:33:26 2017 +0300 (2017-10-05)
parents f12914c09028
children d6f110850f61
line source
1 #!/bin/sh
2 #
3 # /etc/init.d/rcS : Initial boot script for SliTaz GNU/Linux
4 # Configuration file : /etc/rcS.conf
5 #
6 # rcS is the main initialization script used to check fs, mount, clean,
7 # run scripts and start daemons.
8 #
9 . /etc/init.d/rc.functions
10 . /etc/rcS.conf
12 # Set PATH, TZ and boot time.
13 export PATH=/bin:/sbin:/usr/bin:/usr/sbin
14 [ -s /etc/TZ ] && export TZ="$(cat /etc/TZ)"
16 case "$1" in
17 readonly)
18 colorize 34 'Processing /etc/init.d/rcS...'
20 # Mount /proc
21 action 'Mounting proc filesystem on /proc'
22 mount proc
23 status
25 # Trigger udev and handle hotplug events
26 if [ "$UDEV" == 'yes' ]; then
27 action 'Mounting devtmpfs filesystem on /dev'
28 mount -t devtmpfs devtmpfs /dev
29 status
30 [ -d '/lib/udev/devices' ] && cp -af /lib/udev/devices/* /dev/
32 if [ -d '/etc/udev/hwdb.d' ]; then
33 echo 'Creating the udev hardware database...'
34 udevadm hwdb --update
35 fi
37 echo 'Starting udev daemon...'
38 udevd --daemon 2>/dev/null
40 echo 'Udevadm requesting events from the Kernel...'
41 udevadm trigger
43 echo 'Udevadm waiting for the event queue to finish...'
44 udevadm settle --timeout=120
45 # Disable hotplug helper since udevd listen to netlink
46 echo '' > /proc/sys/kernel/hotplug
47 else
48 action 'Executing mdev -s to populate /dev...'
49 mdev -s && echo 'mdev' > /proc/sys/kernel/hotplug
50 status
51 fi
53 # Before mounting filesystems we check FS specified in the file
54 # /etc/rcS.conf and variable $CHECK_FS. We need udev started to
55 # have /dev/* populated
56 if [ -n "$CHECK_FS" ]; then
57 mount -o remount,ro /
58 for i in $CHECK_FS; do
59 colorize 36 "Checking filesystem: $i"
60 e2fsck -p $i
61 done
62 fi
64 # Remount rootfs rw.
65 echo 'Remounting rootfs read/write...'
66 mount -o remount,rw /
67 sync # ensure rw state
69 # Mount filesystems in /etc/fstab.
70 echo 'Mounting filesystems in fstab...'
71 mount -a
72 ;;
74 readwrite)
75 # Be quiet
76 echo '0 0 0 0' > /proc/sys/kernel/printk
78 # Store boot messages to log files.
79 dmesg > /var/log/dmesg.log &
81 # Parse cmdline args for earlier boot options. All other boot options
82 # are in /etc/init./bootopts.sh.
83 action 'Searching for early boot options...'
84 opt=$(cmdline_option modprobe); [ -z "$opt" ] || export MODPROBE='yes'
85 opt=$(cmdline_option config); [ -z "$opt" ] || export CONFIG="$opt"
86 opt=$(cmdline_option screen); [ -z "$opt" ] || export SCREEN="$opt"
87 status
89 # Clean up the system and set up tmp dirs.
90 # */run/* are tmpfs so they are cleaned up at shutdown.
91 if [ "$CLEAN_UP_SYSTEM" == 'yes' ]; then
92 action 'Cleaning up the system...'
93 rm -rf /tmp
94 mkdir -p /tmp/.X11-unix /tmp/.ICE-unix
95 chmod -R 1777 /tmp
96 status
97 else
98 echo 'System clean up is disabled in /etc/rcS.conf'
99 fi
101 # Handle kernel cmdline parameter modprobe=<module_list>
102 if [ -n "$MODPROBE" ]; then
103 for i in $(cmdline_option modprobe | tr ',' '\n'); do
104 action 'Loading kernel module: %s' "$i"
105 modprobe $i
106 status
107 done
108 fi
110 # Handle kernel cmdline parameter config=<device>,<path> to source a
111 # disk init script
112 if [ -n "$CONFIG" ]; then
113 DEVICE=${CONFIG%,*}
114 SCRIPT=${CONFIG#*,}
115 echo "Probing $DEVICE..."
116 if ! mount -r $DEVICE /mnt; then
117 if echo $DEVICE | grep -Eq '/dev/sd|UUID=|LABEL='; then
118 USBDELAY=$(cat /sys/module/usb_storage/parameters/delay_use)
119 USBDELAY=$((1+$USBDELAY))
120 echo "$DEVICE is potentially a USB device: sleep for $USBDELAY seconds"
121 sleep $USBDELAY
122 fi
123 if ! mount -r $DEVICE /mnt; then
124 CONFIG=''
125 fi
126 fi
127 action 'Source %s from %s...' "$SCRIPT" "$DEVICE"
128 if [ -n "$CONFIG" ]; then
129 . /mnt/$SCRIPT
130 umount /mnt 2>/dev/null || true
131 fi
132 status
133 fi
135 # Mount /proc/bus/usb
136 if [ -d '/proc/bus/usb' ]; then
137 action 'Mounting usbfs filesystem on /proc/bus/usb'
138 mount -t usbfs usbfs /proc/bus/usb
139 status
140 fi
142 # Start syslogd and klogd
143 action 'Starting system log daemon: syslogd...'
144 syslogd -s $SYSLOGD_ROTATED_SIZE; status
145 action 'Starting kernel log daemon: klogd...'
146 klogd; status
148 # Load all modules listed in config file
149 if [ -n "$LOAD_MODULES" ]; then
150 colorize 33 'Loading Kernel modules...'
151 for mod in $LOAD_MODULES; do
152 action 'Loading module: %s' "$mod"
153 modprobe $mod
154 status
155 done
156 fi
158 # Detect PCI and USB devices with Tazhw from slitaz-tools. We load
159 # kernel modules only at first boot or in Live CD mode.
160 if [ ! -s '/var/lib/detected-modules' ]; then
161 tazhw init
162 fi
164 # Call udevadm trigger to ensure /dev is fully populated now that all
165 # modules are loaded.
166 if [ "$UDEV" == 'yes' ]; then
167 action 'Triggering udev events: --action=add'
168 udevadm trigger --action=add
169 status
170 fi
172 # Start all scripts specified with $RUN_SCRIPTS
173 for script in $RUN_SCRIPTS; do
174 colorize 34 "Processing /etc/init.d/$script"
175 /etc/init.d/$script
176 done
178 # Start X session. Dbus must be started before Xorg and other daemons.
179 # We started it here because X is run before RUN_DAEMONS. Sleep, in
180 # some live modes we boot too fast and X can't initialize.
181 if [ "$SCREEN" != 'text' -a \
182 -n "$LOGIN_MANAGER" -a \
183 -x '/usr/bin/tazx' -a \
184 -s '/etc/slitaz/applications.conf' -a \
185 -x "/etc/init.d/$LOGIN_MANAGER" ]; then
186 colorize 36 'Starting X environment...'
187 # We need Xorg 40-Keyboard.conf and SliTaz applications.conf
188 if [ ! -s '/etc/X11/xorg.conf.d/40-Keyboard.conf' ]; then
189 echo 'Configuring Xorg server...'
190 HOME='/root'
191 tazx init
192 fi
193 /etc/init.d/dbus start
194 (sleep 2; /etc/init.d/$LOGIN_MANAGER start >/dev/null) &
195 fi
197 # Start all daemons specified with $RUN_DAEMONS
198 if [ -n "$RUN_DAEMONS" ]; then
199 colorize 33 "Starting all daemons..."
200 for daemon in $RUN_DAEMONS; do
201 [ -x "/etc/init.d/$daemon" ] && /etc/init.d/$daemon start
202 done
203 fi
205 # Back to a verbose mode
206 (sleep 6; echo '7 4 1 7' > /proc/sys/kernel/printk) &
208 if [ -n "$MESSAGE" ]; then
209 newline
210 colorize 32 "$MESSAGE"
211 fi
212 ;;
214 *)
215 # Main entry point.
216 # --> readonly --> readwrite
217 if [ ! -s '/run/boot.log' ]; then
218 # Mount /run as tmpfs runtime data are not written to disk
219 mount -t tmpfs tmpfs /run
220 # cp -a in tazpkg does not support /var/run symlink
221 mount --bind /run /var/run
222 fi
224 /etc/init.d/rcS readonly 2>&1 | tee -a /run/boot.log
226 # Logrotate boot.log
227 last='.9'
228 for i in .8 .7 .6 .5 .4 .3 .2 .1 .0 ''; do
229 mv -f "/var/log/boot.log$i" "/var/log/boot.log$last" 2>/dev/null
230 last="$i"
231 done
232 mv -f /run/boot.log /var/log/boot.log
234 /etc/init.d/rcS readwrite 2>&1 | tee -a /var/log/boot.log
235 ;;
236 esac