# /usr/etc/rc - continued system initialization. RANDOM_FILE=/usr/adm/random.dat case "$#:$1" in 1:start|1:stop|1:down) action=$1 ;; *) echo >&2 "Usage: $0 start|stop|down" exit 1 esac 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 echo -n " $name" "$@" & return fi done } 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. ifs="$IFS"; IFS=, for name in `sysenv disable` do if [ "$name" = "$service" ] then return fi done IFS="$ifs"; unset ifs # 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 } case $action in start) # Select console font. test -f /etc/font && loadfont /etc/font /dev/random # overwrite $RANDOM_FILE. We don't want to use this data again dd if=/dev/random of=$RANDOM_FILE bs=1024 count=1 fi # Start servers and drivers set at the boot monitor. echo -n "Starting services:" up rtl8139 up fxp up dpeth up inet up is "arg is leuk" up printer "" /dev/lp up floppy "" /dev/fd0 echo . # Network initialization. (: /dev/null && net=t # Is there a TCP/IP server? echo -n "Starting daemons:" daemonize update daemonize usyslogd # Ugly error message when starting cron from CD. # (and cron unnecessary then so..) if [ ! -f /CD ] then daemonize cron fi 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. 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. t='-t 10' trap '' 2 while :; do intr $t hostaddr -h case $? in 142) echo "\ Unable to obtain an IP address after 10 seconds. Hit DEL to get a root prompt to investigate, otherwise just wait until an address is received..." t= ;; 130) echo "Single user." intr sh echo "Continue waiting for an address..." ;; *) break esac done 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 & ;; 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 esac