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