#!/bin/sh # # hdw - linux /etc/init.d/boot (copied from ROCK Linux + modifications) # # lowlevel bootup script # exec 2>&1 export PATH=/bin:/sbin:/usr/bin:/usr/sbin echo "** booting hdw-linux... **" . /etc/conf/bootdown [ -f /fastboot ] && FASTBOOT=1 ; [ -f /forcefsck ] && FORCEFSCK=1 if [ $FORCEFSCK = 1 ] ; then echo "going to force fsck" ; FASTBOOT=0 ; fi [ $FASTBOOT = 1 ] && echo "fast boot mode enabled" mount -v -n /dev mount -v -n /proc ; mount -v -n /sys mkdir -p /dev/shm ; mount -v -n /dev/shm mkdir -p /dev/pts ; mount -v -n /dev/pts echo "loading kernel modules and configuring the kernel ..." . /etc/conf/kernel echo "populating device nodes ..." /etc/init.d/udev start if [ -f /etc/conf/devfs ] ; then echo "configuring device nodes ..." . /etc/conf/devfs fi echo "activating swap-devices ..." swapon -a if [ $FASTBOOT != 1 ] then echo "checking file systems (1/3) ..." mount -n -o remount,ro / if [ $FORCEFSCK = 1 ] then fsck -A -C -a -f ; fsckrc=$? ; sync ; sleep 3 else fsck -A -C -a ; fsckrc=$? ; sync ; sleep 3 fi x=2 [ $fsckrc -eq 1 -a $EASYFSCK = 1 ] && fsckrc=0 while [ $fsckrc -eq 1 -a $x -lt 4 ] do echo "filesystem check modified disks!" echo "checking file systems ($x/3) ..." fsck -A -C -a -f ; fsckrc=$? ; sync ; sleep 3 if [ $x -eq 3 ] ; then x=4 ; else x=3 ; fi done if [ $fsckrc -eq 0 ] then echo "all checked filesystems are clear." if [ $x != 2 ] ; then echo " **" echo " ** filesystem check modified disks." echo " **" echo " ** going to reboot the system." echo " **" for x in 10 9 8 7 6 5 4 3 2 ; do echo -en "\rsystem reboot in $x seconds ... " sleep 1 done ; echo -e "\rsystem reboot now! " /sbin/reboot -d -f exit fi else echo " **" echo " ** filesystem check failed (returncode=$fsckrc)." echo " ** please repair the broken disk(s) manually." echo " **" echo " ** note: The kernel parameter '-b' can be used to boot" echo " ** directly into a single-user login shell." echo " **" echo " ** going to reboot the system." echo " **" for x in 10 9 8 7 6 5 4 3 2 ; do echo -en "\rsystem reboot in $x seconds ... " sleep 1 done ; echo -e "\rsystem reboot now! " /sbin/reboot -d -f exit fi fi mount -v -n -o remount,rw / grep -E -v '^none (/|[a-z]+:) ' /proc/mounts > /etc/mtab mount -v -a -t nocoda,nfs if type hostname > /dev/null 2>&1 then echo "set the hostname to [`cat /etc/HOSTNAME`] ..." hostname `cat /etc/HOSTNAME` else echo "hostname not set: no 'hostname' command found" fi echo "refresh utmp, delete lock files and other stuff ..." rm -f /var/lock/* /var/lock/*/* /var/run/* 2> /dev/null touch /var/run/utmp ; chmod 664 /var/run/utmp ; chown root.tty /var/run/utmp rm -f /etc/nologin /nologin /fastboot /forcefsck /fastdown if [ "$TEMPCLEAN" = 1 ] ; then echo "cleaning up /tmp ..." for x in /tmp/* /tmp/.[!.]* ; do if [ -O "$x" ] ; then [ "$x" != "/tmp/lost+found" ] && [ "$x" != "/tmp/quota.user" ] && [ "$x" != "/tmp/quota.group" ] && rm -rf -- "$x" else rm -rf -- "$x" fi done fi if type klogd > /dev/null 2>&1 then echo "writing /var/log/boot.msg ..." klogd -f /var/log/boot.new -o grep '.' < /var/log/boot.new > /var/log/boot.msg rm /var/log/boot.new else echo "kernel boot messages are not logged: no 'klogd' command found." fi if type loadkeys > /dev/null 2>&1 then echo "set the keyboard keymappings ..." if [ -L /etc/default.keymap ] ; then oldpwd="`pwd`" ; cd /etc loadkeys `ls -l default.keymap | tr -s ' ' | cut -f11 -d' '` cd "$oldpwd" ; unset oldpwd elif [ -f /etc/default.keymap ] ; then loadkeys /etc/default.keymap else echo "no /etc/default.keymap found." fi else echo "keymappings not configured: no 'loadkeys' command found." fi if type ifconfig > /dev/null 2>&1 then echo "setting up loopback networking ..." ifconfig lo 127.0.0.1 netmask 255.0.0.0 up route add -net 127.0.0.0 netmask 255.0.0.0 dev lo fi echo 'setting overflow UID and GID kernel parameters ...' sysctl -w kernel.overflowuid=`id -u nobody` | tr -d '\n' echo -n ', ' ; sysctl -w kernel.overflowgid=`id -g nobody` echo "initializing kernel random number generator ..." [ -f /var/state/random-seed ] && cat /var/state/random-seed >/dev/urandom dd if=/dev/urandom of=/var/state/random-seed count=1 2> /dev/null # write EOT mark for btee echo -ne '\004'