#!/bin/bash # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. echo "Configuring for backchannel network device" testif=eth_test # Prevent flimflam from taking control of the backchannel network device. ORIG_CONF=${ROOT_FS_DIR}/etc/init/flimflam.conf TEMP_CONF=${ORIG_CONF}.tmp sed "s,/usr/sbin/flimflamd,/usr/sbin/flimflamd -I ${testif}," ${ORIG_CONF} > ${TEMP_CONF} mv -f ${TEMP_CONF} ${ORIG_CONF} # Arrange to run dhclient on the backchannel device but without # installing the default route, and stashing said route away for later # installation as a host route. cat > ${ROOT_FS_DIR}/etc/udev/rules.d/50-backchannel-network.rules < ${ROOT_FS_DIR}/sbin/backchannel-setup < /dev/null 2>&1; then orig_mac=\$(ifconfig \${testif} | awk '/HWaddr/ {print \$5}') ifconfig \${testif} down # must be down for nameif to work nameif eth_tmp \${orig_mac} fi bdev_mac=\$(ifconfig \$1 | awk '/HWaddr/ {print \$5}') ifconfig \$1 down # must be down for nameif to work nameif \${testif} \${bdev_mac} if [ -n "\${orig_mac}" ]; then nameif \$1 \${orig_mac} fi initctl start flimflam fi # Bring up the backchannel interface dhclient -q -pf /var/run/dhclient-\${testif}.pid \\ -lf /var/run/dhclient-\${testif}.leases \\ -cf /etc/dhclient-backchannel.conf \\ -sf /sbin/dhclient-backchannel-script \\ \${testif} EOF chmod +x ${ROOT_FS_DIR}/sbin/backchannel-setup cat > ${ROOT_FS_DIR}/etc/dhclient-backchannel.conf < ${ROOT_FS_DIR}/sbin/dhclient-backchannel-script <> /var/run/dhclient-\${interface}.routers done fi ;; EXPIRE|FAIL|RELEASE|STOP) if [ -n "\$old_ip_address" ]; then # Shut down interface, which will delete routes and clear arp cache. ifconfig \$interface inet 0 fi ;; esac EOF chmod +x ${ROOT_FS_DIR}/sbin/dhclient-backchannel-script