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