]>
Commit | Line | Data |
---|---|---|
7742e157 AF |
1 | #!/bin/bash |
2 | # | |
3 | # /etc/rc.d/rc.sysinit - run once at boot time | |
4 | # | |
5 | # Taken in part from Miquel van Smoorenburg's bcheckrc. | |
6 | # | |
7 | ||
8 | # Set the path | |
9 | PATH=/bin:/sbin:/usr/bin:/usr/sbin | |
10 | export PATH | |
11 | ||
12 | # Read in config data. | |
13 | if [ -f /etc/sysconfig/network ]; then | |
14 | . /etc/sysconfig/network | |
15 | else | |
16 | NETWORKING=no | |
17 | HOSTNAME=localhost | |
18 | fi | |
19 | ||
20 | # Start up swapping. | |
21 | echo "Activating swap partitions" | |
22 | swapon -a | |
23 | ||
24 | # Set the hostname. | |
25 | hostname ${HOSTNAME} | |
26 | echo hostname: `hostname` | |
27 | ||
28 | # Set the NIS domain name | |
29 | if [ -n "$NISDOMAIN" ]; then | |
30 | domainname $NISDOMAIN | |
31 | else | |
32 | domainname "" | |
33 | fi | |
34 | ||
35 | if [ -f /fsckoptions ]; then | |
36 | fsckoptions=`cat /fsckoptions` | |
37 | else | |
38 | fsckoptions='' | |
39 | fi | |
40 | ||
41 | if [ ! -f /fastboot ]; then | |
42 | echo "Checking root filesystems." | |
43 | fsck -V -a $fsckoptions / | |
44 | ||
45 | rc=$? | |
46 | ||
47 | # A return of 2 or higher means there were serious problems. | |
48 | if [ $rc -gt 1 ]; then | |
49 | echo | |
50 | echo | |
51 | echo "*** An error occurred during the file system check." | |
52 | echo "*** Dropping you to a shell; the system will reboot" | |
53 | echo "*** when you leave the shell." | |
54 | ||
55 | PS1="(Repair filesystem) #"; export PS1 | |
56 | sulogin | |
57 | ||
58 | echo "Unmounting file systems" | |
59 | umount -a | |
60 | mount -n -o remount,ro / | |
61 | echo "Automatic reboot in progress." | |
62 | reboot | |
63 | elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then | |
64 | echo "Checking root filesystem quotas" | |
65 | /sbin/quotacheck -v / | |
66 | fi | |
67 | fi | |
68 | ||
69 | if [ -x /sbin/quotaon ]; then | |
70 | echo "Turning on user and group quotas for root filesystem" | |
71 | /sbin/quotaon / | |
72 | fi | |
73 | ||
74 | # check for arguments | |
75 | ||
76 | mount -t proc /proc /proc | |
77 | if grep -i nopnp /proc/cmdline >/dev/null ; then | |
78 | PNP= | |
79 | else | |
80 | PNP=yes | |
81 | fi | |
82 | ||
83 | # set up pnp | |
84 | if [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then | |
85 | if [ -n "$PNP" ]; then | |
86 | echo "Setting up ISA PNP devices" | |
87 | /sbin/isapnp /etc/isapnp/isapnp.conf | |
88 | else | |
89 | echo "Skipping ISA PNP configuration at users request" | |
90 | fi | |
91 | fi | |
92 | ||
93 | # Remount the root filesystem read-write. | |
94 | echo "Remounting root filesystem in read-write mode." | |
95 | mount -n -o remount,rw / | |
96 | ||
97 | if [ ! -f /etc/HOSTNAME ]; then | |
98 | echo ${HOSTNAME} > /etc/HOSTNAME | |
99 | fi | |
100 | ||
101 | # Clear mtab | |
102 | >/etc/mtab | |
103 | ||
104 | # Enter root and /proc into mtab. | |
105 | mount -f / | |
106 | mount -f /proc | |
107 | ||
108 | if [ -f /proc/ksyms ]; then | |
109 | USEMODULES=y | |
110 | else | |
111 | USEMODULES= | |
112 | fi | |
113 | ||
114 | # Get the modules ready to go -- we use awk here as cut is in /usr/bin | |
115 | rm -f /lib/modules/preferred | |
116 | if [ -n $USEMODULES ]; then | |
117 | set `cat /proc/cmdline` | |
118 | while [ $# -gt 0 ]; do | |
119 | if echo $1 | grep '^BOOT_IMAGE=' > /dev/null ; then | |
120 | image=`echo $1 | awk -F= '{ print $2 }'` | |
121 | kernelfile=`/sbin/lilo -I $image` | |
122 | if [ -n "$kernelfile" ]; then | |
123 | kernelname=`echo $kernelfile | awk -F- '{ print $1 }'` | |
124 | versioninfo=`echo $kernelfile | sed "s|${kernelname}-||"` | |
125 | if [ "$kernelname" = "/boot/vmlinuz" -a \ | |
126 | -d /lib/modules/$versioninfo -a \ | |
127 | $versioninfo != `uname -r` ]; then | |
128 | ln -sf $versioninfo /lib/modules/preferred | |
129 | fi | |
130 | fi | |
131 | fi | |
132 | shift | |
133 | done | |
134 | fi | |
135 | ||
136 | if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then | |
137 | # Get ready for kerneld if module support in the kernel | |
138 | echo -n "Finding module dependencies... " | |
139 | if [ -e /lib/modules/preferred ]; then | |
140 | depmod -a preferred | |
141 | else | |
142 | depmod -a | |
143 | fi | |
144 | echo "done" | |
145 | fi | |
146 | ||
147 | # load sound modules | |
148 | if ! grep -i nomodules /proc/cmdline >/dev/null ; then | |
149 | if [ -n "$USEMODULES" ]; then | |
150 | if grep -s "alias sound" /etc/conf.modules > /dev/null ; then | |
151 | modprobe sound | |
152 | if grep -s "alias midi" /etc/conf.modules > /dev/null ; then | |
153 | modprobe midi | |
154 | fi | |
155 | fi | |
156 | fi | |
157 | fi | |
158 | ||
159 | if [ -x /sbin/kerneld -a -n "$USEMODULES" ]; then | |
160 | if [ -f /proc/sys/kernel/modprobe ]; then | |
161 | # /proc/sys/kernel/modprobe indicates built-in kmod instead | |
162 | echo "/sbin/modprobe" > /proc/sys/kernel/modprobe | |
163 | else | |
164 | /sbin/kerneld | |
165 | KERNELD=yes | |
166 | fi | |
167 | fi | |
168 | ||
169 | # Check filesystems | |
170 | if [ ! -f /fastboot ]; then | |
171 | echo "Checking filesystems." | |
172 | fsck -R -A -V -a $fsckoptions | |
173 | ||
174 | # A return of 2 or higher means there were serious problems. | |
175 | if [ $? -gt 1 ]; then | |
176 | echo | |
177 | echo | |
178 | echo "*** An error occurred during the file system check." | |
179 | echo "*** Dropping you to a shell; the system will reboot" | |
180 | echo "*** when you leave the shell." | |
181 | ||
182 | PS1="(Repair filesystem) #"; export PS1 | |
183 | sulogin | |
184 | ||
185 | echo "Unmounting file systems" | |
186 | umount -a | |
187 | mount -n -o remount,ro / | |
188 | echo "Automatic reboot in progress." | |
189 | reboot | |
190 | elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then | |
191 | echo "Checking filesystem quotas" | |
192 | /sbin/quotacheck -v -R -a | |
193 | fi | |
194 | fi | |
195 | ||
196 | # Mount all other filesystems (except for NFS and /proc, which is already | |
197 | # mounted). Contrary to standard usage, | |
198 | # filesystems are NOT unmounted in single user mode. | |
199 | echo "Mounting local filesystems." | |
200 | mount -a -t nonfs,proc | |
201 | ||
202 | # set the console font | |
203 | if [ -x /sbin/setsysfont ]; then | |
204 | /sbin/setsysfont | |
205 | fi | |
206 | ||
207 | if [ -x /sbin/quotaon ]; then | |
208 | echo "Turning on user and group quotas for local filesystems" | |
209 | /sbin/quotaon -a | |
210 | fi | |
211 | ||
212 | # Clean out /etc. | |
213 | rm -f /etc/mtab~ /fastboot /fsckoptions | |
214 | >/var/run/utmp | |
215 | ||
216 | # Delete UUCP lock files. | |
217 | rm -f /var/lock/LCK* | |
218 | ||
219 | # Delete stale subsystem files. | |
220 | rm -f /var/lock/subsys/* | |
221 | ||
222 | if [ -n "$KERNELD" ]; then | |
223 | touch /var/lock/subsys/kerneld | |
224 | fi | |
225 | ||
226 | # Delete stale pid files | |
227 | rm -f /var/run/*.pid | |
228 | rm -f /var/spool/postoffice/.pid.* | |
229 | ||
230 | # Delete X locks | |
231 | rm -f /tmp/.X*-lock | |
232 | ||
233 | # Set the system clock. | |
234 | echo -n "Setting clock" | |
235 | ||
236 | ARC=0 | |
237 | UTC=0 | |
238 | if [ -f /etc/sysconfig/clock ]; then | |
239 | . /etc/sysconfig/clock | |
240 | ||
241 | # convert old style clock config to new values | |
242 | if [ "${CLOCKMODE}" = "GMT" ]; then | |
243 | UTC=true | |
244 | elif [ "${CLOCKMODE}" = "ARC" ]; then | |
245 | ARC=true | |
246 | fi | |
247 | fi | |
248 | ||
249 | if [ -x /sbin/hwclock ]; then | |
250 | CLOCKFLAGS="--hctosys" | |
251 | CLOCK=/sbin/hwclock | |
252 | else | |
253 | CLOCKFLAGS="-a" | |
254 | CLOCK=/sbin/clock | |
255 | fi | |
256 | ||
257 | if [ $UTC = "true" ]; then | |
258 | CLOCKFLAGS="$CLOCKFLAGS -u"; | |
259 | echo -n " (utc)" | |
260 | fi | |
261 | if [ $ARC = "true" ]; then | |
262 | CLOCKFLAGS="$CLOCKFLAGS -A"; | |
263 | echo -n " (arc)" | |
264 | fi | |
265 | echo -n ": " | |
266 | $CLOCK $CLOCKFLAGS | |
267 | ||
268 | date | |
269 | ||
270 | # Right, now turn on swap in case we swap to files. | |
271 | echo "Enabling swap space." | |
272 | swapon -a 2>&1 | grep -v "busy" | |
273 | ||
274 | # Initialize the serial ports. | |
275 | if [ -f /etc/rc.d/rc.serial ]; then | |
276 | . /etc/rc.d/rc.serial | |
277 | fi | |
278 | ||
279 | # Load modules (for backward compatibility with VARs) | |
280 | if [ -f /etc/rc.d/rc.modules ]; then | |
281 | /etc/rc.d/rc.modules | |
282 | fi | |
283 | ||
284 | # If a SCSI tape has been detected, load the st module unconditionally | |
285 | # since many SCSI tapes don't deal well with st being loaded and unloaded | |
286 | if [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi | grep -q 'Type: Sequential-Access' 2>/dev/null ; then | |
287 | if cat /proc/devices | grep -qv ' 9 st' ; then | |
288 | if [ -n "$USEMODULES" ] ; then | |
289 | # Try to load the module. If it fails, ignore it... | |
290 | modprobe st 2>/dev/null | |
291 | fi | |
292 | fi | |
293 | fi | |
294 | ||
295 | # Now that we have all of our basic modules loaded and the kernel going, | |
296 | # let's dump the syslog ring somewhere so we can find it later | |
297 | dmesg > /var/log/dmesg | |
298 | ||
299 | # Feed entropy into the entropy pool | |
300 | /etc/rc.d/init.d/random start |