]> git.pld-linux.org Git - projects/rc-scripts.git/blame - rc.d/rc.sysinit
- activate dm-multipath
[projects/rc-scripts.git] / rc.d / rc.sysinit
CommitLineData
12de71be 1#!/bin/sh
7742e157
AF
2#
3# /etc/rc.d/rc.sysinit - run once at boot time
ec8b15cb 4# $Id$
7742e157
AF
5#
6# Taken in part from Miquel van Smoorenburg's bcheckrc.
7#
8
9# Set the path
10PATH=/bin:/sbin:/usr/bin:/usr/sbin
11export PATH
7e04fe0e 12
b6509675
AM
13# reasonable start values for bootsplash progress.
14export progress=0
15export sscripts=45
16export kscripts=45
17
38198f50 18# NLS
de1fc6ce 19if [ -r /etc/sysconfig/i18n ]; then
38198f50
AM
20 . /etc/sysconfig/i18n
21 [ -n "$LANG" ] && export LANG || unset LANG
22 [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
23 [ -n "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE
24 [ -n "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES
25 [ -n "$LC_NUMERIC" ] && export LC_NUMERIC || unset LC_NUMERIC
26 [ -n "$LC_MONETARY" ] && export LC_MONETARY || unset LC_MONETARY
27 [ -n "$LC_TIME" ] && export LC_TIME || unset LC_TIME
28 [ -n "$LC_ALL" ] && export LC_ALL || unset LC_ALL
29 [ -n "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE
30 [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS
31fi
32
418c0cf3 33# Read network config data
de1fc6ce 34if [ -r /etc/sysconfig/network ]; then
1b228409 35 . /etc/sysconfig/network
7742e157 36else
1b228409 37 NETWORKING=no
38 HOSTNAME=localhost
7742e157
AF
39fi
40
277e5f53 41CONSOLE_LOGLEVEL=1
45e88cd0 42
e298d489
JR
43# Read functions
44. /etc/rc.d/init.d/functions
45
48e500cd
ER
46# boot logging to /var/log/boot.msg. install showconsole package to get it.
47if [ -x /sbin/blogd ] && ! is_no "$RC_BOOTLOG"; then
48 RC_BOOTLOG=1
49else
50 RC_BOOTLOG=
51fi
52
5163449d 53if ! is_yes "$VSERVER" ; then
a1ad6ea5
ER
54 # we need /proc mounted before everything
55 mount -n -o gid=17 -t proc /proc /proc
56
5163449d
JR
57 # sysfs is also needed before any other things (under kernel > 2.5)
58 if grep -q sysfs /proc/filesystems 2>/dev/null ; then
59 mount -n -o gid=17 -t sysfs sysfs /sys
60 if [ "$(kernelver)" -ge "002006014" ] && \
61 grep -q securityfs /proc/filesystems 2>/dev/null ; then
62 mount -n -o gid=17 -t securityfs securityfs /sys/kernel/security
63 fi
64
defac991 65 fi
e298d489 66
5163449d
JR
67 # selinux
68 if grep -q selinuxfs /proc/filesystems 2>/dev/null && ! grep -q selinuxfs /proc/mounts 2>/dev/null; then
69 mount -n -o gid=17 -t selinuxfs selinuxfs /selinux
70 fi
e298d489 71
01b60fd3
JR
72 if [ $(kernelverser) = "002006" ]; then
73 MODULES_CONF=/etc/modprobe.conf
74 elif [ -r /etc/modules.conf ]; then
75 MODULES_CONF=/etc/modules.conf
76 else
77 MODULES_CONF=/etc/conf.modules
78 fi
e298d489 79
ffe19b59 80 # PLD Linux LiveCD support
01b60fd3
JR
81 if [ -x /etc/rc.d/rc.live ]; then
82 /etc/rc.d/rc.live
83 fi
e298d489 84
01b60fd3
JR
85 # Choose Hardware profile
86 if [ -f /etc/sysconfig/hwprof ]; then
87 . /etc/sysconfig/hwprof
88 if is_yes "${HWPROFILES}" && [ -x /sbin/hwprofile -a -d /etc/sysconfig/hwprofiles/data ]; then
89 mount -n / -o rw,remount
90 /sbin/hwprofile -qf
91 mount -n / -o ro,remount
92 fi
5e6dfc29 93 fi
e298d489 94
01b60fd3
JR
95 # Disable splash when requested
96 [ -e /proc/splash ] && is_no "$BOOT_SPLASH" && echo "0" > /proc/splash
5b0f5a94 97
c5e74817
ER
98 # Check SELinux status
99 selinuxfs=$(awk '/ selinuxfs / { print $2 }' /proc/mounts 2> /dev/null)
100 SELINUX=
101 if [ -n "$selinuxfs" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then
102 if [ -r $selinuxfs/enforce ] ; then
103 SELINUX=$(cat $selinuxfs/enforce)
104 else
105 # assume enforcing if you can't read it
106 SELINUX=1
107 fi
5e6dfc29 108 fi
677fdd75 109
c5e74817
ER
110 if [ -x /sbin/restorecon ] && LC_ALL=C fgrep -q " /dev " /proc/mounts 2>/dev/null ; then
111 /sbin/restorecon -R /dev 2>/dev/null
112 fi
677fdd75
AM
113
114
7e16b45e
ER
115 [ -z "${CONSOLETYPE}" ] && CONSOLETYPE="$(/sbin/consoletype)"
116
c5e74817
ER
117 if [ "$CONSOLETYPE" = "vt" -a -x /sbin/setsysfont ]; then
118 /sbin/setsysfont
119 fi
12c4fb70 120fi
5b0f5a94 121
652dbae5 122
458f14b7 123# Print welcome message
503bfc80 124nls "\t\t\t%sPowered by %sPLD Linux Distribution%s" "$(termput setaf $CPOWEREDBY)" "$(termput setaf $CPLD)" "$(termput op)"
8a917f32 125if ! is_no "$RC_PROMPT"; then
503bfc80 126 nls -n "\t\t Press %sI%s to enter interactive startup" "$(termput setaf $CI)" "$(termput op)"
6b4a354c 127 echo
6b4a354c 128fi
201c98b9 129
cc10e704 130# Set the hostname
499b251c
JR
131if [ -z "${HOSTNAME}" ]; then
132 show "$(nls 'Host:') $(hostname)" ; ok
133else
134 run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME}
135fi
6956336c 136
cc10e704
JR
137# Set the NIS domain name
138if [ -n "$NISDOMAIN" ]; then
139 run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN
140else
141 domainname ""
4289a4ff
AM
142fi
143
cc10e704
JR
144if ! is_yes "$VSERVER"; then
145 # Set console loglevel
146 if [ -n "$CONSOLE_LOGLEVEL" ]; then
147 /bin/dmesg -n $CONSOLE_LOGLEVEL
148 fi
6bf50269 149
cc10e704
JR
150 if [ -f /etc/udev/udev.conf ];then
151 . /etc/udev/udev.conf
152 fi
fbbfefb6 153
cc6b79af 154 [ -x /sbin/start_udev ] && /sbin/start_udev
5e6dfc29 155
cc10e704
JR
156 # /dev must be also mounted before everything but only if we want use them ;-)
157 if is_yes "$MOUNT_DEVFS"; then
158 run_cmd "Mounting Device Filesystem" mount -n -t devfs /dev /dev
159 fi
fd6887dc 160
cc10e704
JR
161 # set up devfsd
162 if [ -e /dev/.devfsd -a -x /sbin/devfsd ]; then
163 run_cmd "Starting Device Filesystem Daemon" /sbin/devfsd /dev
164 fi
201c98b9 165
33c6207a
ER
166 # Start logging console output since we have all /dev stuff setup
167 if [ "$RC_BOOTLOG" ]; then
168 /sbin/blogd -q
169 fi
170
cc10e704
JR
171 # cpuset support (mounted unconditionally, shouldn't be a problem)
172 if grep -q cpuset /proc/filesystems 2>/dev/null ; then
29be11b0
ER
173 # mkdir for udev (FIXME fix the udev instead)
174 mkdir -p /dev/cpuset 2>/dev/null
5e6dfc29 175 mount -n -t cpuset none /dev/cpuset
cc10e704 176 fi
201c98b9 177
cc10e704
JR
178 # Configure Linux kernel (initial configuration, some required modules still
179 # may be missing).
180 /sbin/sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
201c98b9 181
cc10e704
JR
182 # Set the system clock.
183 ARC=0
184 SRM=0
185 UTC=0
201c98b9 186
cc10e704
JR
187 if [ -f /etc/sysconfig/clock ]; then
188 . /etc/sysconfig/clock
201c98b9 189
cc10e704
JR
190 # convert old style clock config to new values
191 if [ "${CLOCKMODE}" = "GMT" ]; then
192 UTC=true
193 elif [ "${CLOCKMODE}" = "ARC" ]; then
194 ARC=true
195 fi
196 fi
201c98b9 197
cc10e704
JR
198 if grep "system serial" /proc/cpuinfo 2>/dev/null | grep -q MILO 2>/dev/null ; then
199 ARC=true
200 fi
cb4d1aa7 201
cc10e704
JR
202 CLOCKDEF=""
203 CLOCKFLAGS="--hctosys"
cb4d1aa7 204
cc10e704
JR
205 if is_yes "$UTC" ; then
206 CLOCKFLAGS="$CLOCKFLAGS --utc"
207 CLOCKDEF="$CLOCKDEF (utc)"
208 else
209 CLOCKFLAGS="$CLOCKFLAGS --localtime"
210 CLOCKDEF="$CLOCKDEF (local)"
211 fi
201c98b9 212
cc10e704
JR
213 if is_yes "$ARC" ; then
214 CLOCKFLAGS="$CLOCKFLAGS -A"
215 CLOCKDEF="$CLOCKDEF (arc)"
0bbfed6f 216 fi
e4b0481f 217
cc10e704
JR
218 if is_yes "$SRM" ; then
219 CLOCKFLAGS="$CLOCKFLAGS -S"
220 CLOCKDEF="$CLOCKDEF (srm)"
221 fi
7742e157 222
cc10e704 223 # Check if timezone definition is available
bc05b297 224 if [ -e /etc/localtime -a -e /dev/rtc ] ; then
cc10e704
JR
225 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
226 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
227 fi
228 else
229 TIME_SETUP_DELAYED=yes
230 fi
7742e157 231
cc10e704
JR
232 # Start up swapping
233 run_cmd "Activating swap partitions" swapon -a -e
234
235 # Initialize USB controllers
236 usb=0
1c502fef 237 if ! grep -iq "nousb" /proc/cmdline 2>/dev/null && ! grep -q "/proc/bus/usb" /proc/mounts 2>/dev/null ; then
86711d93 238 aliases=$(/sbin/modprobe -c | awk '/^alias[\t ]+usb-controller/ { print $3 }')
cc10e704 239 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
a6a4a758 240 /sbin/modprobe -s -k usbcore
cc10e704
JR
241 for alias in $aliases ; do
242 [ "$alias" = "off" ] && continue
a6a4a758 243 run_cmd "$(nls 'Initializing USB controller') ($alias)" /sbin/modprobe -s $alias
cc10e704
JR
244 done
245 [ $? -eq 0 -a -n "$aliases" ] && usb=1
246 fi
247 if grep -iq "usb" /proc/devices 2>/dev/null ; then
248 usb=1
249 fi
250 fi
7742e157 251
cc10e704 252 if [ "$usb" = "1" -a ! -f /proc/bus/usb/devices ]; then
7a4f6aef 253 run_cmd "Mounting USB filesystem" mount -n -t usbfs usbfs /proc/bus/usb
b3965b3d 254 fi
b3965b3d 255
cc10e704
JR
256 needusbstorage=
257 if [ "$usb" = "1" ]; then
258 needusbstorage=$(LC_ALL=C cat /proc/bus/usb/devices 2>/dev/null|grep -e "^I.*Cls=08" 2>/dev/null)
259 if [ "$(kernelverser)" -lt "002006" ]; then
5e6dfc29
JR
260 LC_ALL=C grep -q 'hid' /proc/bus/usb/drivers 2>/dev/null || run_cmd "Initializing USB HID interface" modprobe hid 2> /dev/null
261 mouseoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02" 2>/dev/null)
262 kbdoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01" 2>/dev/null)
263 if [ -n "$kbdoutput" ]; then
264 run_cmd "Initializing USB keyboard" modprobe keybdev
265 fi
266 if [ -n "$mouseoutput" ]; then
267 run_cmd "Initializing USB mouse" modprobe mousedev
268 fi
cc10e704
JR
269 fi
270 fi
b3965b3d 271
cc10e704
JR
272 # Setup hdparm thing (if exists and is needed)
273 if ! grep -iq nohdparm /proc/cmdline 2>/dev/null; then
274 [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
ebd1845b 275 fi
b3965b3d 276
cc10e704
JR
277 if [ -f /fastboot ] || grep -iq "fastboot" /proc/cmdline 2>/dev/null ; then
278 fastboot=yes
279 else
280 fastboot=
281 fi
03f9cfee 282
cc10e704
JR
283 if [ -f /fsckoptions ]; then
284 fsckoptions=$(cat /fsckoptions)
285 else
286 fsckoptions=''
287 fi
cb4d1aa7 288
cc10e704
JR
289 if [ -f /forcefsck ]; then
290 fsckoptions="-f $fsckoptions"
790968dd
ER
291 else
292 # Obey the fs_passno setting for / (see fstab(5))
293 # - find the / entry
6fe4e4eb
ER
294 # - make sure we have at least 6 fields
295 _ROOTFS_PASSNO=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $6}' /etc/fstab)
cc10e704 296 fi
7742e157 297
cc10e704 298 _RUN_QUOTACHECK=0
2fce16f9 299 _ROOTFS_TYPE=$(awk '$2 == "/" && $3 != "rootfs" { print $3 }' /proc/mounts 2>/dev/null)
cc10e704 300
790968dd 301 if [ -z "$fastboot" -a "$_ROOTFS_TYPE" != "nfs" -a "$_ROOTFS_TYPE" != "romfs" -a "$_ROOTFS_PASSNO" != 0 ]; then
cc10e704
JR
302 show "Checking root filesystem"; started
303 initlog -c "fsck -C -T -a $fsckoptions /"
304
305 rc=$?
306
307 # A return of 4 or higher means there were serious problems.
308 if [ $rc -gt 3 ]; then
309 [ -e /proc/splash ] && echo "verbose" > /proc/splash
310 # don't use '\n' in nls macro !
311 echo
312 echo
313 nls "*** An error occurred during the file system check."
314 nls "*** Dropping you to a shell; the system will reboot"
315 nls "*** when you leave the shell."
316 echo
317
526b7c62 318 PS1="`nls '(Repair filesystem)# '`"; export PS1
cc10e704 319 [ "$SELINUX" = "1" ] && disable_selinux
277e5f53 320 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
cc10e704
JR
321 /sbin/sulogin
322 else
323 /bin/sh
324 fi
cee18a41 325
cc10e704
JR
326 run_cmd "Unmounting file systems" umount -a
327 mount -n -o remount,ro /
328 run_cmd "Automatic reboot in progress" reboot
329 # A return of 2 or 3 means that filesystem was repaired but we need
330 # to reboot.
331 elif [ "$rc" = "2" -o "$rc" = "3" ]; then
332 [ -e /proc/splash ] && echo "verbose" > /proc/splash
333 echo
334 nls "*** Filesystem was repaired but system needs to be"
335 nls "*** rebooted before mounting it."
336 nls "*** REBOOTING ***"
337 echo
338
339 run_cmd "Unmounting file systems" umount -a
340 mount -n -o remount,ro /
341 run_cmd "Automatic reboot in progress" reboot
342 elif [ "$rc" = "1" ]; then
343 _RUN_QUOTACHECK=1
cb4d1aa7 344 fi
cb4d1aa7 345 fi
7742e157 346
cc10e704
JR
347 # Unmount the initrd, if necessary
348 if LC_ALL=C grep -q /initrd /proc/mounts 2>/dev/null && ! LC_ALL=C grep -q /initrd/loopfs /proc/mounts 2>/dev/null ; then
5e6dfc29
JR
349 if [ -e /initrd/dev/.devfsd ]; then
350 umount /initrd/dev
351 fi
352 umount /initrd
353 /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1
354 fi
355
356 # Check for arguments
cc10e704
JR
357 if grep -iq nopnp /proc/cmdline 2>/dev/null; then
358 PNP=
359 else
360 PNP=yes
361 fi
7742e157 362
cc10e704
JR
363 # set up pnp and kernel pnp
364 if [ -n "$PNP" ]; then
277e5f53 365 if ! is_no "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
5e6dfc29
JR
366 run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf
367 fi
277e5f53 368 if ! is_no "$RUN_KERNELPNP"; then
5e6dfc29
JR
369 /sbin/modprobe -k isa-pnp 2> /dev/null
370 if [ -e /proc/isapnp -a -f /etc/isapnp/isapnp-kernel.conf ]; then
371 show "Setting up ISA PNP devices (kernelspace pnp)"; busy
372 grep -v "^#" /etc/isapnp/isapnp-kernel.conf 2>/dev/null >/proc/isapnp && (deltext; ok) || (deltext; fail)
373 fi
cc10e704 374 fi
b68f99e5 375 fi
7742e157 376
cc10e704 377 # Remount the root filesystem read-write
f1296be4 378 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
cee18a41 379
cc10e704
JR
380 # Update quotas if fsck was run on /
381 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
382 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -vnug /
383 fi
aa362992 384
5475bb0f
ER
385 # Clean up SELinux labels
386 if [ -n "$SELINUX" ]; then
387 for file in /etc/mtab /etc/cryptomtab /etc/ld.so.cache ; do
388 [ -r $file ] && restorecon $file >/dev/null 2>&1
389 done
390 fi
652dbae5
ER
391
392else
393 # Start logging console output since we have all /dev stuff setup
394 if [ "$RC_BOOTLOG" ]; then
395 /sbin/blogd -q
396 fi
677fdd75 397fi
5e6dfc29 398
cb4d1aa7 399# Remove stale backups
7158cab8 400rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~
cb4d1aa7 401
ef05209d
JR
402# Remove /etc/nologin when starting system
403[ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
404
277e5f53 405if ! is_no "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
ef05209d
JR
406 show "Enabling Delay Login"; busy
407 echo > /etc/nologin
408 nls "System bootup in progress - please wait" >> /etc/nologin
409 echo >> /etc/nologin
410 chmod 644 /etc/nologin
411 cp -fp /etc/nologin /etc/nologin.boot
412 ok
413fi
414
415# The root filesystem is now read-write, so we can now log via
416# syslog() directly...
417if [ -n "$IN_INITLOG" ]; then
418 IN_INITLOG=""
419fi
420
cc10e704 421if ! is_yes "$VSERVER"; then
220df3e7
JR
422 # Clear mtab
423 :>/etc/mtab
424 [ -f /etc/cryptomtab ] && :>/etc/cryptomtab
425
cc10e704
JR
426 # Enter root, /proc, /sys, devfs and other into mtab.
427 mount -f /
428 mount -f /proc
429 [ -f /proc/bus/usb/devices ] && mount -f -t usbfs usbfs /proc/bus/usb
430 [ -e /dev/.devfsd ] && mount -f -t devfs devfs /dev
7d45bad6 431
29be11b0 432 if grep -q sysfs /proc/mounts 2>/dev/null; then
cc10e704 433 mount -f -t sysfs sysfs /sys
29be11b0 434 if grep -q securityfs /proc/mounts 2>/dev/null ; then
defac991
AM
435 mount -f -t securityfs securityfs /sys/kernel/security
436 fi
cc10e704 437 fi
ad084d91 438
29be11b0 439 if grep -q selinuxfs /proc/mounts 2>/dev/null; then
cc10e704
JR
440 mount -f -t selinuxfs selinuxfs /selinux
441 fi
cb4d1aa7 442
29be11b0 443 if grep -q cpuset /proc/mounts 2>/dev/null; then
2d495b7f 444 mount -f -t cpuset none /dev/cpuset
cc10e704 445 fi
fd6887dc 446
cc10e704
JR
447 if [ ! -f /proc/modules ]; then
448 USEMODULES=
449 elif ! grep -iq nomodules /proc/cmdline 2>/dev/null; then
450 USEMODULES=y
451 else
452 USEMODULES=
4cc4301b 453 fi
de1fc6ce 454
cc10e704
JR
455 # Adjust symlinks as necessary in /boot to keep system services from
456 # spewing messages about mismatched System maps and so on.
277e5f53 457 if ! is_no "$SET_SLINKS"; then
c14f9857
ER
458 uname_r=$(uname -r)
459 if [ -L /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
460 ln -s -f System.map-$uname_r /boot/System.map
cc10e704 461 fi
c14f9857
ER
462 if [ ! -e /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
463 ln -s -f System.map-$uname_r /boot/System.map
cc10e704 464 fi
c14f9857 465 unset uname_r
418c0cf3 466 fi
7742e157 467
cc10e704
JR
468 # Run depmod if RUN_DEPMOD != "no" and:
469 # a) user requested or RUN_DEPMOD="";
470 # b) modules.dep is missing
471 # c) modules.dep is older than /etc/modules.conf or /lib/modules/`uname -r`
472 if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
473 if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ]; then
474 run_cmd "Finding module dependencies" depmod -a
475 elif [ "$RUN_DEPMOD" = "ifmissing" ]; then
476 run_cmd "Finding module dependencies" depmod -A
477 fi
aa362992 478 fi
5bb58804 479
cc10e704
JR
480 if [ -f /proc/sys/kernel/modprobe ]; then
481 if [ -n "$USEMODULES" ]; then
482 sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
cc10e704
JR
483 else
484 # We used to set this to NULL, but that causes
485 # 'failed to exec' messages"
486 sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
cc10e704 487 fi
cb4d1aa7 488 fi
cb4d1aa7 489
cc10e704
JR
490 # Load usb storage here, to match most other things
491 if [ -n "$needusbstorage" ]; then
492 modprobe -k usb-storage >/dev/null 2>&1
493 fi
cb4d1aa7 494
cc10e704
JR
495 # Load firewire devices
496 if ! grep -iq "nofirewire" /proc/cmdline 2>/dev/null ; then
497 aliases=$(/sbin/modprobe -c | awk '/^alias ieee1394-controller/ { print $3 }')
498 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
5e6dfc29
JR
499 for alias in $aliases ; do
500 [ "$alias" = "off" ] && continue
501 run_cmd "$(nls 'Initializing firewire controller') ($alias)" /sbin/modprobe $alias
502 done
503 LC_ALL=C grep -E "SBP2" /proc/bus/ieee1394/devices 2>/dev/null && /sbin/modprobe -s sbp2 > /dev/null 2>&1
cc10e704 504 fi
5e6dfc29
JR
505 fi
506
cc10e704
JR
507 # Load sound modules if they need persistent DMA buffers
508 if grep -q "^options sound dmabuf=1" "$MODULES_CONF" 2>/dev/null ; then
509 RETURN=0
510 alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
511 if [ -n "$alias" -a "$alias" != "off" ] ; then
512 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
513 RETURN=$?
514 fi
515 alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound-slot-0[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
516 if [ -n "$alias" -a "$alias" != "off" ] ; then
517 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
518 RETURN=$?
f47acf6f
JR
519 fi
520 fi
472fa41e 521
cc10e704
JR
522 # Load modules
523 if [ -x /etc/rc.d/rc.modules ]; then
524 /etc/rc.d/rc.modules
525 fi
7742e157 526
e62309d9
ER
527 # Activate dm-multipath
528 if [ -x /sbin/multipath ]; then
529 run_cmd "Activating dm-multipath" /sbin/multipath -v 0
530 for a in /dev/mapper/*; do
531 [ $a = /dev/mapper/control ] && continue
532 /sbin/kpartx -a $a
533 done
534 fi
535
3a4304f3
AM
536 if [ -x /sbin/dmraid ]; then
537 run_cmd "Activating ATARAID devices" /sbin/dmraid -ay
538 fi
539
cc10e704
JR
540 # Find and activate volume groups:
541 # EVMS
542 if [ -x /sbin/evms_activate ]; then
cc10e704 543 if [ "$(kernelverser)" -lt "002006" ]; then
5e6dfc29
JR
544 # Linux 2.4 core modules
545 modprobe -s -k evms > /dev/null 2>&1
546 modprobe -s -k evms_passthru > /dev/null 2>&1
547 modprobe -s -k ldev_mgr > /dev/null 2>&1
548 modprobe -s -k dos_part > /dev/null 2>&1
cc10e704 549 else
5e6dfc29
JR
550 # Linux 2.6 core module
551 modprobe -s -k evmscore > /dev/null 2>&1
d6749722 552 fi
5e6dfc29 553
cc10e704
JR
554 is_yes "$EVMS_GUID_PTABLE" && modprobe -s -k gpt_part >/dev/null 2>&1
555 is_yes "$EVMS_LVM" && modprobe -s -k lvm_vge >/dev/null 2>&1
556 is_yes "$EVMS_AIX" && modprobe -s -k AIXlvm_vge >/dev/null 2>&1
557 is_yes "$EVMS_OS2" && modprobe -s -k os2lvm_vge >/dev/null 2>&1
558 run_cmd "Discovering EVMS volumes" /sbin/evms_activate
559 if is_yes "$EVMS_LVM" && is_yes "$EVMS_LVM_COMPAT_NODES" ; then
560 # Link nodes for compatibility with LVM
561 if [ "echo /dev/evms/lvm/*" != '/dev/evms/lvm/*' ] ; then
562 ln -s /dev/evms/lvm/* /dev/
de1fc6ce 563 fi
cc10e704
JR
564 fi
565 fi
49c61c56 566
cc10e704
JR
567 # LVM (keep in sync with LVM starting after RAID run!)
568 if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
569 lvmversion=$(/sbin/vgchange --version 2>/dev/null | awk '{gsub("vgchange: Logical Volume Manager ",""); gsub("LVM version: ",""); gsub(/\..*/,"");print $1; exit}')
570 if [ "$lvmversion" = "1" ] ; then
571 modprobe -s -k lvm-mod >/dev/null 2>&1
572 lvmignorelock=""
573 elif [ "$lvmversion" = "2" ] ; then
574 modprobe -s -k dm-mod >/dev/null 2>&1
575 lvmignorelock="--ignorelockingfailure"
576 else
5e6dfc29
JR
577 modprobe -s -k lvm-mod >/dev/null 2>&1
578 # device mapper (2.5+ and patched 2.4)
579 modprobe -s -k dm-mod >/dev/null 2>&1
580 lvmignorelock=""
cc10e704 581 fi
5e6dfc29 582
cc10e704
JR
583 run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelock && \
584 run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmignorelock
585 [ "$lvmversion" = "2" ] && /sbin/vgscan --mknodes $lvmignorelock > /dev/null 2>&1
586
587 fi
588
589 # Add raid devices
590 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ] || [ -f /etc/raidtab ]; then
cc10e704
JR
591 modprobe -s md >/dev/null 2>&1
592 if [ -f /proc/mdstat ]; then
5e6dfc29
JR
593 goraidtab=1
594 golvm=0
595 rc=0
596 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
597 if (grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null); then
0fe527f8 598 run_cmd "Starting up RAID devices" /sbin/mdadm --assemble --scan --auto=yes
5e6dfc29
JR
599 rc=$?
600 [ "$rc" -eq 0 ] && goraidtab=0 && golvm=1
cc10e704 601 fi
5e6dfc29
JR
602 fi
603
604 if [ -f /etc/raidtab -a "$goraidtab" -eq 1 ]; then
49c61c56 605 for i in $(awk '!/^#/ && /raiddev/{print $2}' /etc/raidtab 2>/dev/null); do
5e6dfc29
JR
606 golvm=1
607 RAIDDEV=$(basename $i)
608 RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat 2>/dev/null)
609 show "Starting up RAID device %s" $RAIDDEV
610 busy
611 if [ -z "$RAIDSTAT" ]; then
612 # Try raidstart first...if that fails then
613 # fall back to raid0run and if that fails too
614 # fall back to raidadd, raidrun.
615 RESULT=1
616 if [ -x /sbin/raidstart ]; then
617 /sbin/raidstart $i
618 RESULT=$?
619 fi
620 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
621 /sbin/raid0run $i
622 RESULT=$?
623 fi
624 if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then
625 /sbin/raidadd $i
626 /sbin/raidrun $i
627 RESULT=$?
628 fi
629 if [ $RESULT -gt 0 ]; then
630 rc=1
631 fail
632 else
633 ok
634 fi
635 else
636 ok
637 fi
638 done
639 fi
640
641 # A non-zero return means there were problems
642 if [ $rc -gt 0 ]; then
643 [ -e /proc/splash ] && echo "verbose" > /proc/splash
644 show "Starting up RAID devices"; fail
645 echo
646 echo
647 nls "*** An error occurred during the RAID startup."
648 nls "*** Dropping you to a shell; the system will reboot"
649 nls "*** when you leave the shell."
650 echo
651
652 PS1="$(nls '(RAID Repair)# ')"; export PS1
653 [ "$SELINUX" = "1" ] && disable_selinux
277e5f53 654 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
5e6dfc29 655 /sbin/sulogin
cc10e704 656 else
5e6dfc29 657 /bin/sh
cc10e704 658 fi
12de71be 659
5e6dfc29
JR
660 run_cmd "Unmounting file systems" umount -a
661 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
662 run_cmd "Automatic reboot in progress" reboot
cc10e704 663 fi
5e6dfc29
JR
664 # LVM on RAID (keep in sync with LVM setting few lines above)
665 if [ "$golvm" -eq "1" ]; then
666 if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
667 run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmignorelock && \
668 run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmignorelock
669 [ "$lvmversion" = "2" ] && /sbin/vgscan --mknodes $lvmignorelock > /dev/null 2>&1
670 fi
cc10e704 671 fi
5e6dfc29 672 show "Starting up RAID devices"; ok
2619a5cf 673 fi
12de71be 674 fi
7742e157 675
cc10e704
JR
676 _RUN_QUOTACHECK=0
677 # Check filesystems
678 if [ -z "$fastboot" ] && ! grep -q nofsck /proc/cmdline 2>/dev/null; then
679 rc_splash "fsck start"
680 show "Checking filesystems"; started
790968dd 681 initlog -c "fsck -C -T -R -A -a -P $fsckoptions"
cc10e704
JR
682
683 rc=$?
684
685 # A return of 2 or higher means there were serious problems
686 if [ $rc -gt 1 ]; then
687 [ -e /proc/splash ] && echo "verbose" > /proc/splash
688 echo
689 echo
690 nls "*** An error occurred during the file system check."
691 nls "*** Dropping you to a shell; the system will reboot"
692 nls "*** when you leave the shell."
693 echo
694
695 PS1="$(nls '(Repair filesystem)# ')"; export PS1
696 [ "$SELINUX" = "1" ] && disable_selinux
277e5f53 697 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
cc10e704
JR
698 /sbin/sulogin
699 else
700 /bin/sh
701 fi
7742e157 702
cc10e704
JR
703 run_cmd "Unmounting file systems" umount -a
704 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
705 run_cmd "Automatic reboot in progress" reboot
706 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
707 _RUN_QUOTACHECK=1
708 fi
709 rc_splash "fsck stop"
7742e157 710 fi
7742e157 711
cc10e704
JR
712 # Mount all other filesystems (except for NFS and /proc, which is already
713 # mounted). Contrary to standard usage,
714 # filesystems are NOT unmounted in single user mode.
715
438bf720 716 run_cmd "Mounting local filesystems" mount -a -t nonfs,nfs4,smbfs,ncpfs,proc,cifs -O no_netdev
cc10e704 717
9a0a016d
ER
718 # now we have /usr mounted, recheck if we have gettext and tput available.
719 if is_no "$TPUT"; then
720 GETTEXT=
721 TPUT=
04342743 722 rc_gettext_init
9a0a016d
ER
723 fi
724
cc10e704
JR
725 # Now do some workaround - encrypted filesystems couldn't have been fsck-ed
726 # before mount - that's where the password is entered.
727 # mount is buggy - when remounting loopback filesystem, loop=XXX
728 # option is removed from /etc/mtab
729 if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then
730 show "Checking encrypted filesystems"; started
731 LOOPLIST="$(awk '
732 FILENAME=="/proc/mounts" {
733 TAB[$2]=$1;
734 }
735 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && /[^a-zA-Z_]ro[^a-zA-Z_]/ {
736 if ($2 in TAB){print TAB[$2];}
737 }
738 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
739 if ($2 in TAB){print TAB[$2];}
740 sub("loop(=[^,]*)?","loop=" TAB[$2] ",ro",$4);
741 cmd="mount " $2 " -o remount," $4;
742 system(cmd);
743 }
744 ' /proc/mounts /etc/fstab)"
745 initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST"
746 rc=$?
747
748 # A return of 2 or higher means there were serious problems.
749 if [ $rc -gt 1 ]; then
750 [ -e /proc/splash ] && echo "verbose" > /proc/splash
751 echo
752 echo
753 nls "*** An error occurred during the file system check."
754 nls "*** Dropping you to a shell; the system will reboot"
755 nls "*** when you leave the shell."
756 echo
757
bf14fcab 758 PS1="$(nls '(Repair filesystem)# ')"; export PS1
cc10e704 759 [ "$SELINUX" = "1" ] && disable_selinux
277e5f53 760 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
cc10e704
JR
761 /sbin/sulogin
762 else
763 /bin/sh
764 fi
6fa97a5d 765
cc10e704
JR
766 run_cmd "Unmounting file systems" umount -a
767 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
768 run_cmd "Automatic reboot in progress" reboot
769 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
770 _RUN_QUOTACHECK=1
771 fi
5e6dfc29 772
cc10e704
JR
773 show "Remounting encrypted filesystems back in rw mode"; busy
774 awk '
775 FILENAME=="/proc/mounts" {
776 TAB[$2]=$1;
777 }
778 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
779 sub("loop(=[^,]*)?","loop=" TAB[$2] ",rw",$4);
780 cmd="mount " $2 " -o remount," $4;
781 system(cmd);
782 }
783 ' /proc/mounts /etc/fstab
784 ok
785 fi
6e16ab8f 786
9a0a016d 787 # /var/log should be writable now, so start saving the boot output
652dbae5
ER
788 if [ "$RC_BOOTLOG" ]; then
789 echo > /var/log/boot.msg
790 killall -IO blogd
791 fi
cb4d1aa7 792
1aaf8c92
JR
793 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
794 run_cmd "Checking filesystem quotas" /sbin/quotacheck -vnugRa
795 fi
cb4d1aa7 796
1aaf8c92
JR
797 # Turn on quota
798 if [ -x /sbin/quotaon ]; then
799 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug
800 fi
677fdd75 801
1aaf8c92
JR
802 # Turn on process accounting
803 if [ -x /etc/rc.d/rc.acct ]; then
804 /etc/rc.d/rc.acct start
805 fi
cb4d1aa7 806
cc10e704 807 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
bc05b297 808 if is_yes "$TIME_SETUP_DELAYED" && [ -e /dev/rtc ]; then
cc10e704
JR
809 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
810 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
811 fi
0bbfed6f 812 fi
0bbfed6f 813
cc10e704
JR
814 # Initialize the serial ports
815 if [ -f /etc/rc.d/rc.serial ]; then
816 . /etc/rc.d/rc.serial
817 fi
201c98b9 818
277e5f53 819 if [ -f /proc/sys/kernel/panic -a -n "$PANIC_REBOOT_TIME" -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
cc10e704
JR
820 show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy
821 if (sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1); then ok; else fail; fi
822 fi
201c98b9 823
cc10e704
JR
824 # ... and here finish configuring parameters
825 /sbin/sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
ef05209d 826else
9a0a016d 827 # /var/log should be writable now, so star saving the boot output
652dbae5
ER
828 if [ "$RC_BOOTLOG" ]; then
829 echo > /var/log/boot.msg
830 killall -IO blogd
831 fi
832
ef05209d 833 clean_vserver_mtab
cc10e704 834fi
adec827a 835
652dbae5 836
1aaf8c92
JR
837[ -n "$SELINUX" ] && [ -f /.autorelabel ] && relabel_selinux
838
6239bd5c 839# Clean up /.
cb4d1aa7
JR
840rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff
841
842# Clean up /var
843# I'd use find, but /usr may not be mounted.
844for afile in /var/lock/* /var/run/*; do
5e6dfc29 845 bafile=$(basename $afile)
cb4d1aa7 846 if [ -d "$afile" ]; then
38b419e3
JR
847 case $bafile in
848 news|sudo|mon|cvs)
849 ;;
850 *)
851 rm -rf $afile/*
852 ;;
853 esac
cb4d1aa7 854 else
5e6dfc29 855 [ "$bafile" != "hwprofile" ] && rm -f $afile 2> /dev/null
cb4d1aa7
JR
856 fi
857done
e0cba078 858# Delete stale files
4eb58d70
AM
859rm -f /var/lib/rpm/__db* /var/spool/postoffice/.pid.* /tmp/.X*-lock \
860 /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.*
861rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \
5e6dfc29
JR
862 /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \
863 /tmp/scrollkeeper-* /tmp/ssh-*
45955ed4 864
201c98b9 865{
6b4a354c 866# Clean up utmp/wtmp
1b8e6ce0 867if ! is_no "$NEED_XFILES" ; then
6b4a354c
AM
868 :>/var/run/utmpx
869 touch /var/log/wtmpx
afa9b748 870 chown root:utmp /var/run/utmpx /var/log/wtmpx
19b0557d 871 chmod 0664 /var/run/utmpx /var/log/wtmpx
054a52c9
JR
872else
873 :>/var/run/utmp
874 touch /var/log/wtmp
afa9b748 875 chown root:utmp /var/run/utmp /var/log/wtmp
19b0557d 876 chmod 0664 /var/run/utmp /var/log/wtmp
6b4a354c 877fi
7e04fe0e 878
7e04fe0e 879# Clean /tmp
fcf89189 880if is_yes "$CLEAN_TMP"; then
cb4d1aa7 881 rm -rf /tmp/* /tmp/.[a-zA-Z0-9]*
7e04fe0e 882fi
7742e157 883
e6c8dd44
AM
884# System protected dirs
885mkdir -m 1777 -p /tmp/.ICE-unix > /dev/null 2>&1
886chown root:root /tmp/.ICE-unix
677fdd75 887[ -n "$SELINUX" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1
e6c8dd44 888
1aaf8c92
JR
889if ! is_yes "$VSERVER"; then
890 # Right, now turn on swap in case we swap to files
891 swapon -a >/dev/null 2>&1
892 run_cmd "Enabling swap space" /bin/true
7742e157 893
0d60cc3e
JR
894 # If a SCSI tape has been detected, load the st module unconditionally
895 # since many SCSI tapes don't deal well with st being loaded and unloaded
896 if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then
897 if grep -qv ' 9 st' /proc/devices 2>/dev/null; then
898 if [ -n "$USEMODULES" ] ; then
899 # Try to load the module. If it fails, ignore it...
900 insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
901 fi
7742e157
AF
902 fi
903 fi
7742e157 904
cc10e704
JR
905 # Now that we have all of our basic modules loaded and the kernel going,
906 # let's dump the syslog ring somewhere so we can find it later
907 dmesg -s 131072 > /var/log/dmesg
908 i=5
909 while [ $i -ge 0 ]; do
910 if [ -f /var/log/dmesg.$i ]; then
5e6dfc29
JR
911 chmod 0600 /var/log/dmesg.$i
912 mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1))
cc10e704
JR
913 fi
914 i=$(($i-1))
915 done
916 cp -f /var/log/dmesg /var/log/dmesg.0
917 chmod 0600 /var/log/dmesg /var/log/dmesg.0
918fi
7742e157 919
de1fc6ce 920kill -TERM $(/sbin/pidof getkey) >/dev/null 2>&1
6b4a354c 921} &
385dc542
ER
922
923# extra check if the background process we just spawned is still running,
924# as in case of vserver bootup it finishes quite instantly.
925if ! is_no "$RC_PROMPT" && [ -d /proc/$! ]; then
7c341db5 926 /sbin/getkey -c 5 i && touch /var/run/confirm
6b4a354c
AM
927fi
928wait
de1fc6ce 929echo
8192b17e
JR
930
931# This must be last line !
cc10e704 932# vi:syntax=sh
This page took 0.373161 seconds and 4 git commands to generate.