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