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