1 # /usr/etc/rc - continued system initialization.
3 RANDOM_FILE=/usr/adm/random.dat
4 LOCAL_FILE=/usr/etc/rc.local
9 then # Older kernels do not provide an arch sysenv variable.
10 # We assume we are on x86 then, as existing systems with
11 # kernel and userland (i.e. this script) unsynchronized
19 # Directories to find services in
20 if [ ! "$SERVICES_DIRS" ]
21 then SERVICES_DIRS=/usr/sbin
25 bootcd="`/bin/sysenv bootcd`"
31 1:start|1:stop|1:down)
34 *) echo >&2 "Usage: $0 autoboot|start|stop|down"
38 if [ -f "$LOCAL_FILE" ]
39 then . "$LOCAL_FILE" $1
45 for skip in `sysenv disable`
59 # Function to start a daemon, if it exists.
62 test "$1" = tcpd && name="$2"
69 # check if this service is disabled at the boot monitor.
70 if disabled $name; then return; fi
81 # Function to dynamically start a system service
83 prefix=$(expr "$1 " : '\(-\)')
84 if [ "$prefix" = "-" ];
92 # First check if this service is disabled at the boot monitor.
93 if disabled $service; then return; fi
95 # Service is not disabled. Try to bring it up.
97 for dir in $SERVICES_DIRS
99 if [ -x $bin -a -z "$found" ]
100 then service $opt up $bin "$@"
106 then echo " ($service not found in $SERVICES_DIRS)"
111 # Filter out the non-vlan ethernet entries from inet.conf.
112 # Produce as output a list of "drivername_instancenr"-formatted labels.
113 sed 's/\008/ /g' /etc/inet.conf | \
114 sed -n 's/^ *eth[0-9][0-9]* *\([^ ][^ ]*\) *\([0-9][0-9]*\).*$/\1_\2/p' | \
118 # Detect expansion boards on the BeagleBone and load the proper drivers.
121 # Probe each possible cape EEPROM slave address for a BeagleBone cape.
122 for slave_addr in 54 55 56 57
125 # See if there is a readable EEPROM with address ${slave_addr}.
126 eepromread -f /dev/i2c-3 -a 0x${slave_addr} > /dev/null 2>&1
131 # Found an alive EEPROM. Try reading the cape name.
132 CAPE=`eepromread -i -f /dev/i2c-3 -a 0x${slave_addr} | \
133 sed -n 's/^PART_NUMBER : \(.*\)$/\1/p' | \
134 sed -e 's/\.*$//g'` # Strip trailing periods.
136 # Look for a cape specific RC script.
137 if [ -x /etc/rc.capes/${CAPE} ]
140 # CAT24C256 EEPROM -- all capes have this chip.
141 test -e /dev/eepromb3s${slave_addr} || \
142 (cd /dev && MAKEDEV eepromb3s${slave_addr})
143 up cat24c256 -dev /dev/eepromb3s${slave_addr} \
144 -label cat24c256.3.${slave_addr} \
145 -args "bus=3 address=0x${slave_addr}"
147 # Load the drivers for the cape and do any other configuration.
148 . "/etc/rc.capes/${CAPE}"
153 echo "** UNSUPPORTED CAPE: ${CAPE}"
161 DAEMONS=/etc/rc.daemons
165 # Select console font.
166 test -f /etc/font && loadfont /etc/font </dev/console
169 rm -rf /tmp/* /usr/run/* /usr/spool/lpd/* /usr/spool/locks/*
171 # Start servers and drivers set at the boot monitor.
172 echo -n "Starting services:"
173 up -n random -dev /dev/random -period 3HZ
175 # load random number generator
176 if [ -f $RANDOM_FILE ]
178 cat < $RANDOM_FILE >/dev/random
179 # overwrite $RANDOM_FILE. We don't want to use this data again
180 dd if=/dev/random of=$RANDOM_FILE bs=1024 count=1 2> /dev/null
183 # start network driver instances for all configured ethernet devices
184 for label in $(get_eth_labels); do
185 driver=$(echo $label | sed 's/\(.*\)_.*/\1/')
186 instance=$(echo $label | sed 's/.*_//')
187 eval arg=\$${label}_arg
188 if [ ! -z "$arg" ]; then arg=" $arg"; fi
189 arg="-args \"instance=$instance$arg\""
190 eval up $driver -label $label $arg -period 5HZ
192 if [ X`/bin/sysenv lwip` = Xyes ]
194 up lwip -script /etc/rs.inet -dev /dev/ip
196 up inet -script /etc/rs.inet -dev /dev/ip
199 up pty -dev /dev/ptyp0
205 up log -dev /dev/klog
209 up -n printer -dev /dev/lp -period 10HZ
210 # start VirtualBox time sync driver if the device is there
211 if grep '^[^ ]* [^ ]* 80EE:CAFE ' /proc/pci >/dev/null; then
212 up -n vbox -period 10HZ
218 # Network initialization.
219 (: </dev/tcp) 2>/dev/null && net=t # Is there a TCP/IP server?
221 echo -n "Starting daemons:"
224 # Ugly error message when starting cron from CD.
225 # (and cron unnecessary then so..)
229 rm -f /var/log || true
230 ln -s /tmp/log /var/log || true
233 # syslogd has not been started yet
234 rm -f /var/run/syslogd.pid
238 # i2c only supported on ARM at the moment
241 echo -n "Starting i2c subsystem: "
244 test -e /dev/i2c-${bus} || (cd /dev && MAKEDEV i2c-${bus})
245 up i2c -dev /dev/i2c-${bus} -label i2c.${bus} \
246 -args instance=${bus}
250 BOARD_NAME=`sysenv board`
251 case "${BOARD_NAME}" in
253 ARM-ARMV7-TI-BB-WHITE)
254 echo "Running on a BeagleBone"
255 echo -n "Starting i2c device drivers: "
257 # start EEPROM driver for reading board info
258 test -e /dev/eepromb1s50 || \
259 (cd /dev && MAKEDEV eepromb1s50)
260 up cat24c256 -dev /dev/eepromb1s50 \
261 -label cat24c256.1.50 \
262 -args 'bus=1 address=0x50'
264 # Start TPS65217 driver for power management.
265 up tps65217 -label tps65217.1.24 \
266 -args 'bus=1 address=0x24'
268 # check for the presence of a display
269 eepromread -f /dev/i2c-2 -n > /dev/null 2>&1
273 # start eeprom driver for reading EDID.
274 test -e /dev/eepromb2s50 || \
275 (cd /dev && MAKEDEV eepromb2s50)
276 up cat24c256 -dev /dev/eepromb2s50 \
277 -label cat24c256.2.50 \
278 -args 'bus=2 address=0x50'
281 #up fb -dev /dev/fb0 -args edid.0=cat24c256.2.50
282 # fb hasn't been ported to AM335X yet.
285 if [ -e /service/usbd ]
290 # Detect expansion boards and start drivers.
295 ARM-ARMV7-TI-BB-BLACK)
296 echo "Running on a BeagleBone Black"
297 echo -n "Starting i2c device drivers: "
299 # start EEPROM driver for reading board info
300 test -e /dev/eepromb1s50 || \
301 (cd /dev && MAKEDEV eepromb1s50)
302 up cat24c256 -dev /dev/eepromb1s50 \
303 -label cat24c256.1.50 \
304 -args 'bus=1 address=0x50'
306 # Start TPS65217 driver for power management.
307 up tps65217 -label tps65217.1.24 \
308 -args 'bus=1 address=0x24'
310 # Start TDA19988 driver for reading EDID.
311 up tda19988 -label tda19988.1.3470 -args \
312 'cec_bus=1 cec_address=0x34 hdmi_bus=1 hdmi_address=0x70'
315 #up fb -dev /dev/fb0 -args edid.0=tda19988.1.3470
316 # fb hasn't been ported to AM335X yet.
318 if [ -e /service/usbd ]
323 # Detect expansion boards and start drivers.
328 ARM-ARMV7-TI-BBXM-GENERIC)
329 echo "Running on a BeagleBoard-xM"
330 echo -n "Starting i2c device drivers: "
332 # Start TPS65950 driver for power management.
333 up tps65950 -label tps65950.1.48 \
334 -args 'bus=1 address=0x48'
336 # Set the system time to the time in the TPS65950's RTC
339 # check for the presence of a display
340 eepromread -f /dev/i2c-3 -n > /dev/null 2>&1
344 # start eeprom driver for reading edid
345 test -e /dev/eepromb3s50 || \
346 (cd /dev && MAKEDEV eepromb3s50)
347 up cat24c256 -dev /dev/eepromb3s50 \
348 -label cat24c256.3.50 \
349 -args 'bus=3 address=0x50'
352 up fb -dev /dev/fb0 -args edid.0=cat24c256.3.50
363 if [ -f /etc/rc.net ]
365 # Let a customized TCP/IP initialization script figure it out.
368 # Standard network daemons.
369 echo -n "Starting networking:"
370 if grep -s 'psip0.*default' /etc/inet.conf >/dev/null
371 then ifconfig -h 10.0.0.1
373 if [ X`/bin/sysenv lwip` = Xyes ]
385 # The last daemon has been started, so close the list:
392 # Get the nodename from the DNS and set it.
394 intr -t 20 hostaddr -h
398 # Recover files being edited when the system crashed.
399 test -f /usr/bin/elvprsv && elvprsv /usr/tmp/elv*
401 # Run the daily cleanup on systems that are not on at night.
402 test -f /usr/etc/daily && sh /usr/etc/daily boot &
405 # Save random data, if /usr is mounted rw.
406 if grep ' \/usr .*rw.*' /etc/mtab >/dev/null
408 if dd if=/dev/random of=$RANDOM_FILE.new bs=1024 count=1 2>/dev/null
410 mv $RANDOM_FILE.new $RANDOM_FILE
412 echo 'Failed to save random data.'
418 # Let packages run their own scripts
419 for d in /usr/local/etc/rc.d /usr/pkg/etc/rc.d
421 if [ -d "$d" -a -z "$bootcd" ]
424 echo -n "Local packages ($action): "