]>
Commit | Line | Data |
---|---|---|
12de71be | 1 | #!/bin/sh |
7742e157 AF |
2 | # |
3 | # /etc/rc.d/rc.sysinit - run once at boot time | |
ec8b15cb | 4 | # $Id$ |
7742e157 AF |
5 | # |
6 | # Taken in part from Miquel van Smoorenburg's bcheckrc. | |
7 | # | |
8 | ||
b6509675 AM |
9 | # reasonable start values for bootsplash progress. |
10 | export progress=0 | |
11 | export sscripts=45 | |
12 | export kscripts=45 | |
13 | ||
38198f50 | 14 | # NLS |
de1fc6ce | 15 | if [ -r /etc/sysconfig/i18n ]; then |
38198f50 AM |
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 | ||
418c0cf3 | 29 | # Read network config data |
de1fc6ce | 30 | if [ -r /etc/sysconfig/network ]; then |
1b228409 | 31 | . /etc/sysconfig/network |
7742e157 | 32 | else |
1b228409 | 33 | NETWORKING=no |
34 | HOSTNAME=localhost | |
7742e157 AF |
35 | fi |
36 | ||
277e5f53 | 37 | CONSOLE_LOGLEVEL=1 |
45e88cd0 | 38 | |
e298d489 JR |
39 | # Read functions |
40 | . /etc/rc.d/init.d/functions | |
41 | ||
483f1dda | 42 | disable_selinux() { |
944d6d80 | 43 | local _d selinuxfs _t _r |
483f1dda ER |
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() { | |
944d6d80 | 55 | local _d selinuxfs _t _r |
483f1dda ER |
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 | ||
3aabb390 ER |
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 | ||
0aa81245 | 97 | local module args |
3aabb390 ER |
98 | # Loop over every line in modules file |
99 | ( \ | |
a51d5138 | 100 | grep -hvE '^(#|[[:blank:]]*$)' /etc/modules /etc/modules.$kernel /etc/modules.$kerneleq 2>/dev/null |
3aabb390 ER |
101 | echo '' # make sure there is a LF at the end |
102 | ) | while read module args; do | |
103 | [ -z "$module" ] && continue | |
55bf7b40 ER |
104 | # strip comments |
105 | args=${args%%#*} | |
3aabb390 ER |
106 | modprobe -s $module -- $args |
107 | done | |
108 | } | |
483f1dda | 109 | |
48e500cd ER |
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 | ||
5163449d | 117 | if ! is_yes "$VSERVER" ; then |
a1ad6ea5 | 118 | # we need /proc mounted before everything |
90f9c9ad | 119 | is_fsmounted proc /proc || mount -n -o gid=17 -t proc /proc /proc |
a1ad6ea5 | 120 | |
b0290bbb ER |
121 | # Only read this once. |
122 | cmdline=$(cat /proc/cmdline) | |
123 | ||
5163449d JR |
124 | # sysfs is also needed before any other things (under kernel > 2.5) |
125 | if grep -q sysfs /proc/filesystems 2>/dev/null ; then | |
90f9c9ad | 126 | is_fsmounted sysfs /sys || mount -n -o gid=17 -t sysfs sysfs /sys |
5163449d JR |
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 | |
defac991 | 131 | fi |
e298d489 | 132 | |
5163449d | 133 | # selinux |
3f9e71a5 | 134 | if grep -q selinuxfs /proc/filesystems 2>/dev/null && ! is_fsmounted selinuxfs /selinux; then |
5163449d JR |
135 | mount -n -o gid=17 -t selinuxfs selinuxfs /selinux |
136 | fi | |
e298d489 | 137 | |
ffe19b59 | 138 | # PLD Linux LiveCD support |
01b60fd3 JR |
139 | if [ -x /etc/rc.d/rc.live ]; then |
140 | /etc/rc.d/rc.live | |
141 | fi | |
e298d489 | 142 | |
01b60fd3 JR |
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 | |
5e6dfc29 | 151 | fi |
e298d489 | 152 | |
01b60fd3 JR |
153 | # Disable splash when requested |
154 | [ -e /proc/splash ] && is_no "$BOOT_SPLASH" && echo "0" > /proc/splash | |
5b0f5a94 | 155 | |
c5e74817 ER |
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 | |
5e6dfc29 | 166 | fi |
677fdd75 | 167 | |
3f9e71a5 | 168 | if [ -x /sbin/restorecon ] && is_fsmounted tmpfs /dev; then |
c5e74817 ER |
169 | /sbin/restorecon -R /dev 2>/dev/null |
170 | fi | |
677fdd75 | 171 | |
7e16b45e ER |
172 | [ -z "${CONSOLETYPE}" ] && CONSOLETYPE="$(/sbin/consoletype)" |
173 | ||
c5e74817 ER |
174 | if [ "$CONSOLETYPE" = "vt" -a -x /sbin/setsysfont ]; then |
175 | /sbin/setsysfont | |
176 | fi | |
12c4fb70 | 177 | fi |
5b0f5a94 | 178 | |
652dbae5 | 179 | |
458f14b7 | 180 | # Print welcome message |
503bfc80 | 181 | nls "\t\t\t%sPowered by %sPLD Linux Distribution%s" "$(termput setaf $CPOWEREDBY)" "$(termput setaf $CPLD)" "$(termput op)" |
8a917f32 | 182 | if ! is_no "$RC_PROMPT"; then |
503bfc80 | 183 | nls -n "\t\t Press %sI%s to enter interactive startup" "$(termput setaf $CI)" "$(termput op)" |
6b4a354c | 184 | echo |
6b4a354c | 185 | fi |
201c98b9 | 186 | |
cc10e704 | 187 | # Set the hostname |
499b251c JR |
188 | if [ -z "${HOSTNAME}" ]; then |
189 | show "$(nls 'Host:') $(hostname)" ; ok | |
190 | else | |
191 | run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME} | |
192 | fi | |
6956336c | 193 | |
cc10e704 JR |
194 | # Set the NIS domain name |
195 | if [ -n "$NISDOMAIN" ]; then | |
196 | run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN | |
197 | else | |
198 | domainname "" | |
4289a4ff AM |
199 | fi |
200 | ||
cc10e704 JR |
201 | if ! is_yes "$VSERVER"; then |
202 | # Set console loglevel | |
203 | if [ -n "$CONSOLE_LOGLEVEL" ]; then | |
204 | /bin/dmesg -n $CONSOLE_LOGLEVEL | |
205 | fi | |
6bf50269 | 206 | |
348aacfc | 207 | if ! is_no "$START_UDEV"; then |
f71c07f8 | 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 | |
348aacfc | 213 | fi |
5e6dfc29 | 214 | |
6a8f0f05 | 215 | # Unmount the initrd, if necessary |
426e1497 | 216 | if grep -q /initrd /proc/mounts 2>/dev/null && ! grep -q /initrd/loopfs /proc/mounts 2>/dev/null; then |
426e1497 | 217 | umount /initrd/dev 2>/dev/null |
6a8f0f05 ER |
218 | umount /initrd |
219 | /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1 | |
220 | fi | |
221 | ||
33c6207a ER |
222 | # Start logging console output since we have all /dev stuff setup |
223 | if [ "$RC_BOOTLOG" ]; then | |
0868c9a6 | 224 | /sbin/blogd |
33c6207a ER |
225 | fi |
226 | ||
8159a411 | 227 | # cpuset support (mount if not found in fstab - should be ^# excluded?) |
5bae5434 | 228 | if grep -q cgroup /proc/filesystems 2>/dev/null ; then |
8159a411 PG |
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 | |
5bae5434 | 233 | elif grep -q cpuset /proc/filesystems 2>/dev/null ; then |
8159a411 PG |
234 | if ! grep -q cpuset /etc/fstab 2>/dev/null ; then |
235 | mount -n -t cpuset none /dev/cpuset | |
236 | fi | |
cc10e704 | 237 | fi |
201c98b9 | 238 | |
cc10e704 JR |
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 | |
201c98b9 | 242 | |
cc10e704 JR |
243 | # Set the system clock. |
244 | ARC=0 | |
245 | SRM=0 | |
246 | UTC=0 | |
201c98b9 | 247 | |
cc10e704 JR |
248 | if [ -f /etc/sysconfig/clock ]; then |
249 | . /etc/sysconfig/clock | |
201c98b9 | 250 | |
cc10e704 JR |
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 | |
201c98b9 | 258 | |
cc10e704 JR |
259 | if grep "system serial" /proc/cpuinfo 2>/dev/null | grep -q MILO 2>/dev/null ; then |
260 | ARC=true | |
261 | fi | |
cb4d1aa7 | 262 | |
cc10e704 JR |
263 | CLOCKDEF="" |
264 | CLOCKFLAGS="--hctosys" | |
cb4d1aa7 | 265 | |
cc10e704 JR |
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 | |
201c98b9 | 273 | |
cc10e704 JR |
274 | if is_yes "$ARC" ; then |
275 | CLOCKFLAGS="$CLOCKFLAGS -A" | |
276 | CLOCKDEF="$CLOCKDEF (arc)" | |
0bbfed6f | 277 | fi |
e4b0481f | 278 | |
cc10e704 JR |
279 | if is_yes "$SRM" ; then |
280 | CLOCKFLAGS="$CLOCKFLAGS -S" | |
281 | CLOCKDEF="$CLOCKDEF (srm)" | |
282 | fi | |
7742e157 | 283 | |
cc10e704 | 284 | # Check if timezone definition is available |
5ad31754 | 285 | if [ -e /etc/localtime ] ; then |
cc10e704 JR |
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 | |
7742e157 | 292 | |
6b496866 | 293 | if [ -f /etc/crypttab ] && ! is_empty_file /etc/crypttab; then |
dd23d50d ER |
294 | # XXX might need modules dep |
295 | # Device mapper & related initialization | |
a51d5138 | 296 | if ! grep -qF device-mapper /proc/devices; then |
dd23d50d ER |
297 | modprobe dm-mod |
298 | fi | |
299 | ||
300 | # but should do this before swapon? | |
301 | . /etc/rc.d/init.d/cryptsetup | |
8710c4b5 | 302 | show "Starting disk encryption" |
dd23d50d ER |
303 | init_crypto 0 && ok || fail |
304 | fi | |
305 | ||
cc10e704 JR |
306 | # Start up swapping |
307 | run_cmd "Activating swap partitions" swapon -a -e | |
308 | ||
309 | # Initialize USB controllers | |
310 | usb=0 | |
3f9e71a5 | 311 | if ! strstr "$cmdline" "nousb" && ! is_fsmounted usbfs /proc/bus/usb ; then |
86711d93 | 312 | aliases=$(/sbin/modprobe -c | awk '/^alias[\t ]+usb-controller/ { print $3 }') |
cc10e704 | 313 | if [ -n "$aliases" -a "$aliases" != "off" ] ; then |
170103c8 | 314 | /sbin/modprobe -s usbcore |
cc10e704 JR |
315 | for alias in $aliases ; do |
316 | [ "$alias" = "off" ] && continue | |
a6a4a758 | 317 | run_cmd "$(nls 'Initializing USB controller') ($alias)" /sbin/modprobe -s $alias |
cc10e704 JR |
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 | |
7742e157 | 325 | |
ff474752 | 326 | if [ "$usb" = "1" ] && ! is_fsmounted usbfs /proc/bus/usb ; then |
a40bbbec | 327 | run_cmd "Mounting USB filesystem" mount -n -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb |
b3965b3d | 328 | fi |
b3965b3d | 329 | |
cc10e704 JR |
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 | |
5e6dfc29 JR |
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 | |
cc10e704 JR |
343 | fi |
344 | fi | |
b3965b3d | 345 | |
cc10e704 | 346 | # Setup hdparm thing (if exists and is needed) |
07ea1da7 | 347 | if ! strstr "$cmdline" nohdparm; then |
cc10e704 | 348 | [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm |
ebd1845b | 349 | fi |
b3965b3d | 350 | |
07ea1da7 | 351 | if [ -f /fastboot ] || strstr "$cmdline" "fastboot"; then |
cc10e704 JR |
352 | fastboot=yes |
353 | else | |
354 | fastboot= | |
355 | fi | |
03f9cfee | 356 | |
cc10e704 JR |
357 | if [ -f /fsckoptions ]; then |
358 | fsckoptions=$(cat /fsckoptions) | |
359 | else | |
360 | fsckoptions='' | |
361 | fi | |
cb4d1aa7 | 362 | |
cc10e704 JR |
363 | if [ -f /forcefsck ]; then |
364 | fsckoptions="-f $fsckoptions" | |
790968dd ER |
365 | else |
366 | # Obey the fs_passno setting for / (see fstab(5)) | |
367 | # - find the / entry | |
6fe4e4eb ER |
368 | # - make sure we have at least 6 fields |
369 | _ROOTFS_PASSNO=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $6}' /etc/fstab) | |
cc10e704 | 370 | fi |
7742e157 | 371 | |
cc10e704 | 372 | _RUN_QUOTACHECK=0 |
dc12b33c | 373 | _ROOTFS_DEVICE=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $1}' /etc/fstab) |
2fce16f9 | 374 | _ROOTFS_TYPE=$(awk '$2 == "/" && $3 != "rootfs" { print $3 }' /proc/mounts 2>/dev/null) |
cc10e704 | 375 | |
dc12b33c | 376 | if [ -z "$fastboot" -a "$_ROOTFS_TYPE" != "nfs" -a "$_ROOTFS_TYPE" != "romfs" -a "$_ROOTFS_PASSNO" != 0 -a -e $_ROOTFS_DEVICE ]; then |
cc10e704 JR |
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 | ||
526b7c62 | 393 | PS1="`nls '(Repair filesystem)# '`"; export PS1 |
cc10e704 | 394 | [ "$SELINUX" = "1" ] && disable_selinux |
277e5f53 | 395 | if ! is_no "$RUN_SULOGIN_ON_ERR"; then |
cc10e704 JR |
396 | /sbin/sulogin |
397 | else | |
398 | /bin/sh | |
399 | fi | |
cee18a41 | 400 | |
cc10e704 JR |
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 | |
cb4d1aa7 | 419 | fi |
cb4d1aa7 | 420 | fi |
7742e157 | 421 | |
5e6dfc29 | 422 | # Check for arguments |
07ea1da7 | 423 | if strstr "$cmdline" nopnp; then |
cc10e704 JR |
424 | PNP= |
425 | else | |
426 | PNP=yes | |
427 | fi | |
7742e157 | 428 | |
cc10e704 JR |
429 | # set up pnp and kernel pnp |
430 | if [ -n "$PNP" ]; then | |
277e5f53 | 431 | if ! is_no "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then |
5e6dfc29 JR |
432 | run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf |
433 | fi | |
277e5f53 | 434 | if ! is_no "$RUN_KERNELPNP"; then |
170103c8 | 435 | /sbin/modprobe isa-pnp 2> /dev/null |
5e6dfc29 JR |
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 | |
cc10e704 | 440 | fi |
b68f99e5 | 441 | fi |
7742e157 | 442 | |
41c877f2 | 443 | _ROOTFS_RO=$(awk '($1 !~ /^#/ && $2 == "/" && ($4 == "ro" || $4 ~ /,ro$/ || $4 ~ /^ro,/ || $4 ~ /,ro,/ ) && NF >= 6) { print "ro" }' /etc/fstab) |
cc10e704 | 444 | # Remount the root filesystem read-write |
41c877f2 | 445 | if [ -z "$_ROOTFS_RO" ]; then |
47e385fd | 446 | run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw / |
447 | fi | |
cee18a41 | 448 | |
cc10e704 JR |
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 | |
aa362992 | 453 | |
5475bb0f ER |
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 | |
652dbae5 | 460 | |
6b496866 | 461 | if [ -f /etc/crypttab ] && ! is_empty_file /etc/crypttab; then |
dd23d50d | 462 | # XXX, this must be probably done after random is initialized from /var/run/random-seed |
1b05bb8a | 463 | show "Starting disk encryption using the RNG" |
dd23d50d ER |
464 | init_crypto 1 && ok || fail |
465 | fi | |
652dbae5 ER |
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 | |
677fdd75 | 471 | fi |
5e6dfc29 | 472 | |
cb4d1aa7 | 473 | # Remove stale backups |
47e385fd | 474 | rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~ >/dev/null 2>&1 |
cb4d1aa7 | 475 | |
ef05209d JR |
476 | # Remove /etc/nologin when starting system |
477 | [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot | |
478 | ||
277e5f53 | 479 | if ! is_no "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then |
ef05209d JR |
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 | ||
cc10e704 | 495 | if ! is_yes "$VSERVER"; then |
220df3e7 JR |
496 | # Clear mtab |
497 | :>/etc/mtab | |
498 | [ -f /etc/cryptomtab ] && :>/etc/cryptomtab | |
499 | ||
34c624e7 | 500 | # Enter root, /proc, /sys and other into mtab. |
cc10e704 JR |
501 | mount -f / |
502 | mount -f /proc | |
3f9e71a5 JR |
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 | |
7d45bad6 | 506 | |
3f9e71a5 | 507 | if is_fsmounted sysfs /sys; then |
cc10e704 | 508 | mount -f -t sysfs sysfs /sys |
3f9e71a5 JR |
509 | if is_fsmounted securityfs /sys/kernel/security ; then |
510 | mount -f -t securityfs securityfs /sys/kernel/security | |
defac991 | 511 | fi |
cc10e704 | 512 | fi |
ad084d91 | 513 | |
3f9e71a5 | 514 | if is_fsmounted selinuxfs /selinux; then |
cc10e704 JR |
515 | mount -f -t selinuxfs selinuxfs /selinux |
516 | fi | |
cb4d1aa7 | 517 | |
3f9e71a5 JR |
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 | |
2d495b7f | 521 | mount -f -t cpuset none /dev/cpuset |
cc10e704 | 522 | fi |
fd6887dc | 523 | |
cc10e704 JR |
524 | if [ ! -f /proc/modules ]; then |
525 | USEMODULES= | |
07ea1da7 | 526 | elif ! strstr "$cmdline" nomodules; then |
cc10e704 JR |
527 | USEMODULES=y |
528 | else | |
529 | USEMODULES= | |
4cc4301b | 530 | fi |
de1fc6ce | 531 | |
0b38e7f1 | 532 | uname_r=$(uname -r) |
cc10e704 JR |
533 | # Adjust symlinks as necessary in /boot to keep system services from |
534 | # spewing messages about mismatched System maps and so on. | |
277e5f53 | 535 | if ! is_no "$SET_SLINKS"; then |
c14f9857 ER |
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 | |
cc10e704 | 538 | fi |
c14f9857 ER |
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 | |
cc10e704 | 541 | fi |
418c0cf3 | 542 | fi |
7742e157 | 543 | |
cc10e704 JR |
544 | # Run depmod if RUN_DEPMOD != "no" and: |
545 | # a) user requested or RUN_DEPMOD=""; | |
546 | # b) modules.dep is missing | |
cc10e704 JR |
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 | |
0b38e7f1 | 550 | elif [ "$RUN_DEPMOD" = "ifmissing" ] && [ ! -f /lib/modules/$uname_r/modules.dep ]; then |
cc10e704 JR |
551 | run_cmd "Finding module dependencies" depmod -A |
552 | fi | |
aa362992 | 553 | fi |
0b38e7f1 | 554 | unset uname_r |
5bb58804 | 555 | |
cc10e704 JR |
556 | if [ -f /proc/sys/kernel/modprobe ]; then |
557 | if [ -n "$USEMODULES" ]; then | |
558 | sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1 | |
cc10e704 JR |
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 | |
cc10e704 | 563 | fi |
cb4d1aa7 | 564 | fi |
cb4d1aa7 | 565 | |
cc10e704 JR |
566 | # Load usb storage here, to match most other things |
567 | if [ -n "$needusbstorage" ]; then | |
170103c8 | 568 | modprobe usb-storage >/dev/null 2>&1 |
cc10e704 | 569 | fi |
cb4d1aa7 | 570 | |
cc10e704 | 571 | # Load firewire devices |
07ea1da7 | 572 | if ! strstr "$cmdline" nofirewire; then |
cc10e704 JR |
573 | aliases=$(/sbin/modprobe -c | awk '/^alias ieee1394-controller/ { print $3 }') |
574 | if [ -n "$aliases" -a "$aliases" != "off" ] ; then | |
5e6dfc29 JR |
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 | |
cc10e704 | 580 | fi |
5e6dfc29 JR |
581 | fi |
582 | ||
cc10e704 | 583 | # Load sound modules if they need persistent DMA buffers |
e0fdf0af | 584 | if /sbin/modprobe -c | grep -q "^options sound dmabuf=1"; then |
cc10e704 | 585 | RETURN=0 |
a51d5138 | 586 | alias=$(/sbin/modprobe -c | grep -sE "^alias[[:space:]]+sound[[:space:]]+" 2>/dev/null | awk '{ print $3 }') |
cc10e704 JR |
587 | if [ -n "$alias" -a "$alias" != "off" ] ; then |
588 | run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias | |
589 | RETURN=$? | |
590 | fi | |
a51d5138 | 591 | alias=$(/sbin/modprobe -c | grep -sE "^alias[[:space:]]+sound-slot-0[[:space:]]+" 2>/dev/null | awk '{ print $3 }') |
cc10e704 JR |
592 | if [ -n "$alias" -a "$alias" != "off" ] ; then |
593 | run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias | |
594 | RETURN=$? | |
f47acf6f JR |
595 | fi |
596 | fi | |
472fa41e | 597 | |
cc10e704 | 598 | # Load modules |
3aabb390 | 599 | load_kernel_modules |
7742e157 | 600 | |
e62309d9 | 601 | if [ -x /sbin/multipath ]; then |
2607b4f4 | 602 | # first make nodes that were discarded due (possible) new /dev mount |
6dbec259 | 603 | modprobe -s dm-mod |
2607b4f4 | 604 | /sbin/dmsetup mknodes |
7da998bd | 605 | modprobe -s dm-multipath |
e62309d9 | 606 | run_cmd "Activating dm-multipath" /sbin/multipath -v 0 |
094b84e1 | 607 | /sbin/dmsetup ls --target multipath --exec '/sbin/kpartx -a -p p' |
e62309d9 ER |
608 | fi |
609 | ||
3a4304f3 AM |
610 | if [ -x /sbin/dmraid ]; then |
611 | run_cmd "Activating ATARAID devices" /sbin/dmraid -ay | |
612 | fi | |
613 | ||
cc10e704 JR |
614 | # Find and activate volume groups: |
615 | # EVMS | |
616 | if [ -x /sbin/evms_activate ]; then | |
cc10e704 | 617 | if [ "$(kernelverser)" -lt "002006" ]; then |
5e6dfc29 | 618 | # Linux 2.4 core modules |
170103c8 | 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 | |
cc10e704 | 623 | else |
5e6dfc29 | 624 | # Linux 2.6 core module |
170103c8 | 625 | modprobe -s evmscore > /dev/null 2>&1 |
d6749722 | 626 | fi |
5e6dfc29 | 627 | |
170103c8 | 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 | |
cc10e704 JR |
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 | |
24fec6e3 ER |
635 | if [ "$(echo /dev/evms/lvm/*)" != '/dev/evms/lvm/*' ] ; then |
636 | ln -s /dev/evms/lvm/* /dev | |
de1fc6ce | 637 | fi |
cc10e704 JR |
638 | fi |
639 | fi | |
49c61c56 | 640 | |
cc10e704 JR |
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 | |
0174ae89 | 643 | lvmversion=$(LC_ALL=C /sbin/vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}') |
cc10e704 | 644 | if [ "$lvmversion" = "1" ] ; then |
170103c8 | 645 | modprobe -s lvm-mod >/dev/null 2>&1 |
cc10e704 JR |
646 | lvmignorelock="" |
647 | elif [ "$lvmversion" = "2" ] ; then | |
170103c8 | 648 | modprobe -s dm-mod >/dev/null 2>&1 |
cc10e704 JR |
649 | lvmignorelock="--ignorelockingfailure" |
650 | else | |
170103c8 | 651 | modprobe -s lvm-mod >/dev/null 2>&1 |
5e6dfc29 | 652 | # device mapper (2.5+ and patched 2.4) |
170103c8 | 653 | modprobe -s dm-mod >/dev/null 2>&1 |
5e6dfc29 | 654 | lvmignorelock="" |
cc10e704 | 655 | fi |
5e6dfc29 | 656 | |
2607b4f4 | 657 | run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelock |
cc10e704 | 658 | run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmignorelock |
fcc79c02 ER |
659 | if [ "$lvmversion" = "2" ]; then |
660 | /sbin/vgmknodes | |
661 | # display VG statistics | |
662 | /sbin/vgdisplay -s | |
663 | fi | |
cc10e704 JR |
664 | fi |
665 | ||
666 | # Add raid devices | |
667 | if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ] || [ -f /etc/raidtab ]; then | |
cc10e704 JR |
668 | modprobe -s md >/dev/null 2>&1 |
669 | if [ -f /proc/mdstat ]; then | |
5e6dfc29 JR |
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 | |
d1b96465 AM |
675 | show "Starting up RAID devices"; busy |
676 | /sbin/mdadm --assemble --scan --auto=yes | |
5e6dfc29 | 677 | rc=$? |
d1b96465 | 678 | if [ "$rc" -eq 0 -o "$rc" -eq 2 ]; then |
1851f49d AM |
679 | # rc is used later, too so set sane value |
680 | rc=0 | |
d1b96465 AM |
681 | deltext; ok |
682 | goraidtab=0 | |
683 | golvm=1 | |
684 | else | |
685 | deltext; fail | |
686 | fi | |
687 | ||
cc10e704 | 688 | fi |
5e6dfc29 JR |
689 | fi |
690 | ||
691 | if [ -f /etc/raidtab -a "$goraidtab" -eq 1 ]; then | |
49c61c56 | 692 | for i in $(awk '!/^#/ && /raiddev/{print $2}' /etc/raidtab 2>/dev/null); do |
5e6dfc29 JR |
693 | golvm=1 |
694 | RAIDDEV=$(basename $i) | |
695 | RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat 2>/dev/null) | |
696 | show "Starting up RAID device %s" $RAIDDEV | |
697 | busy | |
698 | if [ -z "$RAIDSTAT" ]; then | |
699 | # Try raidstart first...if that fails then | |
700 | # fall back to raid0run and if that fails too | |
701 | # fall back to raidadd, raidrun. | |
702 | RESULT=1 | |
703 | if [ -x /sbin/raidstart ]; then | |
704 | /sbin/raidstart $i | |
705 | RESULT=$? | |
706 | fi | |
707 | if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then | |
708 | /sbin/raid0run $i | |
709 | RESULT=$? | |
710 | fi | |
711 | if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then | |
712 | /sbin/raidadd $i | |
713 | /sbin/raidrun $i | |
714 | RESULT=$? | |
715 | fi | |
716 | if [ $RESULT -gt 0 ]; then | |
717 | rc=1 | |
718 | fail | |
719 | else | |
720 | ok | |
721 | fi | |
722 | else | |
723 | ok | |
724 | fi | |
725 | done | |
726 | fi | |
727 | ||
728 | # A non-zero return means there were problems | |
729 | if [ $rc -gt 0 ]; then | |
730 | [ -e /proc/splash ] && echo "verbose" > /proc/splash | |
731 | show "Starting up RAID devices"; fail | |
732 | echo | |
733 | echo | |
734 | nls "*** An error occurred during the RAID startup." | |
735 | nls "*** Dropping you to a shell; the system will reboot" | |
736 | nls "*** when you leave the shell." | |
737 | echo | |
738 | ||
739 | PS1="$(nls '(RAID Repair)# ')"; export PS1 | |
740 | [ "$SELINUX" = "1" ] && disable_selinux | |
277e5f53 | 741 | if ! is_no "$RUN_SULOGIN_ON_ERR"; then |
5e6dfc29 | 742 | /sbin/sulogin |
cc10e704 | 743 | else |
5e6dfc29 | 744 | /bin/sh |
cc10e704 | 745 | fi |
12de71be | 746 | |
5e6dfc29 JR |
747 | run_cmd "Unmounting file systems" umount -a |
748 | run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro / | |
749 | run_cmd "Automatic reboot in progress" reboot | |
cc10e704 | 750 | fi |
5e6dfc29 JR |
751 | # LVM on RAID (keep in sync with LVM setting few lines above) |
752 | if [ "$golvm" -eq "1" ]; then | |
619a6389 | 753 | if ! is_no "$EVMS_LVM" && [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then |
2607b4f4 | 754 | run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmignorelock |
5e6dfc29 | 755 | run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmignorelock |
2607b4f4 | 756 | [ "$lvmversion" = "2" ] && /sbin/vgmknodes |
5e6dfc29 | 757 | fi |
cc10e704 | 758 | fi |
5e6dfc29 | 759 | show "Starting up RAID devices"; ok |
2619a5cf | 760 | fi |
12de71be | 761 | fi |
7742e157 | 762 | |
cc10e704 JR |
763 | _RUN_QUOTACHECK=0 |
764 | # Check filesystems | |
07ea1da7 | 765 | if [ -z "$fastboot" ] && ! strstr "$cmdline" nofsck; then |
cc10e704 JR |
766 | rc_splash "fsck start" |
767 | show "Checking filesystems"; started | |
790968dd | 768 | initlog -c "fsck -C -T -R -A -a -P $fsckoptions" |
cc10e704 JR |
769 | |
770 | rc=$? | |
771 | ||
772 | # A return of 2 or higher means there were serious problems | |
773 | if [ $rc -gt 1 ]; then | |
774 | [ -e /proc/splash ] && echo "verbose" > /proc/splash | |
775 | echo | |
776 | echo | |
777 | nls "*** An error occurred during the file system check." | |
778 | nls "*** Dropping you to a shell; the system will reboot" | |
779 | nls "*** when you leave the shell." | |
780 | echo | |
781 | ||
782 | PS1="$(nls '(Repair filesystem)# ')"; export PS1 | |
783 | [ "$SELINUX" = "1" ] && disable_selinux | |
277e5f53 | 784 | if ! is_no "$RUN_SULOGIN_ON_ERR"; then |
cc10e704 JR |
785 | /sbin/sulogin |
786 | else | |
787 | /bin/sh | |
788 | fi | |
7742e157 | 789 | |
cc10e704 JR |
790 | run_cmd "Unmounting file systems" umount -a |
791 | run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro / | |
792 | run_cmd "Automatic reboot in progress" reboot | |
793 | elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then | |
794 | _RUN_QUOTACHECK=1 | |
795 | fi | |
796 | rc_splash "fsck stop" | |
7742e157 | 797 | fi |
7742e157 | 798 | |
cc10e704 JR |
799 | # Mount all other filesystems (except for NFS and /proc, which is already |
800 | # mounted). Contrary to standard usage, | |
801 | # filesystems are NOT unmounted in single user mode. | |
802 | ||
438bf720 | 803 | run_cmd "Mounting local filesystems" mount -a -t nonfs,nfs4,smbfs,ncpfs,proc,cifs -O no_netdev |
cc10e704 | 804 | |
9a0a016d ER |
805 | # now we have /usr mounted, recheck if we have gettext and tput available. |
806 | if is_no "$TPUT"; then | |
807 | GETTEXT= | |
348aacfc | 808 | TPUT= |
04342743 | 809 | rc_gettext_init |
9a0a016d ER |
810 | fi |
811 | ||
cc10e704 JR |
812 | # Now do some workaround - encrypted filesystems couldn't have been fsck-ed |
813 | # before mount - that's where the password is entered. | |
814 | # mount is buggy - when remounting loopback filesystem, loop=XXX | |
815 | # option is removed from /etc/mtab | |
816 | if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then | |
817 | show "Checking encrypted filesystems"; started | |
fea9b6da | 818 | LOOPLIST="$(LC_ALL=C awk ' |
cc10e704 JR |
819 | FILENAME=="/proc/mounts" { |
820 | TAB[$2]=$1; | |
821 | } | |
822 | FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && /[^a-zA-Z_]ro[^a-zA-Z_]/ { | |
823 | if ($2 in TAB){print TAB[$2];} | |
824 | } | |
825 | FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ { | |
826 | if ($2 in TAB){print TAB[$2];} | |
827 | sub("loop(=[^,]*)?","loop=" TAB[$2] ",ro",$4); | |
828 | cmd="mount " $2 " -o remount," $4; | |
829 | system(cmd); | |
830 | } | |
831 | ' /proc/mounts /etc/fstab)" | |
832 | initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST" | |
833 | rc=$? | |
834 | ||
835 | # A return of 2 or higher means there were serious problems. | |
836 | if [ $rc -gt 1 ]; then | |
837 | [ -e /proc/splash ] && echo "verbose" > /proc/splash | |
838 | echo | |
839 | echo | |
840 | nls "*** An error occurred during the file system check." | |
841 | nls "*** Dropping you to a shell; the system will reboot" | |
842 | nls "*** when you leave the shell." | |
843 | echo | |
844 | ||
bf14fcab | 845 | PS1="$(nls '(Repair filesystem)# ')"; export PS1 |
cc10e704 | 846 | [ "$SELINUX" = "1" ] && disable_selinux |
277e5f53 | 847 | if ! is_no "$RUN_SULOGIN_ON_ERR"; then |
cc10e704 JR |
848 | /sbin/sulogin |
849 | else | |
850 | /bin/sh | |
851 | fi | |
6fa97a5d | 852 | |
cc10e704 JR |
853 | run_cmd "Unmounting file systems" umount -a |
854 | run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro / | |
855 | run_cmd "Automatic reboot in progress" reboot | |
856 | elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then | |
857 | _RUN_QUOTACHECK=1 | |
858 | fi | |
5e6dfc29 | 859 | |
cc10e704 JR |
860 | show "Remounting encrypted filesystems back in rw mode"; busy |
861 | awk ' | |
862 | FILENAME=="/proc/mounts" { | |
863 | TAB[$2]=$1; | |
864 | } | |
865 | FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ { | |
866 | sub("loop(=[^,]*)?","loop=" TAB[$2] ",rw",$4); | |
867 | cmd="mount " $2 " -o remount," $4; | |
868 | system(cmd); | |
869 | } | |
870 | ' /proc/mounts /etc/fstab | |
871 | ok | |
872 | fi | |
6e16ab8f | 873 | |
9a0a016d | 874 | # /var/log should be writable now, so start saving the boot output |
652dbae5 ER |
875 | if [ "$RC_BOOTLOG" ]; then |
876 | echo > /var/log/boot.msg | |
877 | killall -IO blogd | |
878 | fi | |
cb4d1aa7 | 879 | |
1aaf8c92 JR |
880 | if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then |
881 | run_cmd "Checking filesystem quotas" /sbin/quotacheck -vnugRa | |
882 | fi | |
cb4d1aa7 | 883 | |
1aaf8c92 JR |
884 | # Turn on quota |
885 | if [ -x /sbin/quotaon ]; then | |
886 | run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug | |
887 | fi | |
677fdd75 | 888 | |
1aaf8c92 JR |
889 | # Turn on process accounting |
890 | if [ -x /etc/rc.d/rc.acct ]; then | |
891 | /etc/rc.d/rc.acct start | |
892 | fi | |
cb4d1aa7 | 893 | |
cc10e704 | 894 | # Set the clock if timezone definition wasn't available (eg. /usr not mounted) |
280fc816 | 895 | if is_yes "$TIME_SETUP_DELAYED"; then |
cc10e704 JR |
896 | if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then |
897 | show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok | |
898 | fi | |
0bbfed6f | 899 | fi |
0bbfed6f | 900 | |
cc10e704 JR |
901 | # Initialize the serial ports |
902 | if [ -f /etc/rc.d/rc.serial ]; then | |
903 | . /etc/rc.d/rc.serial | |
904 | fi | |
201c98b9 | 905 | |
277e5f53 | 906 | if [ -f /proc/sys/kernel/panic -a -n "$PANIC_REBOOT_TIME" -a "$PANIC_REBOOT_TIME" -gt "0" ]; then |
cc10e704 JR |
907 | show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy |
908 | if (sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1); then ok; else fail; fi | |
909 | fi | |
201c98b9 | 910 | |
cc10e704 JR |
911 | # ... and here finish configuring parameters |
912 | /sbin/sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1 | |
ef05209d | 913 | else |
fea9b6da | 914 | # /var/log should be writable now, so start saving the boot output |
652dbae5 ER |
915 | if [ "$RC_BOOTLOG" ]; then |
916 | echo > /var/log/boot.msg | |
917 | killall -IO blogd | |
918 | fi | |
919 | ||
ef05209d | 920 | clean_vserver_mtab |
cc10e704 | 921 | fi |
adec827a | 922 | |
652dbae5 | 923 | |
1aaf8c92 JR |
924 | [ -n "$SELINUX" ] && [ -f /.autorelabel ] && relabel_selinux |
925 | ||
6239bd5c | 926 | # Clean up /. |
47e385fd | 927 | rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff >/dev/null 2>&1 |
cb4d1aa7 JR |
928 | |
929 | # Clean up /var | |
5145ce41 | 930 | # /usr could be still not mounted if it is on NFS. |
cb4d1aa7 | 931 | for afile in /var/lock/* /var/run/*; do |
fea9b6da | 932 | bafile=${afile##*/} |
cb4d1aa7 | 933 | if [ -d "$afile" ]; then |
38b419e3 | 934 | case $bafile in |
fea9b6da ER |
935 | news|sudo|mon|cvs) |
936 | ;; | |
937 | *) | |
91dc9337 | 938 | echo $afile/* | xargs rm -rf |
fea9b6da | 939 | ;; |
38b419e3 | 940 | esac |
cb4d1aa7 | 941 | else |
5e6dfc29 | 942 | [ "$bafile" != "hwprofile" ] && rm -f $afile 2> /dev/null |
cb4d1aa7 JR |
943 | fi |
944 | done | |
5145ce41 | 945 | |
e0cba078 | 946 | # Delete stale files |
4eb58d70 AM |
947 | rm -f /var/lib/rpm/__db* /var/spool/postoffice/.pid.* /tmp/.X*-lock \ |
948 | /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.* | |
949 | rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \ | |
5e6dfc29 JR |
950 | /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \ |
951 | /tmp/scrollkeeper-* /tmp/ssh-* | |
45955ed4 | 952 | |
201c98b9 | 953 | { |
6b4a354c | 954 | # Clean up utmp/wtmp |
fea9b6da | 955 | if ! is_no "$NEED_XFILES"; then |
6b4a354c AM |
956 | :>/var/run/utmpx |
957 | touch /var/log/wtmpx | |
afa9b748 | 958 | chown root:utmp /var/run/utmpx /var/log/wtmpx |
19b0557d | 959 | chmod 0664 /var/run/utmpx /var/log/wtmpx |
054a52c9 JR |
960 | else |
961 | :>/var/run/utmp | |
962 | touch /var/log/wtmp | |
afa9b748 | 963 | chown root:utmp /var/run/utmp /var/log/wtmp |
19b0557d | 964 | chmod 0664 /var/run/utmp /var/log/wtmp |
6b4a354c | 965 | fi |
7e04fe0e | 966 | |
7e04fe0e | 967 | # Clean /tmp |
fcf89189 | 968 | if is_yes "$CLEAN_TMP"; then |
fea9b6da | 969 | # XXX LC_ALL needed here |
cb4d1aa7 | 970 | rm -rf /tmp/* /tmp/.[a-zA-Z0-9]* |
7e04fe0e | 971 | fi |
7742e157 | 972 | |
e6c8dd44 AM |
973 | # System protected dirs |
974 | mkdir -m 1777 -p /tmp/.ICE-unix > /dev/null 2>&1 | |
975 | chown root:root /tmp/.ICE-unix | |
677fdd75 | 976 | [ -n "$SELINUX" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1 |
e6c8dd44 | 977 | |
1aaf8c92 | 978 | if ! is_yes "$VSERVER"; then |
fea9b6da | 979 | run_cmd "Enabling swap space" /bin/true |
1aaf8c92 JR |
980 | # Right, now turn on swap in case we swap to files |
981 | swapon -a >/dev/null 2>&1 | |
7742e157 | 982 | |
0d60cc3e JR |
983 | # If a SCSI tape has been detected, load the st module unconditionally |
984 | # since many SCSI tapes don't deal well with st being loaded and unloaded | |
985 | if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then | |
986 | if grep -qv ' 9 st' /proc/devices 2>/dev/null; then | |
987 | if [ -n "$USEMODULES" ] ; then | |
988 | # Try to load the module. If it fails, ignore it... | |
989 | insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1 | |
990 | fi | |
7742e157 AF |
991 | fi |
992 | fi | |
7742e157 | 993 | |
cc10e704 JR |
994 | # Now that we have all of our basic modules loaded and the kernel going, |
995 | # let's dump the syslog ring somewhere so we can find it later | |
c8f4b766 | 996 | dmesg > /var/log/dmesg |
cc10e704 JR |
997 | i=5 |
998 | while [ $i -ge 0 ]; do | |
999 | if [ -f /var/log/dmesg.$i ]; then | |
5e6dfc29 JR |
1000 | chmod 0600 /var/log/dmesg.$i |
1001 | mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1)) | |
cc10e704 JR |
1002 | fi |
1003 | i=$(($i-1)) | |
1004 | done | |
1005 | cp -f /var/log/dmesg /var/log/dmesg.0 | |
1006 | chmod 0600 /var/log/dmesg /var/log/dmesg.0 | |
1007 | fi | |
7742e157 | 1008 | |
a81df7c5 AM |
1009 | if ! is_no "$RC_PROMPT"; then |
1010 | while :; do | |
1011 | pid=$(/sbin/pidof getkey) | |
1012 | [ -n "$pid" -o -e /var/run/getkey_done ] && break | |
1013 | usleep 100000 | |
1014 | done | |
1015 | [ -n "$pid" ] && kill -TERM "$pid" >/dev/null 2>&1 | |
1016 | fi | |
6b4a354c | 1017 | } & |
385dc542 | 1018 | |
863baad1 | 1019 | # /proc extra check if the background process we just spawned is still running, |
385dc542 | 1020 | # as in case of vserver bootup it finishes quite instantly. |
863baad1 | 1021 | if ! is_no "$RC_PROMPT" && [ -d /proc/$! ]; then |
a81df7c5 AM |
1022 | /sbin/getkey i && touch /var/run/confirm |
1023 | touch /var/run/getkey_done | |
6b4a354c AM |
1024 | fi |
1025 | wait | |
a81df7c5 AM |
1026 | if ! is_no "$RC_PROMPT"; then |
1027 | rm -f /var/run/getkey_done | |
1028 | fi | |
de1fc6ce | 1029 | echo |