2005-04-25 15:50:26 +02:00
|
|
|
# /usr/etc/rc - continued system initialization.
|
|
|
|
|
2005-08-02 17:46:24 +02:00
|
|
|
RANDOM_FILE=/usr/adm/random.dat
|
2005-08-05 12:37:02 +02:00
|
|
|
LOCAL_FILE=/usr/etc/rc.local
|
2005-08-02 17:46:24 +02:00
|
|
|
|
2005-04-25 15:50:26 +02:00
|
|
|
case "$#:$1" in
|
|
|
|
1:start|1:stop|1:down)
|
|
|
|
action=$1
|
|
|
|
;;
|
|
|
|
*) echo >&2 "Usage: $0 start|stop|down"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|
2005-08-05 12:37:02 +02:00
|
|
|
if [ -f "$LOCAL_FILE" ]
|
|
|
|
then . "$LOCAL_FILE" $1
|
|
|
|
fi
|
|
|
|
|
2005-08-04 18:45:29 +02:00
|
|
|
disabled()
|
|
|
|
{
|
|
|
|
ifs="$IFS"; IFS=,
|
2005-08-04 19:00:18 +02:00
|
|
|
for skip in `sysenv disable`
|
2005-08-04 18:45:29 +02:00
|
|
|
do
|
2005-08-04 19:00:18 +02:00
|
|
|
if [ "$skip" = "$1" ]
|
2005-08-04 18:45:29 +02:00
|
|
|
then
|
|
|
|
IFS="$ifs"; unset ifs
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
IFS="$ifs"; unset ifs
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2005-04-25 15:50:26 +02:00
|
|
|
daemonize()
|
|
|
|
{
|
|
|
|
# Function to start a daemon, if it exists.
|
|
|
|
local IFS=':'
|
|
|
|
local name="$1"
|
|
|
|
test "$1" = tcpd && name="$2"
|
|
|
|
|
|
|
|
for dir in $PATH
|
|
|
|
do
|
|
|
|
if [ -f "$dir/$1" ]
|
|
|
|
then
|
2005-08-04 18:45:29 +02:00
|
|
|
|
|
|
|
# check if this service is disabled at the boot monitor.
|
|
|
|
if disabled $name; then return; fi
|
|
|
|
|
2005-04-25 15:50:26 +02:00
|
|
|
echo -n " $name"
|
|
|
|
"$@" &
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2005-08-02 17:46:24 +02:00
|
|
|
up()
|
|
|
|
{
|
|
|
|
service=$1
|
|
|
|
args=$2
|
|
|
|
device=$3
|
|
|
|
|
|
|
|
# Function to dynamically start a system service
|
|
|
|
|
|
|
|
# First check if this service is disabled at the boot monitor.
|
2005-08-04 18:45:29 +02:00
|
|
|
if disabled $service; then return; fi
|
2005-08-02 17:46:24 +02:00
|
|
|
|
|
|
|
# Service is not disabled. Try to bring it up.
|
|
|
|
command="/usr/sbin/$service"
|
|
|
|
if [ ! -z "$args" ]; then command="$command -args \"$args\""; fi
|
|
|
|
if [ ! -z "$device" ]; then command="$command -dev \"$device\""; fi
|
|
|
|
echo -n " $service"
|
|
|
|
eval service up $command
|
|
|
|
}
|
2005-07-19 14:16:55 +02:00
|
|
|
|
2005-04-25 15:50:26 +02:00
|
|
|
case $action in
|
|
|
|
start)
|
|
|
|
# Select console font.
|
|
|
|
test -f /etc/font && loadfont /etc/font </dev/console
|
|
|
|
|
|
|
|
# Cleanup.
|
|
|
|
rm -rf /tmp/. /usr/run/. /usr/spool/lpd/. /usr/spool/locks/.
|
|
|
|
|
2005-08-04 11:26:36 +02:00
|
|
|
# Start servers and drivers set at the boot monitor.
|
2005-08-04 21:23:03 +02:00
|
|
|
echo -n "More services:"
|
2005-08-03 17:22:41 +02:00
|
|
|
up random "" /dev/random
|
|
|
|
|
2005-07-19 14:16:55 +02:00
|
|
|
# load random number generator
|
|
|
|
if [ -f $RANDOM_FILE ]
|
|
|
|
then
|
|
|
|
cat < $RANDOM_FILE >/dev/random
|
|
|
|
# overwrite $RANDOM_FILE. We don't want to use this data again
|
2005-08-02 17:56:24 +02:00
|
|
|
dd if=/dev/random of=$RANDOM_FILE bs=1024 count=1 2> /dev/null
|
2005-07-19 14:16:55 +02:00
|
|
|
fi
|
|
|
|
|
2005-08-04 11:26:36 +02:00
|
|
|
# start only network drivers that are in use
|
2005-08-05 16:20:05 +02:00
|
|
|
for driver in rtl8139 fxp dpeth dp8390
|
2005-08-04 11:26:36 +02:00
|
|
|
do
|
|
|
|
if grep " $driver " /etc/inet.conf > /dev/null
|
|
|
|
then
|
2005-08-05 12:37:02 +02:00
|
|
|
eval arg=\$${driver}_arg
|
|
|
|
up $driver "$arg"
|
2005-08-04 11:26:36 +02:00
|
|
|
fi
|
|
|
|
done
|
2005-08-02 18:05:01 +02:00
|
|
|
up inet ""
|
2005-08-02 17:46:24 +02:00
|
|
|
up printer "" /dev/lp
|
|
|
|
echo .
|
2005-04-25 15:50:26 +02:00
|
|
|
|
|
|
|
# Network initialization.
|
|
|
|
(: </dev/tcp) 2>/dev/null && net=t # Is there a TCP/IP server?
|
|
|
|
|
|
|
|
echo -n "Starting daemons:"
|
|
|
|
daemonize update
|
2005-07-08 19:30:01 +02:00
|
|
|
daemonize usyslogd
|
2005-05-03 17:41:02 +02:00
|
|
|
|
|
|
|
# Ugly error message when starting cron from CD.
|
|
|
|
# (and cron unnecessary then so..)
|
|
|
|
if [ ! -f /CD ]
|
|
|
|
then daemonize cron
|
|
|
|
fi
|
2005-08-02 17:56:24 +02:00
|
|
|
echo .
|
2005-04-25 15:50:26 +02:00
|
|
|
|
|
|
|
if [ "$net" ]
|
|
|
|
then
|
|
|
|
if [ -f /etc/rc.net ]
|
|
|
|
then
|
|
|
|
# Let a customized TCP/IP initialization script figure it out.
|
|
|
|
. /etc/rc.net
|
|
|
|
else
|
|
|
|
# Standard network daemons.
|
2005-08-02 17:56:24 +02:00
|
|
|
echo -n "Starting networking:"
|
2005-04-25 15:50:26 +02:00
|
|
|
daemonize dhcpd
|
|
|
|
daemonize nonamed
|
|
|
|
daemonize talkd
|
|
|
|
daemonize tcpd shell in.rshd
|
|
|
|
daemonize tcpd login in.rlogind
|
|
|
|
daemonize tcpd telnet in.telnetd
|
|
|
|
daemonize tcpd ftp in.ftpd
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# The last daemon has been started, so close the list:
|
|
|
|
echo .
|
|
|
|
|
|
|
|
if [ "$net" ]
|
|
|
|
then
|
|
|
|
# Get the nodename from the DNS and set it.
|
|
|
|
trap '' 2
|
2005-08-08 18:56:40 +02:00
|
|
|
intr -t 10 hostaddr -h || echo "Unable to obtain an IP address."
|
2005-04-25 15:50:26 +02:00
|
|
|
trap 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Recover files being edited when the system crashed.
|
|
|
|
test -f /usr/bin/elvprsv && elvprsv /usr/tmp/elv*
|
|
|
|
|
|
|
|
# Run the daily cleanup on systems that are not on at night.
|
|
|
|
test -f /usr/etc/daily && sh /usr/etc/daily boot &
|
2005-07-19 14:16:55 +02:00
|
|
|
|
|
|
|
;;
|
|
|
|
stop|down)
|
|
|
|
# Save random data.
|
|
|
|
if dd if=/dev/random of=$RANDOM_FILE.new bs=1024 count=1 2>/dev/null
|
|
|
|
then
|
|
|
|
mv $RANDOM_FILE.new $RANDOM_FILE
|
|
|
|
else
|
|
|
|
echo 'Failed to save random data.'
|
|
|
|
fi
|
2005-04-25 15:50:26 +02:00
|
|
|
esac
|