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