# functions This file contains functions to be used by most or all
# shell scripts in the /etc/init.d directory.
#
-# Version: @(#) /etc/init.d/functions $Revision: 1.8 $ $Date: 1999/06/18 19:23:51 $
+# Version: @(#) /etc/init.d/functions $Revision: 1.9 $ $Date: 1999/06/19 11:29:04 $
#
# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
# Hacked by: Greg Galloway and Marc Ewing
# Some functions to handle PLD-style messages
show()
{
- text="$*".............................................
- echo -ne `echo $text | cut -c1-45`
+ text="$*".............................................
+ echo -ne `echo $text | cut -c1-45`
}
busy()
{
- echo -n "`tput setaf 6`[`tput setaf 5` BUSY `tput setaf 6`]`tput setaf 7`"
+ echo -n "`tput setaf 6`[`tput setaf 5` BUSY `tput setaf 6`]`tput setaf 7`"
}
ok()
{
- echo "`tput setaf 6`[`tput setaf 2` DONE `tput setaf 6`]`tput setaf 7`"
+ echo "`tput setaf 6`[`tput setaf 2` DONE `tput setaf 6`]`tput setaf 7`"
}
started()
{
- echo "`tput setaf 6`[`tput setaf 2` WORK `tput setaf 6`]`tput setaf 7`"
+ echo "`tput setaf 6`[`tput setaf 2` WORK `tput setaf 6`]`tput setaf 7`"
}
fail()
{
- echo "`tput setaf 6`[`tput setaf 1` FAIL `tput setaf 6`]`tput setaf 7`"
+ echo "`tput setaf 6`[`tput setaf 1` FAIL `tput setaf 6`]`tput setaf 7`"
}
died()
{
- echo "`tput setaf 6`[`tput setaf 1` DIED `tput setaf 6`]`tput setaf 7`"
+ echo "`tput setaf 6`[`tput setaf 1` DIED `tput setaf 6`]`tput setaf 7`"
}
deltext()
{
- echo -ne '\b\b\b\b\b\b\b\b'
+ echo -ne '\b\b\b\b\b\b\b\b'
}
# Usage run_cmd Message command_to_run
run_cmd()
{
-_ERRORS=""
-MESSAGE=$1
-show "$MESSAGE"; busy
-shift
-if _ERRORS="`initlog -c \"$*\"`"; then
-deltext; ok
-else
-deltext; fail; echo $_ERRORS
-fi
-exit_code=$?
-unset _ERRORS
-return $exit_code
+ _ERRORS=""
+ MESSAGE=$1
+ show "$MESSAGE"; busy
+ shift
+ if _ERRORS="`initlog -c \"$*\"`"; then
+ deltext; ok
+ else
+ deltext; fail; echo $_ERRORS
+ fi
+ exit_code=$?
+ unset _ERRORS
+ return $exit_code
}
# A function to start a program (now it's usefull on read-only filesystem too)
[ -z "$DEFAULT_SERVICE_RUN_NICE_LEVEL" ] && DEFAULT_SERVICE_RUN_NICE_LEVEL=0
# Test syntax.
case $1 in
- '') echo '$0: Usage: daemon [+/-nicelevel] {program}'
- return 1;;
- -*|+*) SERVICE_RUN_NICE_LEVEL=$1
- shift;;
+ '') echo '$0: Usage: daemon [+/-nicelevel] {program}'
+ return 1;;
+ -*|+*) SERVICE_RUN_NICE_LEVEL=$1
+ shift;;
esac
# make sure it doesn't core dump anywhere; while this could mask
# And start it up.
busy
if _ERRORS="`nice -n ${SERVICE_RUN_NICE_LEVEL:-$DEFAULT_SERVICE_RUN_NICE_LEVEL} initlog -c "$*" 2>&1`"; then
- deltext
- ok
+ deltext
+ ok
else
- deltext
- fail
- echo $_ERRORS
+ deltext
+ fail
+ echo $_ERRORS
fi
- unset _ERRORS
+ unset _ERRORS
}
# A function to stop a program.
kill $killlevel $pid >$TMPFILE 2>&1
fi
else
- rm -f /var/run/$base.pid
- deltext
- fail
- return
+ rm -f /var/run/$base.pid
+ deltext
+ fail
+ return
fi
# Remove pid file if any.
# Read network config data.
if [ -f /etc/sysconfig/network ]; then
- . /etc/sysconfig/network
+ . /etc/sysconfig/network
else
- NETWORKING=no
- HOSTNAME=localhost
+ NETWORKING=no
+ HOSTNAME=localhost
fi
# Read system config data.
if [ -f /etc/sysconfig/system ]; then
- . /etc/sysconfig/system
+ . /etc/sysconfig/system
else
- RUN_SULOGIN_ON_ERR=yes
- RUN_ISAPNP=yes
- PANIC_REBOOT_TIME=0
- DELAY_LOGIN=yes
- CLEAN_TMP=no
- CONSOLE_LOGLEVEL=1
- LOAD_SOUND=yes
+ RUN_SULOGIN_ON_ERR=yes
+ RUN_ISAPNP=yes
+ PANIC_REBOOT_TIME=0
+ DELAY_LOGIN=yes
+ CLEAN_TMP=no
+ CONSOLE_LOGLEVEL=1
+ LOAD_SOUND=yes
fi
# Set console loglevel
# Set the NIS domain name
if [ -n "$NISDOMAIN" ]; then
-run_cmd "NIS Domain: ${NISDOMAIN}" domainname $NISDOMAIN
+ run_cmd "NIS Domain: ${NISDOMAIN}" domainname $NISDOMAIN
else
- domainname ""
+ domainname ""
fi
if [ -f /fsckoptions ]; then
fsckoptions=`cat /fsckoptions`
- else
+else
fsckoptions=''
fi
fi
if [ -x /sbin/quotaon ]; then
- run_cmd "Turning on quotas on root filesystem" /sbin/quotaon /
+ run_cmd "Turning on quotas on root filesystem" /sbin/quotaon /
fi
# check for arguments
mount -t proc /proc /proc
if grep -i nopnp /proc/cmdline >/dev/null ; then
- PNP=
+ PNP=
else
- PNP=yes
+ PNP=yes
fi
# set up pnp
if [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
- if [ -n "$PNP" ] && [ "$RUN_ISAPNP" == "yes" ]; then
- run_cmd "Setting up ISA PNP devices"/sbin/isapnp /etc/isapnp/isapnp.conf
- else
- show "Skipping ISA PNP configuration"; ok
- fi
+ if [ -n "$PNP" ] && [ "$RUN_ISAPNP" == "yes" ]; then
+ run_cmd "Setting up ISA PNP devices"/sbin/isapnp /etc/isapnp/isapnp.conf
+ else
+ show "Skipping ISA PNP configuration"; ok
+ fi
fi
# Remount the root filesystem read-write.
# /etc/nologin when starting system
if [ "$DELAY_LOGIN" == "yes" ] && [ ! -f /etc/nologin ]; then
- show "Enabling Delay Login"; busy
- echo > /etc/nologin
- echo "[EN] System bootup in progress - please wait" >> /etc/nologin
- echo "[PL] Startowanie systemu w toku - proszê czekaæ" >> /etc/nologin
- echo >> /etc/nologin
- chmod 644 /etc/nologin
- cp -fp /etc/nologin /etc/nologin.boot
- deltext; ok
+ show "Enabling Delay Login"; busy
+ echo > /etc/nologin
+ echo "[EN] System bootup in progress - please wait" >> /etc/nologin
+ echo "[PL] Startowanie systemu w toku - proszê czekaæ" >> /etc/nologin
+ echo >> /etc/nologin
+ chmod 644 /etc/nologin
+ cp -fp /etc/nologin /etc/nologin.boot
+ deltext; ok
fi
mount -f /proc
if ! grep -i nomodules /proc/cmdline >/dev/null && [ -f /proc/ksyms ]; then
- USEMODULES=y
+ USEMODULES=y
else
- USEMODULES=
+ USEMODULES=
fi
# Set up kernel version-dependent symlinks.
rm -f /lib/modules/preferred
if [ -n "$USEMODULES" ]; then
- ktag="`cat /proc/version`"
- mtag="`grep -l "$ktag" /lib/modules/*/.rhkmvtag 2> /dev/null`"
- if [ -n "$mtag" ]; then
- mver="`echo $mtag | sed -e 's,/lib/modules/,,' -e 's,/.rhkmvtag,,' -e 's,[ ].*$,,'`"
- ln -sf /lib/modules/$mver /lib/modules/preferred
- ln -sf /boot/System.map-$mver /boot/System.map
- ln -sf /boot/module-info-$mver /boot/module-info
- fi
+ ktag="`cat /proc/version`"
+ mtag="`grep -l "$ktag" /lib/modules/*/.rhkmvtag 2> /dev/null`"
+ if [ -n "$mtag" ]; then
+ mver="`echo $mtag | sed -e 's,/lib/modules/,,' -e 's,/.rhkmvtag,,' -e 's,[ ].*$,,'`"
+ ln -sf /lib/modules/$mver /lib/modules/preferred
+ ln -sf /boot/System.map-$mver /boot/System.map
+ ln -sf /boot/module-info-$mver /boot/module-info
+ fi
fi
if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then
- # Get ready for kerneld if module support in the kernel
- if [ -e /lib/modules/preferred ]; then
- run_cmd "Finding module dependencies" depmod -a preferred
- else
- run_cmd "Finding module dependencies" depmod -a
- fi
+ # Get ready for kerneld if module support in the kernel
+ if [ -e /lib/modules/preferred ]; then
+ run_cmd "Finding module dependencies" depmod -a preferred
+ else
+ run_cmd "Finding module dependencies" depmod -a
+ fi
fi
# load sound modules
if (! grep -i nomodules /proc/cmdline >/dev/null) && [ "$LOAD_SOUND" == "yes" ]; then
- if [ -n "$USEMODULES" ]; then
- if grep -s "alias sound" /etc/modules.conf > /dev/null ; then
- run_cmd "Loading sound module" modprobe sound
- if grep -s "alias midi" /etc/conf.modules > /dev/null ; then
- run_cmd "Loading midi module" modprobe midi
- fi
+ if [ -n "$USEMODULES" ]; then
+ if grep -s "alias sound" /etc/modules.conf > /dev/null ; then
+ run_cmd "Loading sound module" modprobe sound
+ if grep -s "alias midi" /etc/conf.modules > /dev/null ; then
+ run_cmd "Loading midi module" modprobe midi
+ fi
+ fi
fi
- fi
fi
if [ -f /proc/sys/kernel/modprobe ]; then
# set the console font
if [ -x /sbin/setsysfont ]; then
- show "Loading default system font"; busy
- if (/sbin/setsysfont > /dev/null 2>&1); then deltext; ok; else deltext; fail; fi
+ show "Loading default system font"; busy
+ if (/sbin/setsysfont > /dev/null 2>&1); then deltext; ok; else deltext; fail; fi
fi
if [ -x /sbin/quotaon ]; then
- run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -a
+ run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -a
fi
# Clean out /etc & /var/{run/*,log/{b,w}tmpx}}.
chown root.utmpx /var/run/utmpx
chmod 0664 /var/run/utmpx /var/log/wtmpx
-# Uncomment if you planing to run `utmpd'
-#:>/var/log/wtmp
-#:>/var/run/utmp
-
# Clean /tmp
if [ "$CLEAN_TMP" == "yes" ]; then
-rm -rf /tmp/*
+ rm -rf /tmp/*
fi
# Delete UUCP lock files.
ARC=0
UTC=0
if [ -f /etc/sysconfig/clock ]; then
- . /etc/sysconfig/clock
+ . /etc/sysconfig/clock
- # convert old style clock config to new values
- if [ "${CLOCKMODE}" = "GMT" ]; then
- UTC=true
- elif [ "${CLOCKMODE}" = "ARC" ]; then
+ # convert old style clock config to new values
+ if [ "${CLOCKMODE}" = "GMT" ]; then
+ UTC=true
+ elif [ "${CLOCKMODE}" = "ARC" ]; then
ARC=true
- fi
+ fi
fi
if [ -x /sbin/hwclock ]; then
- CLOCKFLAGS="--hctosys"
- CLOCK=/sbin/hwclock
+ CLOCKFLAGS="--hctosys"
+ CLOCK=/sbin/hwclock
else
- CLOCKFLAGS="-a"
- CLOCK=/sbin/clock
+ CLOCKFLAGS="-a"
+ CLOCK=/sbin/clock
fi
case "$UTC" in
yes|true)
- CLOCKFLAGS="$CLOCKFLAGS -u";
-# echo -n " (utc)"
- ;;
+ CLOCKFLAGS="$CLOCKFLAGS -u";
+# echo -n " (utc)"
+ ;;
esac
case "$ARC" in
yes|true)
- CLOCKFLAGS="$CLOCKFLAGS -A";
-# echo -n " (arc)"
- ;;
+ CLOCKFLAGS="$CLOCKFLAGS -A";
+# echo -n " (arc)"
+ ;;
esac
#echo -n ": "
# Right, now turn on swap in case we swap to files.
show "Enabling swap space"; busy
if [ "`LANG=C swapon -a 2>&1 | grep -v "busy"`" == "" ]; then
-deltext; ok; else deltext; fail; fi
+ deltext; ok
+else
+ deltext; fail
+fi
# Initialize the serial ports.
if [ -f /etc/rc.d/rc.serial ]; then
if [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi | grep -q 'Type: Sequential-Access' 2>/dev/null ; then
if cat /proc/devices | grep -qv ' 9 st' ; then
if [ -n "$USEMODULES" ] ; then
- # Try to load the module. If it fails, ignore it...
- insmod -p st >/dev/null 2>&1 && modprobe st >/dev/null 2>&1
+ # Try to load the module. If it fails, ignore it...
+ insmod -p st >/dev/null 2>&1 && modprobe st >/dev/null 2>&1
fi
fi
fi
# Feed entropy into the entropy pool
/etc/rc.d/init.d/random start
-