aboutsummaryrefslogtreecommitdiffstats
path: root/rc.d/init.d
diff options
context:
space:
mode:
Diffstat (limited to 'rc.d/init.d')
-rwxr-xr-xrc.d/init.d/functions120
-rwxr-xr-xrc.d/init.d/halt4
-rwxr-xr-xrc.d/init.d/network12
3 files changed, 122 insertions, 14 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 $* "[ OK ]"
+ return 0
+}
+
+echo_failure() {
+ echo $* "[FAILED]"
+ 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)