53 lines
1.3 KiB
Bash
53 lines
1.3 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
# ==============================================================================
|
||
|
# Config and setup
|
||
|
|
||
|
SOURCE=${BASH_SOURCE[0]}
|
||
|
while [ -L "$SOURCE" ]; do
|
||
|
DIR=$(cd -P "$(dirname "$SOURCE")" >/dev/null 2>&1 && pwd)
|
||
|
SOURCE=$(readlink "$SOURCE")
|
||
|
[[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE
|
||
|
done
|
||
|
DIR=$(cd -P "$(dirname "$SOURCE")" >/dev/null 2>&1 && pwd)
|
||
|
|
||
|
if [[ -f "$DIR/../config/config.sh" ]]; then
|
||
|
. "$DIR/../config/config.sh"
|
||
|
else
|
||
|
echo "$DIR/../config/config.sh missing!"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
if [ "$(id -u)" -ne 0 ]; then
|
||
|
echo 'This script must be run as root.' >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
. "$DIR/get_client_mac_address.sh"
|
||
|
|
||
|
# ==============================================================================
|
||
|
|
||
|
MAC_OTHR=$(get_client_mac_address $ETH_IFACE)
|
||
|
if [ -z "$MAC_OTHR" ]; then
|
||
|
echo "Bridged client not found! MAC address was empty."
|
||
|
exit 1
|
||
|
else
|
||
|
echo "Cloning MAC: $MAC_OTHR"
|
||
|
fi
|
||
|
|
||
|
# Clone MAC address of the wired-only device to the WiFi device
|
||
|
ifconfig $WLAN_IFACE down
|
||
|
ifconfig $WLAN_IFACE hw ether $MAC_OTHR
|
||
|
ifconfig $WLAN_IFACE up
|
||
|
echo "Set $WLAN_IFACE MAC to $MAC_OTHR"
|
||
|
|
||
|
while true; do
|
||
|
WLAN_IFACE_IP=$(ip -4 -br addr show $WLAN_IFACE | grep -Po "\\d+\\.\\d+\\.\\d+\\.\\d+")
|
||
|
if [ -n "${WLAN_IFACE_IP}" ]; then
|
||
|
echo "Got DHCP IP: $WLAN_IFACE_IP"
|
||
|
break
|
||
|
fi
|
||
|
echo "Waiting for $WLAN_IFACE to get an IP..."
|
||
|
sleep 5
|
||
|
done
|