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