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