| 1 | #!/bin/bash |
|---|
| 2 | # |
|---|
| 3 | # /etc/rc.sysinit - run once at boot time |
|---|
| 4 | # |
|---|
| 5 | # Taken in part from Miquel van Smoorenburg's bcheckrc. |
|---|
| 6 | # |
|---|
| 7 | |
|---|
| 8 | # Set the path |
|---|
| 9 | PATH=/bin:/sbin:/usr/bin:/usr/sbin |
|---|
| 10 | export PATH |
|---|
| 11 | |
|---|
| 12 | HOSTNAME=`/bin/hostname` |
|---|
| 13 | HOSTTYPE=`uname -m` |
|---|
| 14 | KERNELRELEASE=`uname -r` |
|---|
| 15 | KERNELVERSION=`echo $KERNELRELEASE | cut -f 1-2 -d.` |
|---|
| 16 | |
|---|
| 17 | # VLEE: make host dependent /etc |
|---|
| 18 | if [ -x /etc/rc.diskless ]; then |
|---|
| 19 | echo -n "Preparing diskless setup :" |
|---|
| 20 | if /etc/rc.diskless ; then |
|---|
| 21 | echo " [ OK ]" |
|---|
| 22 | else |
|---|
| 23 | echo " [ NG ]" |
|---|
| 24 | fi |
|---|
| 25 | elif [ -x /DLKit/etc/rc.diskless ]; then |
|---|
| 26 | echo -n "Preparing diskless setup :" |
|---|
| 27 | if /DLKit/etc/rc.diskless ; then |
|---|
| 28 | echo " [ OK ]" |
|---|
| 29 | else |
|---|
| 30 | echo " [ NG ]" |
|---|
| 31 | fi |
|---|
| 32 | fi |
|---|
| 33 | |
|---|
| 34 | # Read in config data. |
|---|
| 35 | if [ -f /etc/sysconfig/network ]; then |
|---|
| 36 | . /etc/sysconfig/network |
|---|
| 37 | else |
|---|
| 38 | NETWORKING=no |
|---|
| 39 | fi |
|---|
| 40 | |
|---|
| 41 | if [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" ]; then |
|---|
| 42 | HOSTNAME=localhost |
|---|
| 43 | fi |
|---|
| 44 | |
|---|
| 45 | # Mount /run |
|---|
| 46 | mount -n -t tmpfs none /run >/dev/null 2>&1 |
|---|
| 47 | # Mount /dev |
|---|
| 48 | mount -n -t devtmpfs none /dev >/dev/null 2>&1 |
|---|
| 49 | # Mount /proc, /sys |
|---|
| 50 | if [ ! -e /proc/mounts ]; then |
|---|
| 51 | mount -n -t proc /proc /proc |
|---|
| 52 | mount -n -t sysfs /sys /sys >/dev/null 2>&1 |
|---|
| 53 | fi |
|---|
| 54 | if [ ! -d /proc/bus/usb ]; then |
|---|
| 55 | modprobe usbcore >/dev/null 2>&1 && mount -n -t usbfs /proc/bus/usb /proc/bus/usb |
|---|
| 56 | else |
|---|
| 57 | mount -n -t usbfs /proc/bus/usb /proc/bus/usb |
|---|
| 58 | fi |
|---|
| 59 | |
|---|
| 60 | # readahead |
|---|
| 61 | if [ -f /.readahead_collect -a -r /etc/sysconfig/readahead ]; then |
|---|
| 62 | . /etc/sysconfig/readahead |
|---|
| 63 | if [ "x$READAHEAD_COLLECT" == "xyes" -a ! -f /forcefsck -a -x /sbin/readahead-collector ]; then |
|---|
| 64 | /sbin/readahead-collector |
|---|
| 65 | fi |
|---|
| 66 | elif [ -x /sbin/readahead_early ]; then |
|---|
| 67 | /sbin/readahead_early & |
|---|
| 68 | fi |
|---|
| 69 | |
|---|
| 70 | if [ -x /etc/rc.early.local ]; then |
|---|
| 71 | . /etc/rc.early.local |
|---|
| 72 | fi |
|---|
| 73 | |
|---|
| 74 | # Source functions |
|---|
| 75 | . /etc/init.d/functions |
|---|
| 76 | |
|---|
| 77 | PLYMOUTH= |
|---|
| 78 | [ -x /usr/bin/plymouth ] && PLYMOUTH=yes |
|---|
| 79 | |
|---|
| 80 | # Print a banner. ;) |
|---|
| 81 | echo -en $"\t\t\tWelcome to " |
|---|
| 82 | [ "$BOOTUP" != "serial" ] && echo -en $"\\033[1;36m" |
|---|
| 83 | echo -en $"Vine" |
|---|
| 84 | [ "$BOOTUP" != "serial" ] && echo -en $"\\033[0;39m" |
|---|
| 85 | echo $" Linux" |
|---|
| 86 | if [ "$PROMPT" != "no" ]; then |
|---|
| 87 | echo -en $"\t\tPress 'I' to enter interactive startup." |
|---|
| 88 | echo |
|---|
| 89 | fi |
|---|
| 90 | |
|---|
| 91 | # Fix console loglevel |
|---|
| 92 | /bin/dmesg -n $LOGLEVEL |
|---|
| 93 | |
|---|
| 94 | # read /proc/cmdline once |
|---|
| 95 | cmdline=$(cat /proc/cmdline) |
|---|
| 96 | |
|---|
| 97 | # Initialize hardware |
|---|
| 98 | if [ -f /proc/sys/kernel/modprobe ]; then |
|---|
| 99 | if ! strstr "$cmdline" nomodules && [ -f /proc/modules ] ; then |
|---|
| 100 | sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1 |
|---|
| 101 | else |
|---|
| 102 | sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1 |
|---|
| 103 | fi |
|---|
| 104 | fi |
|---|
| 105 | |
|---|
| 106 | touch /dev/.in_sysinit >/dev/null 2>&1 |
|---|
| 107 | |
|---|
| 108 | # kill nash and start udev |
|---|
| 109 | nashpid=$(pidof nash 2>/dev/null) |
|---|
| 110 | [ -n "$nashpid" ] && kill $nashpid >/dev/null 2>&1 |
|---|
| 111 | unset nashpid |
|---|
| 112 | if [ ! -f "/lxcroot" ]; then |
|---|
| 113 | /sbin/start_udev |
|---|
| 114 | fi |
|---|
| 115 | |
|---|
| 116 | # static /dev filesystem |
|---|
| 117 | if [ -x /etc/rc.MAKEDEV ]; then |
|---|
| 118 | action $"Making and Mounting /dev filesystem: " /etc/rc.d/rc.MAKEDEV |
|---|
| 119 | elif [ -x /DLKit/etc/rc.MAKEDEV ]; then |
|---|
| 120 | action $"Making and Mounting /dev filesystem: " /DLKit/etc/rc.d/rc.MAKEDEV |
|---|
| 121 | fi |
|---|
| 122 | |
|---|
| 123 | # Load user-defined modules |
|---|
| 124 | for file in /etc/sysconfig/modules/*.modules ; do |
|---|
| 125 | [ -x $file ] && $file |
|---|
| 126 | done |
|---|
| 127 | |
|---|
| 128 | # Load modules (for backward compatibility with VARs) |
|---|
| 129 | if [ -f /etc/rc.modules ]; then |
|---|
| 130 | /etc/rc.modules |
|---|
| 131 | fi |
|---|
| 132 | |
|---|
| 133 | # Unmount the initrd, if necessary |
|---|
| 134 | if grep -q /initrd /proc/mounts && ! grep -q /initrd/loopfs /proc/mounts ; then |
|---|
| 135 | action $"Unmounting initrd: " umount /initrd |
|---|
| 136 | /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1 |
|---|
| 137 | fi |
|---|
| 138 | |
|---|
| 139 | # load SCSI modules |
|---|
| 140 | for module in `/sbin/modprobe -c | LC_ALL=C awk '/^alias[[:space:]]+scsi_hostadapter[0-9]*[[:space:]]/ { print $3 }'` |
|---|
| 141 | do |
|---|
| 142 | if ( modprobe --dry-run $module 2> /dev/null ) ; then |
|---|
| 143 | action $"Loading SCSI module ($module): " /sbin/modprobe $module |
|---|
| 144 | fi |
|---|
| 145 | done |
|---|
| 146 | |
|---|
| 147 | # Configure kernel parameters |
|---|
| 148 | update_boot_stage RCkernelparam |
|---|
| 149 | action $"Configuring kernel parameters: " sysctl -e -p /etc/sysctl.conf |
|---|
| 150 | |
|---|
| 151 | # Set the system clock. |
|---|
| 152 | ARC=0 |
|---|
| 153 | SRM=0 |
|---|
| 154 | UTC=0 |
|---|
| 155 | |
|---|
| 156 | if [ -f /etc/sysconfig/clock ]; then |
|---|
| 157 | . /etc/sysconfig/clock |
|---|
| 158 | |
|---|
| 159 | # convert old style clock config to new values |
|---|
| 160 | if [ "${CLOCKMODE}" = "GMT" ]; then |
|---|
| 161 | UTC=true |
|---|
| 162 | elif [ "${CLOCKMODE}" = "ARC" ]; then |
|---|
| 163 | ARC=true |
|---|
| 164 | fi |
|---|
| 165 | fi |
|---|
| 166 | |
|---|
| 167 | CLOCKDEF="" |
|---|
| 168 | CLOCKFLAGS="$CLOCKFLAGS --hctosys" |
|---|
| 169 | |
|---|
| 170 | case "$UTC" in |
|---|
| 171 | yes|true) |
|---|
| 172 | CLOCKFLAGS="$CLOCKFLAGS --utc"; |
|---|
| 173 | CLOCKDEF="$CLOCKDEF (utc)"; |
|---|
| 174 | ;; |
|---|
| 175 | no|false) |
|---|
| 176 | CLOCKFLAGS="$CLOCKFLAGS --localtime"; |
|---|
| 177 | CLOCKDEF="$CLOCKDEF (localtime)"; |
|---|
| 178 | ;; |
|---|
| 179 | esac |
|---|
| 180 | |
|---|
| 181 | case "$ARC" in |
|---|
| 182 | yes|true) |
|---|
| 183 | CLOCKFLAGS="$CLOCKFLAGS --arc"; |
|---|
| 184 | CLOCKDEF="$CLOCKDEF (arc)"; |
|---|
| 185 | ;; |
|---|
| 186 | esac |
|---|
| 187 | case "$SRM" in |
|---|
| 188 | yes|true) |
|---|
| 189 | CLOCKFLAGS="$CLOCKFLAGS --srm"; |
|---|
| 190 | CLOCKDEF="$CLOCKDEF (srm)"; |
|---|
| 191 | ;; |
|---|
| 192 | esac |
|---|
| 193 | |
|---|
| 194 | /sbin/hwclock $CLOCKFLAGS |
|---|
| 195 | |
|---|
| 196 | action $"Setting clock $CLOCKDEF: `date`" date |
|---|
| 197 | |
|---|
| 198 | if [ "`/sbin/consoletype`" = "vt" ]; then |
|---|
| 199 | # Load keymap |
|---|
| 200 | if [ -x /bin/loadkeys ]; then |
|---|
| 201 | KEYTABLE= |
|---|
| 202 | KEYMAP= |
|---|
| 203 | if [ -f /etc/sysconfig/console/default.kmap ]; then |
|---|
| 204 | KEYMAP=/etc/sysconfig/console/default.kmap |
|---|
| 205 | else |
|---|
| 206 | if [ -f /etc/sysconfig/keyboard ]; then |
|---|
| 207 | . /etc/sysconfig/keyboard |
|---|
| 208 | fi |
|---|
| 209 | if [ -n "$KEYTABLE" -a -d "/lib/kbd/keymaps" ]; then |
|---|
| 210 | KEYMAP=$KEYTABLE |
|---|
| 211 | fi |
|---|
| 212 | fi |
|---|
| 213 | if [ -n "$KEYMAP" ]; then |
|---|
| 214 | # Since this takes in/output from stdin/out, we can't use initlog |
|---|
| 215 | if [ -n "$KEYTABLE" ]; then |
|---|
| 216 | echo -n $"Loading default keymap ($KEYTABLE): " |
|---|
| 217 | else |
|---|
| 218 | echo -n $"Loading default keymap: " |
|---|
| 219 | fi |
|---|
| 220 | loadkeys $KEYMAP < /dev/tty0 > /dev/tty0 2>/dev/null && \ |
|---|
| 221 | success $"Loading default keymap" || failure $"Loading default keymap" |
|---|
| 222 | echo |
|---|
| 223 | fi |
|---|
| 224 | fi |
|---|
| 225 | fi |
|---|
| 226 | |
|---|
| 227 | # Start up swapping. |
|---|
| 228 | action $"Activating swap partitions: " swapon -a -e |
|---|
| 229 | |
|---|
| 230 | # Set the hostname. |
|---|
| 231 | update_boot_stage RChostname |
|---|
| 232 | action $"Setting hostname ${HOSTNAME}: " hostname ${HOSTNAME} |
|---|
| 233 | |
|---|
| 234 | # Sync waiting for storage. |
|---|
| 235 | { rmmod scsi_wait_scan ; modprobe scsi_wait_scan ; rmmod scsi_wait_scan ; } >/dev/null 2>&1 |
|---|
| 236 | |
|---|
| 237 | # Device mapper & related initialization |
|---|
| 238 | if ! grep -q -F "device-mapper" /proc/devices >/dev/null 2>&1 ; then |
|---|
| 239 | modprobe dm-mod >/dev/null 2>&1 |
|---|
| 240 | fi |
|---|
| 241 | |
|---|
| 242 | [ -f /etc/mdadm.conf -a -x /sbin/mdadm ] && /sbin/mdadm -As --auto=yes --run |
|---|
| 243 | |
|---|
| 244 | if ! strstr "$cmdline" nompath && [ -f /etc/multipath.conf ] && [ -x /sbin/multipath ]; then |
|---|
| 245 | modprobe dm-multipath >/dev/null 2>&1 |
|---|
| 246 | /sbin/multipath -v 0 |
|---|
| 247 | if [ -x /sbin/kpartx ]; then |
|---|
| 248 | /sbin/dmsetup ls --target multipath --exec "/sbin/kpartx -a" |
|---|
| 249 | fi |
|---|
| 250 | fi |
|---|
| 251 | |
|---|
| 252 | if ! strstr "$cmdline" nodmraid && [ -x /sbin/dmraid.static ]; then |
|---|
| 253 | modprobe dm-mirror > /dev/null 2>&1 |
|---|
| 254 | dmraidsets=$(LC_ALL=C /sbin/dmraid -s -c -i) |
|---|
| 255 | if [ "$?" = "0" ]; then |
|---|
| 256 | for dmname in $dmraidsets; do |
|---|
| 257 | if [[ "$dmname" == isw_* ]] && \ |
|---|
| 258 | ! strstr "$cmdline" noiswmd; then |
|---|
| 259 | continue |
|---|
| 260 | fi |
|---|
| 261 | /sbin/dmraid.static -ay -i --rm_partitions -p "$dmname" >/dev/null 2>&1 |
|---|
| 262 | /sbin/kpartx -a -p p "/dev/mapper/$dmname" |
|---|
| 263 | done |
|---|
| 264 | fi |
|---|
| 265 | fi |
|---|
| 266 | |
|---|
| 267 | # Start any MD RAID arrays that haven't been started yet |
|---|
| 268 | [ -r /proc/mdstat ] && [ -r /dev/md/md-device-map ] && /sbin/mdadm -IRs |
|---|
| 269 | |
|---|
| 270 | if [ -x /sbin/lvm ]; then |
|---|
| 271 | action $"Setting up Logical Volume Management:" /sbin/lvm vgchange -a y --sysinit |
|---|
| 272 | action $"Creating LVM devices:" /sbin/lvm vgscan --mknodes --ignorelockingfailure |
|---|
| 273 | fi |
|---|
| 274 | |
|---|
| 275 | update_boot_stage RCfsck |
|---|
| 276 | |
|---|
| 277 | if [ -f /fastboot ] || [ -f /lxcroot ] || strstr "$cmdline" fastboot ; then |
|---|
| 278 | fastboot=yes |
|---|
| 279 | else |
|---|
| 280 | fastboot= |
|---|
| 281 | fi |
|---|
| 282 | |
|---|
| 283 | if [ -f /fsckoptions ]; then |
|---|
| 284 | fsckoptions=`cat /fsckoptions` |
|---|
| 285 | else |
|---|
| 286 | fsckoptions= |
|---|
| 287 | fi |
|---|
| 288 | |
|---|
| 289 | READONLY= |
|---|
| 290 | if [ -f /etc/sysconfig/readonly-root ]; then |
|---|
| 291 | . /etc/sysconfig/readonly-root |
|---|
| 292 | fi |
|---|
| 293 | if strstr "$cmdline" readonlyroot ; then |
|---|
| 294 | READONLY=yes |
|---|
| 295 | fi |
|---|
| 296 | if strstr "$cmdline" noreadonlyroot ; then |
|---|
| 297 | READONLY=no |
|---|
| 298 | fi |
|---|
| 299 | |
|---|
| 300 | |
|---|
| 301 | if [ -f /forcefsck ]; then |
|---|
| 302 | fsckoptions="-f $fsckoptions" |
|---|
| 303 | elif [ -f /.autofsck ] && [ ! -f /lxcroot ]; then |
|---|
| 304 | echo $"Your system appears to have shut down uncleanly" |
|---|
| 305 | AUTOFSCK_TIMEOUT=5 |
|---|
| 306 | AUTOFSCK_DEF_CHECK=no |
|---|
| 307 | [ -f /etc/sysconfig/autofsck ] && . /etc/sysconfig/autofsck |
|---|
| 308 | if [ "$AUTOFSCK_DEF_CHECK" = "yes" ] ; then |
|---|
| 309 | AUTOFSCK_OPT=-f |
|---|
| 310 | else |
|---|
| 311 | AUTOFSCK_OPT= |
|---|
| 312 | fi |
|---|
| 313 | |
|---|
| 314 | if [ "$PROMPT" != "no" ]; then |
|---|
| 315 | if [ "$AUTOFSCK_DEF_CHECK" = "yes" ] ; then |
|---|
| 316 | if /sbin/getkey -c $AUTOFSCK_TIMEOUT -m $"Press N within %d seconds to not force file system integrity check..." n ; then |
|---|
| 317 | AUTOFSCK_OPT= |
|---|
| 318 | fi |
|---|
| 319 | else |
|---|
| 320 | if /sbin/getkey -c $AUTOFSCK_TIMEOUT -m $"Press Y within %d seconds to force file system integrity check..." y ; then |
|---|
| 321 | AUTOFSCK_OPT=-f |
|---|
| 322 | fi |
|---|
| 323 | fi |
|---|
| 324 | echo |
|---|
| 325 | else |
|---|
| 326 | # PROMPT not allowed |
|---|
| 327 | if [ "$AUTOFSCK_DEF_CHECK" = "yes" ] ; then |
|---|
| 328 | echo $"Forcing file system integrity check due to default setting" |
|---|
| 329 | else |
|---|
| 330 | echo $"Not forcing file system integrity check due to default setting" |
|---|
| 331 | fi |
|---|
| 332 | fi |
|---|
| 333 | fsckoptions="$AUTOFSCK_OPT $fsckoptions" |
|---|
| 334 | fi |
|---|
| 335 | |
|---|
| 336 | if [ "$BOOTUP" != "serial" ]; then |
|---|
| 337 | fsckoptions="-C $fsckoptions" |
|---|
| 338 | else |
|---|
| 339 | fsckoptions="-V $fsckoptions" |
|---|
| 340 | fi |
|---|
| 341 | |
|---|
| 342 | _RUN_QUOTACHECK=0 |
|---|
| 343 | ROOTFSTYPE=`grep " / " /proc/mounts | awk '{ print $3 }'` |
|---|
| 344 | if [ -z "$fastboot" -a "$READONLY" != "yes" -a "$ROOTFSTYPE" != "nfs" -a "$ROOTFSTYPE" != "reiserfs" -a "$ROOTFSTYPE" != "unionfs" -a "$ROOTFSTYPE" != "squashfs" ]; then |
|---|
| 345 | |
|---|
| 346 | STRING=$"Checking root filesystem" |
|---|
| 347 | echo $STRING |
|---|
| 348 | fsck -T -a $fsckoptions / |
|---|
| 349 | rc=$? |
|---|
| 350 | |
|---|
| 351 | if [ "$rc" = "0" ]; then |
|---|
| 352 | success "$STRING" |
|---|
| 353 | echo |
|---|
| 354 | elif [ "$rc" = "1" ]; then |
|---|
| 355 | passed $"$STRING" |
|---|
| 356 | echo |
|---|
| 357 | fi |
|---|
| 358 | |
|---|
| 359 | # A return of 2 or higher means there were serious problems. |
|---|
| 360 | if [ $rc -gt 1 ]; then |
|---|
| 361 | [ -n "$PLYMOUTH" ] && plymouth --hide-splash |
|---|
| 362 | |
|---|
| 363 | failure "$STRING" |
|---|
| 364 | echo |
|---|
| 365 | echo |
|---|
| 366 | echo $"*** An error occurred during the file system check." |
|---|
| 367 | echo $"*** Dropping you to a shell; the system will reboot" |
|---|
| 368 | echo $"*** when you leave the shell." |
|---|
| 369 | |
|---|
| 370 | PS1=$"(Repair filesystem) \# # "; export PS1 |
|---|
| 371 | sulogin |
|---|
| 372 | |
|---|
| 373 | echo $"Unmounting file systems" |
|---|
| 374 | umount -a |
|---|
| 375 | mount -n -o remount,ro / |
|---|
| 376 | echo $"Automatic reboot in progress." |
|---|
| 377 | reboot -f |
|---|
| 378 | elif [ "$rc" = "1" ]; then |
|---|
| 379 | _RUN_QUOTACHECK=1 |
|---|
| 380 | fi |
|---|
| 381 | fi |
|---|
| 382 | |
|---|
| 383 | update_boot_stage RCquotacheck |
|---|
| 384 | |
|---|
| 385 | # Possibly update quotas if fsck was run on /. |
|---|
| 386 | grep -E '[[:space:]]+/[[:space:]]+' /etc/fstab | \ |
|---|
| 387 | awk '{ print $4 }' | \ |
|---|
| 388 | grep -q quota |
|---|
| 389 | _ROOT_HAS_QUOTA=$? |
|---|
| 390 | if [ X"$_RUN_QUOTACHECK" = X1 -a \ |
|---|
| 391 | "$_ROOT_HAS_QUOTA" -a \ |
|---|
| 392 | -x /sbin/quotacheck ]; then |
|---|
| 393 | if [ -x /sbin/convertquota ]; then |
|---|
| 394 | if [ -f /quota.user ]; then |
|---|
| 395 | action $"Converting old user quota files: " \ |
|---|
| 396 | /sbin/convertquota -u / && rm -f /quota.user |
|---|
| 397 | fi |
|---|
| 398 | if [ -f /quota.group ]; then |
|---|
| 399 | action $"Converting old group quota files: " \ |
|---|
| 400 | /sbin/convertquota -g / && rm -f /quota.group |
|---|
| 401 | fi |
|---|
| 402 | fi |
|---|
| 403 | action $"Checking root filesystem quotas: " /sbin/quotacheck -nug / |
|---|
| 404 | fi |
|---|
| 405 | |
|---|
| 406 | # check for arguments passed from kernel |
|---|
| 407 | |
|---|
| 408 | update_boot_stage RCmountfs |
|---|
| 409 | |
|---|
| 410 | # Remount the root filesystem in specified mode |
|---|
| 411 | state=`awk '/(^\/dev\/root| \/ )/ { print $4 }' /proc/mounts` |
|---|
| 412 | newstate=`awk '/^#/{next} $2 == "/" {print $4 }' /etc/fstab` |
|---|
| 413 | if strstr "$cmdline" no_remount_rootfs ;then |
|---|
| 414 | action $"Staying readonly root filesystem mode : " /bin/true |
|---|
| 415 | else |
|---|
| 416 | [ "$state" != "rw" ] && [ ! -f "/lxcroot" ] && \ |
|---|
| 417 | action $"Remounting root filesystem in specified mode($newstate): " mount -n -o remount,$newstate / |
|---|
| 418 | fi |
|---|
| 419 | |
|---|
| 420 | if [ "$READONLY" != "yes" ]; then |
|---|
| 421 | # Clear mtab |
|---|
| 422 | (>/etc/mtab) &> /dev/null |
|---|
| 423 | |
|---|
| 424 | # Remove stale backups |
|---|
| 425 | rm -f /etc/mtab~ /etc/mtab~~ |
|---|
| 426 | |
|---|
| 427 | # Enter root, /proc and (potentially) /proc/bus/usb and devfs into mtab. |
|---|
| 428 | mount -f / |
|---|
| 429 | mount -f /proc >/dev/null 2>&1 |
|---|
| 430 | mount -f /sys >/dev/null 2>&1 |
|---|
| 431 | mount -f /dev/pts >/dev/null 2>&1 |
|---|
| 432 | mount -f /dev/shm >/dev/null 2>&1 |
|---|
| 433 | mount -f /proc/bus/usb >/dev/null 2>&1 |
|---|
| 434 | fi |
|---|
| 435 | |
|---|
| 436 | if strstr "$cmdline" hdparm ;then |
|---|
| 437 | update_boot_stage RChdparm |
|---|
| 438 | |
|---|
| 439 | # Turn on harddisk optimization |
|---|
| 440 | # There is only one file /etc/sysconfig/harddisks for all disks |
|---|
| 441 | # after installing the hdparm-RPM. If you need different hdparm parameters |
|---|
| 442 | # for each of your disks, copy /etc/sysconfig/harddisks to |
|---|
| 443 | # /etc/sysconfig/harddiskhda (hdb, hdc...) and modify it. |
|---|
| 444 | # each disk which has no special parameters will use the defaults. |
|---|
| 445 | |
|---|
| 446 | disk[0]=s; disk[1]=hda; disk[2]=hdb; disk[3]=hdc; |
|---|
| 447 | disk[4]=hdd; disk[5]=hde; disk[6]=hdf; disk[7]=hdg; disk[8]=hdh; |
|---|
| 448 | |
|---|
| 449 | |
|---|
| 450 | if [ -x /sbin/hdparm ]; then |
|---|
| 451 | for device in 0 1 2 3 4 5 6 7 8; do |
|---|
| 452 | unset MULTIPLE_IO USE_DMA EIDE_32BIT LOOKAHEAD EXTRA_PARAMS |
|---|
| 453 | if [ -f /etc/sysconfig/harddisk${disk[$device]} ]; then |
|---|
| 454 | . /etc/sysconfig/harddisk${disk[$device]} |
|---|
| 455 | HDFLAGS[$device]= |
|---|
| 456 | if [ -n "$MULTIPLE_IO" ]; then |
|---|
| 457 | HDFLAGS[$device]="-q -m$MULTIPLE_IO" |
|---|
| 458 | fi |
|---|
| 459 | if [ -n "$USE_DMA" ]; then |
|---|
| 460 | HDFLAGS[$device]="${HDFLAGS[$device]} -q -d$USE_DMA" |
|---|
| 461 | fi |
|---|
| 462 | if [ -n "$EIDE_32BIT" ]; then |
|---|
| 463 | HDFLAGS[$device]="${HDFLAGS[$device]} -q -c$EIDE_32BIT" |
|---|
| 464 | fi |
|---|
| 465 | if [ -n "$LOOKAHEAD" ]; then |
|---|
| 466 | HDFLAGS[$device]="${HDFLAGS[$device]} -q -A$LOOKAHEAD" |
|---|
| 467 | fi |
|---|
| 468 | if [ -n "$EXTRA_PARAMS" ]; then |
|---|
| 469 | HDFLAGS[$device]="${HDFLAGS[$device]} $EXTRA_PARAMS" |
|---|
| 470 | fi |
|---|
| 471 | else |
|---|
| 472 | HDFLAGS[$device]="${HDFLAGS[0]}" |
|---|
| 473 | fi |
|---|
| 474 | if [ -e "/proc/ide/${disk[$device]}/media" ] ; then |
|---|
| 475 | hdmedia=`cat /proc/ide/${disk[$device]}/media` |
|---|
| 476 | if [ "$hdmedia" = "disk" ]; then |
|---|
| 477 | if [ -n "${HDFLAGS[$device]}" ]; then |
|---|
| 478 | action $"Setting hard drive parameters for ${disk[$device]}: " /sbin/hdparm ${HDFLAGS[$device]} /dev/${disk[$device]} |
|---|
| 479 | fi |
|---|
| 480 | fi |
|---|
| 481 | fi |
|---|
| 482 | done |
|---|
| 483 | fi |
|---|
| 484 | fi |
|---|
| 485 | |
|---|
| 486 | # The root filesystem is now read-write, so we can now log via syslog() directly.. |
|---|
| 487 | if [ -n "$IN_INITLOG" ]; then |
|---|
| 488 | IN_INITLOG= |
|---|
| 489 | fi |
|---|
| 490 | |
|---|
| 491 | update_boot_stage RCfsck |
|---|
| 492 | |
|---|
| 493 | _RUN_QUOTACHECK=0 |
|---|
| 494 | # Check filesystems |
|---|
| 495 | if [ -z "$fastboot" ]; then |
|---|
| 496 | STRING=$"Checking filesystems" |
|---|
| 497 | echo $STRING |
|---|
| 498 | fsck -T -R -A -a $fsckoptions |
|---|
| 499 | rc=$? |
|---|
| 500 | if [ "$rc" = "0" ]; then |
|---|
| 501 | success "$STRING" |
|---|
| 502 | echo |
|---|
| 503 | elif [ "$rc" = "1" ]; then |
|---|
| 504 | passed "$STRING" |
|---|
| 505 | echo |
|---|
| 506 | fi |
|---|
| 507 | |
|---|
| 508 | # A return of 2 or higher means there were serious problems. |
|---|
| 509 | if [ $rc -gt 1 ]; then |
|---|
| 510 | failure "$STRING" |
|---|
| 511 | echo |
|---|
| 512 | echo |
|---|
| 513 | echo $"*** An error occurred during the file system check." |
|---|
| 514 | echo $"*** Dropping you to a shell; the system will reboot" |
|---|
| 515 | echo $"*** when you leave the shell." |
|---|
| 516 | |
|---|
| 517 | PS1=$"(Repair filesystem) \# # "; export PS1 |
|---|
| 518 | sulogin |
|---|
| 519 | |
|---|
| 520 | echo $"Unmounting file systems" |
|---|
| 521 | umount -a |
|---|
| 522 | mount -n -o remount,ro / |
|---|
| 523 | echo $"Automatic reboot in progress." |
|---|
| 524 | reboot -f |
|---|
| 525 | elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then |
|---|
| 526 | _RUN_QUOTACHECK=1 |
|---|
| 527 | fi |
|---|
| 528 | fi |
|---|
| 529 | |
|---|
| 530 | update_boot_stage RClocalfs |
|---|
| 531 | |
|---|
| 532 | # Mount all other filesystems (except for NFS and /proc, which is already |
|---|
| 533 | # mounted). Contrary to standard usage, |
|---|
| 534 | # filesystems are NOT unmounted in single user mode. |
|---|
| 535 | if [ "$READONLY" != "yes" ] ; then |
|---|
| 536 | action $"Mounting local filesystems: " mount -a -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev >/dev/null 2>&1 |
|---|
| 537 | else |
|---|
| 538 | action $"Mounting local filesystems: " mount -a -n -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev >/dev/null 2>&1 |
|---|
| 539 | fi |
|---|
| 540 | |
|---|
| 541 | # check remaining quotas other than root |
|---|
| 542 | if [ X"$_RUN_QUOTACHECK" = X1 -a -x /sbin/quotacheck ]; then |
|---|
| 543 | if [ -x /sbin/convertquota ]; then |
|---|
| 544 | # try to convert old quotas |
|---|
| 545 | for mountpt in `cat /etc/mtab | awk '$4 ~ /quota/{print $2}'`; do |
|---|
| 546 | if [ -f "$mountpt/quota.user" ]; then |
|---|
| 547 | action $"Converting old user quota files: " \ |
|---|
| 548 | /sbin/convertquota -u $mountpt && \ |
|---|
| 549 | rm -f $mountpt/quota.user |
|---|
| 550 | fi |
|---|
| 551 | if [ -f "$mountpt/quota.group" ]; then |
|---|
| 552 | action $"Converting old group quota files: " \ |
|---|
| 553 | /sbin/convertquota -g $mountpt && \ |
|---|
| 554 | rm -f $mountpt/quota.group |
|---|
| 555 | fi |
|---|
| 556 | done |
|---|
| 557 | fi |
|---|
| 558 | action $"Checking local filesystem quotas: " /sbin/quotacheck -aRnug |
|---|
| 559 | fi |
|---|
| 560 | |
|---|
| 561 | if [ -x /sbin/quotaon ]; then |
|---|
| 562 | action $"Enabling local filesystem quotas: " /sbin/quotaon -aug |
|---|
| 563 | fi |
|---|
| 564 | |
|---|
| 565 | # Configure machine if necessary. |
|---|
| 566 | if [ -f /.unconfigured ]; then |
|---|
| 567 | if [ -x /usr/bin/plymouth ]; then |
|---|
| 568 | /usr/bin/plymouth quit |
|---|
| 569 | fi |
|---|
| 570 | if [ -x /usr/bin/system-config-keyboard ]; then |
|---|
| 571 | /usr/bin/system-config-keyboard |
|---|
| 572 | fi |
|---|
| 573 | if [ -x /usr/bin/passwd ]; then |
|---|
| 574 | /usr/bin/passwd root |
|---|
| 575 | fi |
|---|
| 576 | if [ -x /usr/sbin/system-config-network-tui ]; then |
|---|
| 577 | /usr/sbin/system-config-network-tui |
|---|
| 578 | fi |
|---|
| 579 | if [ -x /usr/sbin/timeconfig ]; then |
|---|
| 580 | /usr/sbin/timeconfig |
|---|
| 581 | fi |
|---|
| 582 | if [ -x /usr/sbin/authconfig-tui ]; then |
|---|
| 583 | /usr/sbin/authconfig-tui --nostart |
|---|
| 584 | fi |
|---|
| 585 | if [ -x /usr/sbin/ntsysv ]; then |
|---|
| 586 | /usr/sbin/ntsysv --level 35 |
|---|
| 587 | fi |
|---|
| 588 | |
|---|
| 589 | # Reread in network configuration data. |
|---|
| 590 | if [ -f /etc/sysconfig/network ]; then |
|---|
| 591 | . /etc/sysconfig/network |
|---|
| 592 | |
|---|
| 593 | # Reset the hostname. |
|---|
| 594 | action $"Resetting hostname ${HOSTNAME}: " hostname ${HOSTNAME} |
|---|
| 595 | fi |
|---|
| 596 | |
|---|
| 597 | rm -f /.unconfigured |
|---|
| 598 | fi |
|---|
| 599 | |
|---|
| 600 | # Clean out /etc. |
|---|
| 601 | rm -f /fastboot /fsckoptions /forcefsck /.autofsck /halt /poweroff |
|---|
| 602 | |
|---|
| 603 | # Do we need (w|u)tmpx files? We don't set them up, but the sysadmin might... |
|---|
| 604 | _NEED_XFILES= |
|---|
| 605 | [ -f /var/run/utmpx -o -f /var/log/wtmpx ] && _NEED_XFILES=1 |
|---|
| 606 | |
|---|
| 607 | # Clean up /var |
|---|
| 608 | rm -rf /var/lock/cvs/* /var/run/screen/* |
|---|
| 609 | find /var/lock /var/run -type f -exec rm -f {} \; |
|---|
| 610 | |
|---|
| 611 | rm -f /var/lib/rpm/__db* &> /dev/null |
|---|
| 612 | rm -f /var/gdm/.gdmfifo &> /dev/null |
|---|
| 613 | |
|---|
| 614 | { |
|---|
| 615 | # Clean up utmp/wtmp |
|---|
| 616 | >/var/run/utmp |
|---|
| 617 | touch /var/log/wtmp /var/log/btmp |
|---|
| 618 | chgrp utmp /var/run/utmp /var/log/wtmp |
|---|
| 619 | chmod 0664 /var/run/utmp /var/log/wtmp |
|---|
| 620 | chmod 0600 /var/log/btmp |
|---|
| 621 | if [ -n "$_NEED_XFILES" ]; then |
|---|
| 622 | >/var/run/utmpx |
|---|
| 623 | touch /var/log/wtmpx |
|---|
| 624 | chgrp utmp /var/run/utmpx /var/log/wtmpx |
|---|
| 625 | chmod 0664 /var/run/utmpx /var/log/wtmpx |
|---|
| 626 | fi |
|---|
| 627 | |
|---|
| 628 | # Clean up various /tmp bits |
|---|
| 629 | rm -f /tmp/.X*-lock /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.* \ |
|---|
| 630 | /tmp/.esd/* |
|---|
| 631 | rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \ |
|---|
| 632 | /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \ |
|---|
| 633 | /tmp/scrollkeeper-* /tmp/ssh-* \ |
|---|
| 634 | /dev/.in_sysinit |
|---|
| 635 | # Make ICE directory |
|---|
| 636 | mkdir -m 1777 -p /tmp/.ICE-unix >/dev/null 2>&1 |
|---|
| 637 | chown root:root /tmp/.ICE-unix |
|---|
| 638 | |
|---|
| 639 | # Now turn on swap in case we swap to files. |
|---|
| 640 | update_boot_stage RCswap |
|---|
| 641 | action $"Enabling swap space: " swapon -a -e |
|---|
| 642 | |
|---|
| 643 | # Initialize the serial ports. |
|---|
| 644 | if [ -f /etc/rc.serial ]; then |
|---|
| 645 | . /etc/rc.serial |
|---|
| 646 | fi |
|---|
| 647 | |
|---|
| 648 | update_boot_stage RCusbstorage |
|---|
| 649 | |
|---|
| 650 | # Load usb storage here, to match most other things |
|---|
| 651 | if [ -n "$needusbstorage" ]; then |
|---|
| 652 | modprobe usb-storage >/dev/null 2>&1 |
|---|
| 653 | fi |
|---|
| 654 | |
|---|
| 655 | # Adjust symlinks as necessary in /boot to keep system services from |
|---|
| 656 | # spewing messages about mismatched System maps and so on. |
|---|
| 657 | if [ -L /boot/System.map -a -r /boot/System.map-`uname -r` ]; then |
|---|
| 658 | ln -s -f System.map-`uname -r` /boot/System.map |
|---|
| 659 | fi |
|---|
| 660 | if [ ! -e /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then |
|---|
| 661 | ln -s -f System.map-`uname -r` /boot/System.map |
|---|
| 662 | fi |
|---|
| 663 | |
|---|
| 664 | # Now that we have all of our basic modules loaded and the kernel going, |
|---|
| 665 | # let's dump the syslog ring somewhere so we can find it later |
|---|
| 666 | dmesg -s 131072 > /var/log/dmesg |
|---|
| 667 | # Also keep kernel symbols around in case we need them for debugging |
|---|
| 668 | i=5 |
|---|
| 669 | while [ $i -ge 0 ] ; do |
|---|
| 670 | if [ -f /var/log/ksyms.$i ] ; then |
|---|
| 671 | mv /var/log/ksyms.$i /var/log/ksyms.$(($i+1)) |
|---|
| 672 | fi |
|---|
| 673 | i=$(($i-1)) |
|---|
| 674 | done |
|---|
| 675 | _ksyms=/proc/kallsyms |
|---|
| 676 | (/bin/date; |
|---|
| 677 | /bin/uname -a; |
|---|
| 678 | /bin/cat /proc/cpuinfo; |
|---|
| 679 | /bin/cat /proc/modules; |
|---|
| 680 | /bin/cat ${_ksyms}) >/var/log/ksyms.0 |
|---|
| 681 | # create the crash indicator flag to warn on crashes, offer fsck with timeout |
|---|
| 682 | touch /.autofsck |
|---|
| 683 | kill -TERM `/sbin/pidof getkey` >/dev/null 2>&1 |
|---|
| 684 | } & |
|---|
| 685 | if [ "$PROMPT" != "no" ]; then |
|---|
| 686 | /sbin/getkey i && touch /var/run/confirm |
|---|
| 687 | fi |
|---|
| 688 | wait |
|---|
| 689 | |
|---|
| 690 | # let plymouth know that we're leaving rc.sysinit |
|---|
| 691 | if [ -x /usr/bin/plymouth ]; then |
|---|
| 692 | /usr/bin/plymouth --sysinit |
|---|
| 693 | fi |
|---|
| 694 | |
|---|