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