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