#!/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 eth1 backchannel" # Prevent connman from taking control of the backchannel network device. ORIG_CONF=${ROOT_FS_DIR}/etc/init/connman.conf TEMP_CONF=${ORIG_CONF}.tmp sed 's/connmand -W/connmand -I eth1 -W/' ${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-eth1.rules < ${ROOT_FS_DIR}/sbin/backchannel-setup < /dev/null 2>&1; then orig_eth1_mac=\$(ifconfig eth1 | awk '/HWaddr/ {print \$5}') ifconfig eth1 down # must be down for nameif to work nameif eth_tmp \${orig_eth1_mac} fi bdev_mac=\$(ifconfig \$1 | awk '/HWaddr/ {print \$5}') ifconfig \$1 down # must be down for nameif to work nameif eth1 \${bdev_mac} if [ -n "\${orig_eth1_mac}" ]; then nameif \$1 \${orig_eth1_mac} fi initctl start connman fi # Bring up the backchannel interface dhclient -q -pf /var/run/dhclient-eth1.pid \\ -lf /var/run/dhclient-eth1.leases \\ -cf /etc/dhclient-backchannel.conf \\ -sf /sbin/dhclient-backchannel-script \\ eth1 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