wok-tiny view base-tiny/stuff/etc/init.d/rcS @ rev 132

Up busybox (1.28-20170822)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Aug 22 13:28:07 2017 +0200 (2017-08-22)
parents 52bd0412b176
children df0a7ccded6c
line source
1 #!/bin/sh
2 # /etc/init.d/rcS - Initial boot script for SliTaz GNU/Linux.
3 # Config file is : /etc/rcS.conf
4 #
5 # rcS is the main initialization script used to check fs, mount, clean,
6 # run scripts and start daemons.
7 #
8 . /etc/init.d/rc.functions
9 . /etc/rcS.conf
11 # Set TZ and boot time.
12 [ -s /etc/TZ ] && export TZ="$(cat /etc/TZ)"
14 echo "Processing /etc/init.d/rcS..."
16 # Mount /proc.
17 echo -n "Mounting proc filesystem..."
18 mount proc
19 status
21 if [ "$EARLY_RUN_SCRIPTS" ]; then
22 echo "Executing early initialization scripts..."
23 for script in $EARLY_RUN_SCRIPTS
24 do
25 [ -x /etc/init.d/$script ] && /etc/init.d/$script
26 done
27 fi
29 # Load all modules listed in config file.
30 if [ "$LOAD_MODULES" -o -s /modules ]; then
31 echo -n "Loading modules..."
32 for mod in $LOAD_MODULES $(cat /modules 2> /dev/null)
33 do
34 echo -n " ${mod%%|*}"
35 modprobe ${mod//|/ }
36 done
37 status
38 [ "$KEEP_MODULES" ] || rm -rf /lib/modules /modules 2> /dev/null
39 fi
41 # Mount /sys.
42 echo -n "Mounting sys filesystem..."
43 mount sysfs
44 status
46 if [ -e /sbin/mdev ]; then
47 echo -n "Start hotplug..."
48 echo /sbin/mdev > /proc/sys/kernel/hotplug
49 mdev -s
50 status
51 fi
53 echo -n "Updating /dev..."
54 for i in /sys/block/*/dev /sys/block/*/*/dev ; do
55 [ -s "$i" ] || continue
56 n=${i%/dev}
57 n=/dev/${n##*/}
58 [ -e $n ] && continue
59 echo -n " ${n##*/}"
60 mknod $n b $(sed 's/:/ /' < $i)
61 done
62 status
64 # Before mounting filesystems we check fs specified in the file
65 # /etc/rcS.conf and variable $CHECK_FS.
66 if [ "$CHECK_FS" ]; then
67 mount -o remount,ro /
68 for i in $CHECK_FS
69 do
70 echo "Checking filesystem on : $i"
71 e2fsck -p $i
72 done
73 fi
75 # Remount rootfs rw.
76 echo "Remounting rootfs read/write..."
77 mount -o remount,rw /
79 # Mount filesystems in /etc/fstab.
80 echo "Mounting filesystems in fstab..."
81 mount -a
83 # Store boot messages to log files.
84 dmesg > /var/log/dmesg.log &
86 # Parse cmdline args for earlier boot options. All other boot options
87 # are in /etc/init./bootopts.sh.
88 echo -n "Searching for early boot options..."
89 for opt in $(cat /proc/cmdline)
90 do
91 case $opt in
92 cdrom=*)
93 export CDROM=${opt#cdrom=} ;;
94 config=*)
95 export CONFIG=${opt#config=} ;;
96 *)
97 continue ;;
98 esac
99 done
100 status
102 # Clean up the system.
103 if [ "$CLEAN_UP_SYSTEM" = "yes" ]; then
104 echo -n "Cleaning up the system..."
105 find /var/run -name "*.pid" -type f | xargs rm -f
106 rm -rf /tmp /var/lock/*
107 mkdir -p /tmp && chmod 1777 /tmp
108 status
109 else
110 echo "System clean up is disabled in /etc/rcS.conf..."
111 echo -n "Keeping all tmp and pid files..."
112 status
113 fi
115 # Create /dev/cdrom if needed (symlink does not exist on LiveCD).
116 # Also add /dev/cdrom to fstab if entry does not exist.
117 if [ "$CDROM" ]; then
118 DRIVE_NAME=${CDROM#/dev/}
119 else
120 DRIVE_NAME=$(fgrep -s "drive name" /proc/sys/dev/cdrom/info | cut -f 3)
121 fi
122 if [ -n "$DRIVE_NAME" -a ! "$(readlink /dev/cdrom)" ]; then
123 echo -n "Creating symlink : /dev/cdrom..."
124 ln -s /dev/$DRIVE_NAME /dev/cdrom
125 ln -s /dev/$DRIVE_NAME /dev/dvd
126 chmod 0666 /dev/cdrom /dev/dvd /dev/$DRIVE_NAME
127 status
128 fi
129 if ! fgrep -q "/dev/cdrom" /etc/fstab; then
130 echo -n "Adding /dev/cdrom to fstab..."
131 echo '/dev/cdrom /media/cdrom iso9660 user,ro,noauto 0 0' \
132 >> /etc/fstab
133 status
134 fi
136 # Handle kernel cmdline parameter config=<device>,<path> to source a
137 # disk init script
138 if [ "$CONFIG" ]; then
139 DEVICE=${CONFIG%,*}
140 SCRIPT=${CONFIG#*,}
141 echo "Probing $DEVICE... "
142 if ! mount -r $DEVICE /mnt; then
143 if echo $DEVICE | grep -Eq "/dev/sd|UUID=|LABEL="; then
144 USBDELAY=$(cat /sys/module/usb_storage/parameters/delay_use)
145 USBDELAY=$((1+$USBDELAY))
146 echo "$DEVICE is potentially a USB device: sleep for $USBDELAY seconds"
147 sleep $USBDELAY
148 fi
149 if ! mount -r $DEVICE /mnt; then
150 CONFIG=""
151 fi
152 fi
153 echo -n "Source $SCRIPT from $DEVICE..."
154 if [ "$CONFIG" ]; then
155 . /mnt/$SCRIPT
156 umount /mnt 2> /dev/null || true
157 fi
158 status
159 fi
161 # Mount /proc/bus/usb.
162 if [ -d /proc/bus/usb ]; then
163 echo -n "Mounting /proc/bus/usb filesystem..."
164 mount -t usbfs usbfs /proc/bus/usb
165 status
166 fi
168 # Start syslogd and klogd.
169 if [ "$KERNEL_LOG_DAEMONS" = "yes" ]; then
170 echo -n "Starting system log deamon: syslogd..."
171 syslogd -s $SYSLOGD_ROTATED_SIZE && status
172 echo -n "Starting kernel log daemon: klogd..."
173 klogd && status
174 else
175 echo "Kernel log daemons are disabled in /etc/rc.conf..."
176 fi
178 [ -d /usr/share/kmap ] && echo -n "Load keymap..." &&
179 cat /usr/share/kmap/* | { /bin/loadkmap 2>/dev/null || loadkmap; } &&
180 rm -rf /usr/share/kmap && status
182 # Start all scripts specified with $RUN_SCRIPTS.
183 echo "Executing all initialization scripts..."
184 for script in $RUN_SCRIPTS
185 do
186 [ -x /etc/init.d/$script ] && /etc/init.d/$script
187 done
189 # Re-source main config file. In Live mode, daemons list can be modified
190 # by boot options (screen=text will remove slim).
191 . /etc/rcS.conf
193 # Start all daemons specified with $RUN_DAEMONS.
194 echo "Starting all daemons specified in /etc/rcS.conf..."
195 for daemon in $RUN_DAEMONS
196 do
197 if [ -x /etc/init.d/$daemon ]; then
198 /etc/init.d/$daemon start
199 fi
200 done
202 # Reset screen and display a bold message.
203 if [ "$MESSAGE" ]; then
204 reset
205 echo -e "\033[1m$MESSAGE\033[0m"
206 fi