Check that mac address gets generated

This commit is contained in:
Bob Mottram 2017-09-29 22:23:03 +01:00
parent a5d2b6a69e
commit 81c2c54493
1 changed files with 42 additions and 37 deletions

View File

@ -229,13 +229,15 @@ function start {
ifconfig $IFACE down ifconfig $IFACE down
ifconfig $IFACE mtu 1532 ifconfig $IFACE mtu 1532
peeraddr=$(assign_peer_address) peermac=$(assign_peer_address)
ifconfig $IFACE hw ether $peeraddr if [ ! $peermac ]; then
echo $"$IFACE assigned MAC address $peeraddr" echo $"Unable to obtain MAC address for $peermac"
return
fi
ifconfig $IFACE hw ether $peermac
echo $"$IFACE assigned MAC address $peermac"
iwconfig $IFACE enc off iwconfig $IFACE enc off
iwconfig $IFACE mode ad-hoc essid $WIFI_SSID channel $CHANNEL iwconfig $IFACE mode ad-hoc essid $WIFI_SSID channel $CHANNEL
sleep 1
iwconfig $IFACE ap $CELLID
modprobe batman-adv modprobe batman-adv
batctl if add $IFACE batctl if add $IFACE
@ -264,42 +266,45 @@ function start {
HOTSPOT_NAME=$"${WIFI_SSID}-hotspot" HOTSPOT_NAME=$"${WIFI_SSID}-hotspot"
ifconfig $IFACE_SECONDARY down ifconfig $IFACE_SECONDARY down
ifconfig $IFACE_SECONDARY mtu 1500 ifconfig $IFACE_SECONDARY mtu 1500
peeraddr=$(assign_peer_address) CELLID=$(assign_peer_address)
ifconfig $IFACE_SECONDARY hw ether $peeraddr if [ $CELLID ]; then
echo $"Secondary wifi adaptor $IFACE_SECONDARY assigned to MAC address $peeraddr" ifconfig $IFACE_SECONDARY hw ether $CELLID
iwconfig $IFACE_SECONDARY enc open echo $"Secondary wifi adaptor $IFACE_SECONDARY assigned to MAC address $CELLID"
iwconfig $IFACE_SECONDARY mode managed essid $HOTSPOT_NAME channel ${HOTSPOT_CHANNEL} iwconfig $IFACE_SECONDARY enc open
iwconfig $IFACE_SECONDARY ap $CELLID iwconfig $IFACE_SECONDARY mode managed essid $HOTSPOT_NAME channel ${HOTSPOT_CHANNEL}
iwconfig $IFACE_SECONDARY ap $CELLID
iwconfig $IFACE ap $CELLID
brctl addbr $BRIDGE_HOTSPOT brctl addbr $BRIDGE_HOTSPOT
brctl addif $BRIDGE_HOTSPOT bat0 brctl addif $BRIDGE_HOTSPOT bat0
brctl addif $BRIDGE_HOTSPOT $IFACE_SECONDARY brctl addif $BRIDGE_HOTSPOT $IFACE_SECONDARY
ifconfig bat0 0.0.0.0 ifconfig bat0 0.0.0.0
ifconfig $IFACE_SECONDARY 0.0.0.0 ifconfig $IFACE_SECONDARY 0.0.0.0
sed -i 's|#DAEMON_CONF=.*|DAEMON_CONF="/etc/hostapd/hostapd.conf"|g' /etc/default/hostapd sed -i 's|#DAEMON_CONF=.*|DAEMON_CONF="/etc/hostapd/hostapd.conf"|g' /etc/default/hostapd
echo "interface=${IFACE_SECONDARY}" > /etc/hostapd/hostapd.conf echo "interface=${IFACE_SECONDARY}" > /etc/hostapd/hostapd.conf
echo "bridge=${BRIDGE_HOTSPOT}" >> /etc/hostapd/hostapd.conf echo "bridge=${BRIDGE_HOTSPOT}" >> /etc/hostapd/hostapd.conf
echo 'driver=nl80211' >> /etc/hostapd/hostapd.conf echo 'driver=nl80211' >> /etc/hostapd/hostapd.conf
echo "country_code=UK" >> /etc/hostapd/hostapd.conf echo "country_code=UK" >> /etc/hostapd/hostapd.conf
echo "ssid=$HOTSPOT_NAME" >> /etc/hostapd/hostapd.conf echo "ssid=$HOTSPOT_NAME" >> /etc/hostapd/hostapd.conf
echo 'hw_mode=g' >> /etc/hostapd/hostapd.conf echo 'hw_mode=g' >> /etc/hostapd/hostapd.conf
echo "channel=${HOTSPOT_CHANNEL}" >> /etc/hostapd/hostapd.conf echo "channel=${HOTSPOT_CHANNEL}" >> /etc/hostapd/hostapd.conf
echo 'wpa=2' >> /etc/hostapd/hostapd.conf echo 'wpa=2' >> /etc/hostapd/hostapd.conf
echo "wpa_passphrase=$HOTSPOT_PASSPHRASE" >> /etc/hostapd/hostapd.conf echo "wpa_passphrase=$HOTSPOT_PASSPHRASE" >> /etc/hostapd/hostapd.conf
echo 'wpa_key_mgmt=WPA-PSK' >> /etc/hostapd/hostapd.conf echo 'wpa_key_mgmt=WPA-PSK' >> /etc/hostapd/hostapd.conf
echo 'wpa_pairwise=TKIP' >> /etc/hostapd/hostapd.conf echo 'wpa_pairwise=TKIP' >> /etc/hostapd/hostapd.conf
echo 'rsn_pairwise=CCMP' >> /etc/hostapd/hostapd.conf echo 'rsn_pairwise=CCMP' >> /etc/hostapd/hostapd.conf
echo 'auth_algs=1' >> /etc/hostapd/hostapd.conf echo 'auth_algs=1' >> /etc/hostapd/hostapd.conf
echo 'macaddr_acl=0' >> /etc/hostapd/hostapd.conf echo 'macaddr_acl=0' >> /etc/hostapd/hostapd.conf
ifconfig $BRIDGE_HOTSPOT up ifconfig $BRIDGE_HOTSPOT up
avahi-autoipd --force-bind --daemonize --wait $BRIDGE_HOTSPOT avahi-autoipd --force-bind --daemonize --wait $BRIDGE_HOTSPOT
ifconfig $IFACE_SECONDARY up promisc ifconfig $IFACE_SECONDARY up promisc
#ifconfig $IFACE_SECONDARY auto-dhcp start #ifconfig $IFACE_SECONDARY auto-dhcp start
systemctl start hostapd systemctl start hostapd
hotspot_enabled=1 hotspot_enabled=1
fi
fi fi
fi fi
fi fi