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