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