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