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