1 # /usr/etc/rc - continued system initialization.
3 RANDOM_FILE=/usr/adm/random.dat
4 LOCAL_FILE=/usr/etc/rc.local
9 # Directories to find services in
10 if [ ! "$SERVICES_DIRS" ]
11 then SERVICES_DIRS=/usr/sbin
15 bootcd="`/bin/sysenv bootcd`"
18 1:start|1:stop|1:down)
21 *) echo >&2 "Usage: $0 start|stop|down"
25 if [ -f "$LOCAL_FILE" ]
26 then . "$LOCAL_FILE" $1
32 for skip in `sysenv disable`
46 # Function to start a daemon, if it exists.
49 test "$1" = tcpd && name="$2"
56 # check if this service is disabled at the boot monitor.
57 if disabled $name; then return; fi
68 # Function to dynamically start a system service
70 prefix=$(expr "$1 " : '\(-\)')
71 if [ "$prefix" = "-" ];
79 # First check if this service is disabled at the boot monitor.
80 if disabled $service; then return; fi
82 # Service is not disabled. Try to bring it up.
84 for dir in $SERVICES_DIRS
86 if [ -x $bin -a -z "$found" ]
87 then service $opt up $bin "$@"
93 then echo " ($service not found in $SERVICES_DIRS)"
98 # Filter out the non-vlan ethernet entries from inet.conf.
99 # Produce as output a list of "drivername_instancenr"-formatted labels.
100 sed 's/\008/ /g' /etc/inet.conf | \
101 sed -n 's/^ *eth[0-9][0-9]* *\([^ ][^ ]*\) *\([0-9][0-9]*\).*$/\1_\2/p' | \
105 DAEMONS=/etc/rc.daemons
109 # Select console font.
110 test -f /etc/font && loadfont /etc/font </dev/console
113 rm -rf /tmp/* /usr/run/* /usr/spool/lpd/* /usr/spool/locks/*
115 # Start servers and drivers set at the boot monitor.
116 echo -n "Starting services:"
117 up -n random -dev /dev/random -devstyle STYLE_DEVA -period 3HZ
119 # load random number generator
120 if [ -f $RANDOM_FILE ]
122 cat < $RANDOM_FILE >/dev/random
123 # overwrite $RANDOM_FILE. We don't want to use this data again
124 dd if=/dev/random of=$RANDOM_FILE bs=1024 count=1 2> /dev/null
127 # start network driver instances for all configured ethernet devices
128 for label in $(get_eth_labels); do
129 driver=$(echo $label | sed 's/\(.*\)_.*/\1/')
130 instance=$(echo $label | sed 's/.*_//')
131 eval arg=\$${label}_arg
132 if [ ! -z "$arg" ]; then arg=" $arg"; fi
133 arg="-args \"instance=$instance$arg\""
134 eval up $driver -label $label $arg -period 5HZ
136 if [ X`/bin/sysenv lwip` = Xyes ]
138 up lwip -script /etc/rs.inet -dev /dev/ip -devstyle STYLE_CLONE_A
140 up inet -script /etc/rs.inet -dev /dev/ip -devstyle STYLE_CLONE
142 up -n printer -dev /dev/lp -period 10HZ
144 # start VirtualBox time sync driver if the device is there
145 if grep '^[^ ]* [^ ]* 80EE:CAFE ' /proc/pci >/dev/null; then
146 up -n vbox -period 10HZ
150 # Network initialization.
151 (: </dev/tcp) 2>/dev/null && net=t # Is there a TCP/IP server?
153 echo -n "Starting daemons:"
156 # Ugly error message when starting cron from CD.
157 # (and cron unnecessary then so..)
161 rm -f /var/log || true
162 ln -s /tmp/log /var/log || true
165 # syslogd has not been started yet
166 rm -f /var/run/syslogd.pid
172 if [ -f /etc/rc.net ]
174 # Let a customized TCP/IP initialization script figure it out.
177 # Standard network daemons.
178 echo -n "Starting networking:"
179 if grep -s 'psip0.*default' /etc/inet.conf >/dev/null
180 then ifconfig -h 10.0.0.1
182 if [ X`/bin/sysenv lwip` = Xyes ]
194 # The last daemon has been started, so close the list:
201 # Get the nodename from the DNS and set it.
203 intr -t 20 hostaddr -h
207 # Recover files being edited when the system crashed.
208 test -f /usr/bin/elvprsv && elvprsv /usr/tmp/elv*
210 # Run the daily cleanup on systems that are not on at night.
211 test -f /usr/etc/daily && sh /usr/etc/daily boot &
214 # Save random data, if /usr is mounted rw.
215 if grep ' \/usr .*rw' /etc/mtab >/dev/null
217 if dd if=/dev/random of=$RANDOM_FILE.new bs=1024 count=1 2>/dev/null
219 mv $RANDOM_FILE.new $RANDOM_FILE
221 echo 'Failed to save random data.'
227 # Let packages run their own scripts
228 for d in /usr/local/etc/rc.d /usr/pkg/etc/rc.d
230 if [ -d "$d" -a -z "$bootcd" ]
233 echo -n "Local packages ($action): "