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