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