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

Start Dbus daemon befor X = fix a part of automounting issue and Skype dbus errors
author Christophe Lincoln <pankso@slitaz.org>
date Mon May 05 18:58:33 2014 +0200 (2014-05-05)
parents 3671428835e5
children fba11a13a321
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
18 readonly)
20 colorize 34 "Processing: /etc/init.d/rcS..."
22 # Mount /proc
23 echo -n "Mounting proc filesystem on /proc"
24 mount proc && status
26 # Trigger Udev and handle hotplug events
27 if [ "$UDEV" == "yes" ]; then
28 echo -n "Mounting devtmpfs filesystem on: /dev"
29 mount -t devtmpfs devtmpfs /dev
30 status
31 echo "Starting udev daemon..."
32 udevd --daemon 2>/dev/null
33 echo "Udevadm requesting events from the Kernel..."
34 udevadm trigger
35 echo "Udevadm waiting for the event queue to finish..."
36 udevadm settle --timeout=120
37 # Disable hotplug helper since udevd listen to netlink
38 echo "" > /proc/sys/kernel/hotplug
39 else
40 echo -n "Executing mdev -s to populate /dev..."
41 mdev -s && echo "mdev" > /proc/sys/kernel/hotplug
42 status
43 fi
45 # Before mounting filesystems we check fs specified in the file
46 # /etc/rcS.conf and variable $CHECK_FS. WE need udev started to
47 # have /dev/* populated
48 if [ "$CHECK_FS" ]; then
49 mount -o remount,ro /
50 for i in $CHECK_FS; do
51 colorize 36 "Checking filesystem: $i"
52 e2fsck -p $i
53 done
54 fi
56 # Remount rootfs rw.
57 echo "Remounting rootfs read/write..."
58 mount -o remount,rw /
60 # Mount filesystems in /etc/fstab.
61 echo "Mounting filesystems in fstab..."
62 mount -a
63 ;;
65 readwrite)
67 # Be quiet
68 echo "0 0 0 0" > /proc/sys/kernel/printk
70 # Store boot messages to log files.
71 dmesg > /var/log/dmesg.log &
73 # Parse cmdline args for earlier boot options. All other boot options
74 # are in /etc/init./bootopts.sh.
75 echo -n "Searching for early boot options..."
76 for opt in $(cat /proc/cmdline)
77 do
78 case $opt in
79 modprobe=*)
80 export MODPROBE="yes" ;;
81 config=*)
82 export CONFIG=${opt#config=} ;;
83 screen=*)
84 export SCREEN=${opt#screen=} ;;
85 *)
86 continue ;;
87 esac
88 done
89 status
91 # Clean up the system and set up tmp dirs. */run/* are tmpfs so they are
92 # cleaned up at shutdown.
93 if [ "$CLEAN_UP_SYSTEM" = "yes" ]; then
94 echo -n "Cleaning up the system..."
95 rm -rf /tmp
96 mkdir -p /tmp/.X11-unix /tmp/.ICE-unix
97 chmod -R 1777 /tmp
98 status
99 else
100 echo "System clean up is disabled in: /etc/rcS.conf"
101 fi
103 # Handle kernel cmdline parameter modprobe=<module_list>
104 if [ "$MODPROBE" ]; then
105 mods=$(sed -e 's/.* modprobe=\([^ ]*\).*/\1/' -e 's/,/\n/g' < /proc/cmdline)
106 for i in $mods; do
107 echo -n "Loading kernel module: $i"
108 modprobe $i
109 status
110 done
111 fi
113 # Handle kernel cmdline parameter config=<device>,<path> to source a
114 # disk init script
115 if [ -n "$CONFIG" ]; then
116 DEVICE=${CONFIG%,*}
117 SCRIPT=${CONFIG#*,}
118 echo "Probing $DEVICE... "
119 if ! mount -r $DEVICE /mnt; then
120 if echo $DEVICE | grep -Eq "/dev/sd|UUID=|LABEL="; then
121 USBDELAY=$(cat /sys/module/usb_storage/parameters/delay_use)
122 USBDELAY=$((1+$USBDELAY))
123 echo "$DEVICE is potentially a USB device: sleep for $USBDELAY seconds"
124 sleep $USBDELAY
125 fi
126 if ! mount -r $DEVICE /mnt; then
127 CONFIG=""
128 fi
129 fi
130 echo -n "Source $SCRIPT from $DEVICE..."
131 if [ -n "$CONFIG" ]; then
132 . /mnt/$SCRIPT
133 umount /mnt 2> /dev/null || true
134 fi
135 status
136 fi
138 # Mount /proc/bus/usb
139 if [ -d /proc/bus/usb ]; then
140 echo -n "Mounting usbfs filesystem on: /proc/bus/usb"
141 mount -t usbfs usbfs /proc/bus/usb
142 status
143 fi
145 # Start syslogd and klogd
146 echo -n "Starting system log daemon: syslogd..."
147 syslogd -s $SYSLOGD_ROTATED_SIZE && status
148 echo -n "Starting kernel log daemon: klogd..."
149 klogd && status
151 # Load all modules listed in config file
152 if [ "$LOAD_MODULES" ]; then
153 colorize 33 "Loading Kernel modules..."
154 for mod in $LOAD_MODULES; do
155 echo -n "Loading module: $mod"
156 modprobe $mod
157 status
158 done
159 fi
161 # Detect PCI and USB devices with Tazhw from slitaz-tools. We load
162 # kernel modules only at first boot or in LiveCD mode.
163 if [ ! -s /var/lib/detected-modules ]; then
164 tazhw init
165 fi
167 # Call udevadm trigger to ensure /dev is fully populated now that all
168 # modules are loaded.
169 if [ "$UDEV" = "yes" ]; then
170 echo -n "Triggering udev events: --action=add"
171 udevadm trigger --action=add
172 status
173 fi
175 # Start all scripts specified with $RUN_SCRIPTS
176 for script in $RUN_SCRIPTS; do
177 echo $(colorize 34 "Processing: /etc/init.d/$script")
178 /etc/init.d/$script
179 done
181 # Start X session. Dbus must be started before Xorg and other daemons.
182 # We started it here because X is run before RUN_DAEMONS. Sleep, in
183 # some in live mode we boot too fast and X can't initialize.
184 if [ "$SCREEN" != "text" ] && [ "$LOGIN_MANAGER" ] && \
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..." && HOME="/root"
190 tazx init
191 fi
192 /etc/init.d/dbus start
193 (sleep 2; /etc/init.d/${LOGIN_MANAGER} start >/dev/null) &
194 fi
196 # Start all daemons specified with $RUN_DAEMONS
197 if [ "$RUN_DAEMONS" ]; then
198 colorize 33 "Starting all daemons..."
199 for daemon in $RUN_DAEMONS; do
200 /etc/init.d/$daemon start
201 done
202 fi
204 # Back to a verbose mode
205 (sleep 6 && echo "7 4 1 7" > /proc/sys/kernel/printk) &
207 if [ "$MESSAGE" ]; then
208 newline
209 colorize 32 "$MESSAGE"
210 fi
211 ;;
213 *)
214 # --> readonly --> readwrite
215 if [ ! -s /run/boot.log ]; then
216 # Mount /run as tmpfs runtime data are not written to disk
217 mount -t tmpfs tmpfs /run
218 # cp -a in tazpkg does not support /var/run symlink
219 mount --bind /run /var/run
220 fi
221 /etc/init.d/rcS readonly 2>&1 | tee -a /run/boot.log
222 # Logrotate boot.log
223 last=.9
224 for i in .8 .7 .6 .5 .4 .3 .2 .1 .0 '' ; do
225 mv -f /var/log/boot.log${i} /var/log/boot.log${last} 2>/dev/null
226 last=$i
227 done
228 mv -f /run/boot.log /var/log/boot.log
229 /etc/init.d/rcS readwrite 2>&1 | tee -a /var/log/boot.log ;;
230 esac