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