diff options
Diffstat (limited to 'rc.d')
-rwxr-xr-x | rc.d/init.d/functions | 120 | ||||
-rwxr-xr-x | rc.d/init.d/halt | 4 | ||||
-rwxr-xr-x | rc.d/init.d/network | 12 | ||||
-rwxr-xr-x | rc.d/rc | 26 | ||||
-rwxr-xr-x | rc.d/rc.sysinit | 96 |
5 files changed, 190 insertions, 68 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions index a651d699..e69f27f4 100755 --- a/rc.d/init.d/functions +++ b/rc.d/init.d/functions @@ -1,4 +1,5 @@ -#! /bin/sh + +#!/bin/sh # # functions This file contains functions to be used by most or all # shell scripts in the /etc/init.d directory. @@ -12,6 +13,15 @@ # First set up a default search path. export PATH="/sbin:/usr/sbin:/bin:/usr/bin" +# Read in our configuration +if [ -f /etc/sysconfig/init ]; then + . /etc/sysconfig/init +else + BOOTUP=color +fi + + + # A function to start a program. daemon() { # Test syntax. @@ -30,15 +40,17 @@ daemon() { pid=`pidofproc $base` [ -n "$pid" ] && ps h $pid >/dev/null 2>&1 && return - # echo basename of the program. - echo -n "$base " - # make sure it doesn't core dump anywhere; while this could mask # problems with the daemon, it also closes some security problems ulimit -c 0 + + # + if [ $BOOTUP != "color" ]; then + echo -n $base + fi # And start it up. - nice -n $nicelevel "$@" + nice -n $nicelevel initlog -q -c "$*" && success -n "$base startup" || failure -n "$base startup" } # A function to stop a program. @@ -150,3 +162,101 @@ status() { echo "$1 is stopped" return 3 } + +echo_success() { + echo $* "[300C[10D[ [1;32mOK[0;39m ]" + return 0 +} + +echo_failure() { + echo $* "[300C[10D[[1;31mFAILED[0;39m]" + return 0 +} + +success() { + if [ "$1" = "-n" ]; then + ECHOARGS="-n" + shift + else + ECHOARGS="" + fi + if [ -z "$IN_INITLOG" ]; then + initlog -n $0 -s "$1" -e 1 + else + echo "-n $0 -s \"$1\" -e 1" >&21 + fi + [ "$BOOTUP" = "color" ] && echo_success $ECHOARGS + return 0 +} + +failure() { + if [ "$1" = "-n" ]; then + ECHOARGS="-n" + shift + else + ECHOARGS="" + fi + if [ -z "$IN_INITLOG" ]; then + initlog -n $0 -s "$1" -e 2 + else + echo "-n $0 -s \"$1\" -e 2" >&21 + fi + [ "$BOOTUP" = "color" ] && echo_failure $ECHOARGS + return 0 +} + +action() { + if [ "$1" = "-n" ]; then + ECHOARGS="-n" + shift + else + ECHOARGS="" + fi + STRING=$1 + echo $ECHOARGS "$STRING " + shift + if [ -z "$IN_INITLOG" ]; then + initlog -q -c "$*" && success "$STRING" || failure "$STRING" + else + # This sucks. + output=`$*` + rc=$? + if [ -n "$output" ]; then + cmdname=`basename $1` + initlogcmds=`echo $output | sed -e "s/^/ -n $cmdname -s \"/" | sed -e "s/$/\"/"` + echo "$initlogcmds" >&21 + fi + + if [ $rc ]; then + success "$STRING" + else + echo $output + failure "$STRING" + fi + fi + return 0 +} + +# Confirm whether we really want to run this service +confirm() { + echo -n "Start service $1 (Y)es/(N)o/(C)ontinue? [Y] " + read answer + case $answer in + y|Y|"") + return 0 + ;; + c|C) + return 2 + ;; + n|N) + return 1 + ;; + *) + confirm $1 + return $? + ;; + esac +} + + + diff --git a/rc.d/init.d/halt b/rc.d/init.d/halt index 5134770b..552f8f16 100755 --- a/rc.d/init.d/halt +++ b/rc.d/init.d/halt @@ -15,7 +15,7 @@ PATH=/sbin:/bin:/usr/bin:/usr/sbin case "$0" in *halt) message="The system is halted" - command="halt" + command="halt -p" ;; *reboot) message="Please stand by while rebooting the system..." @@ -44,7 +44,7 @@ echo "Turning off swap and accounting" swapoff -a [ -x /sbin/accton ] && /sbin/accton echo "Unmounting file systems" -umount -a +umount -a -f mount -n -o remount,ro / # turn off raid diff --git a/rc.d/init.d/network b/rc.d/init.d/network index 425d6c38..f21de187 100755 --- a/rc.d/init.d/network +++ b/rc.d/init.d/network @@ -57,8 +57,7 @@ ipv4_forward_set () fi if [ $value != `cat /proc/sys/net/ipv4/ip_forward` ]; then - echo $message - echo "$value" > /proc/sys/net/ipv4/ip_forward + action -n "$message" echo "$value" > /proc/sys/net/ipv4/ip_forward fi fi fi @@ -70,7 +69,7 @@ case "$1" in start) ipv4_forward_set - ./ifup ifcfg-lo + action "Bringing up interface lo" ./ifup ifcfg-lo case "$IPX" in yes|true) @@ -81,14 +80,14 @@ case "$1" in esac for i in $interfaces; do - ./ifup $i boot + action "Bringing up interface $i" ./ifup $i boot done touch /var/lock/subsys/network ;; stop) for i in $interfaces; do - ./ifdown $i boot + action "Shutting down interface $i" ./ifdown $i boot done case "$IPX" in yes|true) @@ -96,8 +95,7 @@ case "$1" in ;; esac ./ifdown ifcfg-lo - echo "Disabling IPv4 packet forwarding." - echo 0 > /proc/sys/net/ipv4/ip_forward + action -n "Disabling IPv4 packet forwarding." echo 0 > /proc/sys/net/ipv4/ip_forward rm -f /var/lock/subsys/network ;; status) @@ -19,6 +19,15 @@ runlevel=$2 previous=$1 export runlevel previous +# See if we want to be in user confirmation mode +if [ "$previous" = "N" ]; then + if grep -i confirm /proc/cmdline >/dev/null ; then + CONFIRM=yes + else + CONFIRM= + fi +fi + # Get first argument. Set new runlevel to this argument. [ "$1" != "" ] && runlevel="$argv1" @@ -58,6 +67,23 @@ if [ -d /etc/rc.d/rc$runlevel.d ]; then subsys=${i#/etc/rc.d/rc$runlevel.d/S??} [ -f /var/lock/subsys/$subsys ] || \ [ -f /var/lock/subsys/${subsys}.init ] && continue + + # If we're in confirmation mode, get user confirmation + [ -n "$CONFIRM" ] && + { + confirm $subsys + case $? in + 0) + : + ;; + 2) + CONFIRM= + ;; + *) + continue + ;; + esac + } # Bring the subsystem up. $i start diff --git a/rc.d/rc.sysinit b/rc.d/rc.sysinit index acd2b5fa..0b84f72f 100755 --- a/rc.d/rc.sysinit +++ b/rc.d/rc.sysinit @@ -1,10 +1,15 @@ -#! /bin/sh +#!/bin/sh # # /etc/rc.d/rc.sysinit - run once at boot time # # Taken in part from Miquel van Smoorenburg's bcheckrc. # +# Rerun ourselves through initlog +if [ -z "$IN_INITLOG" ]; then + [ -f /sbin/initlog ] && exec /sbin/initlog -r /etc/rc.d/rc.sysinit +fi + # Set the path PATH=/bin:/sbin:/usr/bin:/usr/sbin export PATH @@ -17,17 +22,18 @@ else HOSTNAME=localhost fi +# Source functions +. /etc/rc.d/init.d/functions + # Start up swapping. -echo "Activating swap partitions" -swapon -a +action -n "Activating swap partitions" swapon -a # Set the hostname. -hostname ${HOSTNAME} -echo hostname: `hostname` +action -n "Setting hostname ${HOSTNAME}" hostname ${HOSTNAME} # Set the NIS domain name if [ -n "$NISDOMAIN" ]; then - domainname $NISDOMAIN + action -n "Setting NIS domain name $NISDOMAIN" domainname $NISDOMAIN else domainname "" fi @@ -39,12 +45,10 @@ if [ -f /fsckoptions ]; then fi if [ ! -f /fastboot ]; then - echo "Checking root filesystems." - fsck -V -a $fsckoptions / - + action -n "Checking root filesystem" fsck -T -a $fsckoptions / rc=$? - - # A return of 2 or higher means there were serious problems. + + # A return of 2 or higher means there were serious problems. if [ $rc -gt 1 ]; then echo echo @@ -60,17 +64,19 @@ if [ ! -f /fastboot ]; then mount -n -o remount,ro / echo "Automatic reboot in progress." reboot + elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then + action -n "Checking root filesystem quotas" /sbin/quotacheck -v / fi fi if [ -x /sbin/quotaon ]; then - echo "Turning on user and group quotas for root filesystem" - /sbin/quotaon / + action -n "Turning on user and group quotas for root filesystem" /sbin/quotaon / fi # check for arguments mount -t proc /proc /proc + if grep -i nopnp /proc/cmdline >/dev/null ; then PNP= else @@ -80,23 +86,20 @@ fi # set up pnp if [ -x /sbin/isapnp -a -f /etc/isapnp.conf ]; then if [ -n "$PNP" ]; then - echo "Setting up ISA PNP devices" - /sbin/isapnp /etc/isapnp.conf + action -n "Setting up ISA PNP devices" /sbin/isapnp /etc/isapnp.conf else - echo "Skipping ISA PNP configuration at users request" + action -n "Skipping ISA PNP configuration at users request" /bin/true fi fi # Remount the root filesystem read-write. -echo "Remounting root filesystem in read-write mode." -mount -n -o remount,rw / +action -n "Remounting root filesystem in read-write mode" mount -n -o remount,rw / -# Check quotas if fsck fixed something. -if [ "$rc" = "1" -a -x /sbin/quotacheck ]; then - echo "Checking root filesystem quotas" - /sbin/quotacheck -v / +if [ -n "$IN_INITLOG" ]; then + IN_INITLOG= fi + if [ ! -f /etc/HOSTNAME ]; then echo ${HOSTNAME} > /etc/HOSTNAME fi @@ -129,22 +132,20 @@ fi if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then # Get ready for kerneld if module support in the kernel - echo -n "Finding module dependencies... " if [ -e /lib/modules/preferred ]; then - depmod -a preferred + action -n "Finding module dependencies" depmod -a preferred else - depmod -a + action -n "Finding module dependencies" depmod -a fi - echo "done" fi # load sound modules if ! grep -i nomodules /proc/cmdline >/dev/null ; then if [ -n "$USEMODULES" ]; then if grep -s "alias sound" /etc/conf.modules > /dev/null ; then - modprobe sound + action -n "Loading sound module" modprobe sound if grep -s "alias midi" /etc/conf.modules > /dev/null ; then - modprobe midi + action -n "Loading midi module" modprobe midi fi fi fi @@ -162,8 +163,7 @@ fi # Add raid devices if [ -f /proc/mdstat -a -f /etc/raidtab -a -x /sbin/raidadd ]; then - echo "Starting up RAID devices." - raidadd -a + action -n "Starting up RAID devices" raidadd -a rc=$? @@ -193,8 +193,7 @@ fi # Check filesystems if [ ! -f /fastboot ]; then - echo "Checking filesystems." - fsck -R -A -V -a $fsckoptions + action -n "Checking filesystems" fsck -T -R -A -a $fsckoptions rc=$? @@ -214,29 +213,23 @@ if [ ! -f /fastboot ]; then mount -n -o remount,ro / echo "Automatic reboot in progress." reboot + elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then + action -n "Checking filesystem quotas" /sbin/quotacheck -v -R -a fi fi # Mount all other filesystems (except for NFS and /proc, which is already # mounted). Contrary to standard usage, # filesystems are NOT unmounted in single user mode. -echo "Mounting local filesystems." -mount -a -t nonfs,proc +action -n "Mounting local filesystems" mount -a -t nonfs,proc # set the console font if [ -x /sbin/setsysfont ]; then /sbin/setsysfont fi -# Check quotas if fsck fixed something. -if [ "$rc" = "1" -a -x /sbin/quotacheck ]; then - echo "Checking filesystem quotas" - /sbin/quotacheck -v -R -a -fi - if [ -x /sbin/quotaon ]; then - echo "Turning on user and group quotas for local filesystems" - /sbin/quotaon -a + action -n "Turning on user and group quotas for local filesystems" /sbin/quotaon -a fi # Clean out /etc. @@ -263,8 +256,6 @@ rm -f /tmp/.X*-lock rm -f /tmp/.s.PGSQL.* # Set the system clock. -echo -n "Setting clock" - ARC=0 UTC=0 if [ -f /etc/sysconfig/clock ]; then @@ -278,6 +269,7 @@ if [ -f /etc/sysconfig/clock ]; then fi fi +CLOCKDEF="" if [ -x /sbin/hwclock ]; then CLOCKFLAGS="--hctosys" CLOCK=/sbin/hwclock @@ -289,25 +281,22 @@ fi case "$UTC" in yes|true) CLOCKFLAGS="$CLOCKFLAGS -u"; - echo -n " (utc)" + CLOCKDEF="$CLOCKDEF (utc)"; ;; esac case "$ARC" in yes|true) CLOCKFLAGS="$CLOCKFLAGS -A"; - echo -n " (arc)" + CLOCKDEF="$CLOCKDEF (arc)"; ;; esac -echo -n ": " $CLOCK $CLOCKFLAGS - -date +action -n "Setting clock $CLOCKDEF: `date`" date # Right, now turn on swap in case we swap to files. -echo "Enabling swap space." -swapon -a 2>&1 | grep -v "busy" +action -n "Enabling swap space" swapon -a 2>&1 | grep -v "busy" # Initialize the serial ports. if [ -f /etc/rc.d/rc.serial ]; then @@ -335,7 +324,6 @@ fi dmesg > /var/log/dmesg # Feed entropy into the entropy pool -# XXX Random is also started as S20random but randomization may be needed -# XXX for packet sequence numbers during network initialization so we'll -# XXX add entropy here too. /etc/rc.d/init.d/random start + +sleep 10 |