summaryrefslogtreecommitdiffstats
path: root/Scripts/setup_tap.sh
diff options
context:
space:
mode:
authorsuchinton2001 <suchinton.2001@gmail.com>2023-07-22 18:39:14 +0530
committersuchinton2001 <suchinton.2001@gmail.com>2023-09-07 18:31:07 +0530
commitdb9f586a19fed7bcd04be3596fc30dc53f61b1db (patch)
tree476d86c085137779f47ee6b409e3a8aaac68991d /Scripts/setup_tap.sh
parentf9b00b992d88edc0e9c31de809a1a981139c4fde (diff)
Upload progress on AGL demo control panel in one batch
AGL Demo Control Panel is a PyQt5 application used to simulate CAN bus signals using Kuksa.val v1: Initial commit v2: Remove unused assets v3: Add Opensans fonts, remove un-used styles and add Lisences as attributions v4: - Remove Opensans fonts, default to Dejavu fonts - Replace feather icons with carbon icons. - Reusing AGL demo app assests for HVAC and Steering wheel inputs. v5: Remove assets/Images/Lisences.md attribution file Signed-off-by: suchinton2001 <suchinton.2001@gmail.com> Change-Id: I1529495deff6fc27eacb92f7a29c4f71f8c8d5d9
Diffstat (limited to 'Scripts/setup_tap.sh')
-rw-r--r--Scripts/setup_tap.sh84
1 files changed, 84 insertions, 0 deletions
diff --git a/Scripts/setup_tap.sh b/Scripts/setup_tap.sh
new file mode 100644
index 0000000..1c71344
--- /dev/null
+++ b/Scripts/setup_tap.sh
@@ -0,0 +1,84 @@
+#!/bin/bash
+
+if [[ $EUID > 0 ]]; then
+ echo "Run this script as root"
+ exit
+fi
+
+BRIDGE="br0"
+TAP="tap0"
+
+echo "Available network interfaces:"
+interfaces=$(ip link | awk -F ': ' '{print $2}')
+index=0
+
+# Array to store interface names
+declare -a interface_names
+
+# Array to store interface types
+declare -a interface_types
+
+# Loop through each interface and display its type
+for interface in $interfaces; do
+ type=$(ip link show $interface | grep -o 'type .*' | awk '{print $2}')
+ echo "$index: $interface - $type"
+
+ # Store interface name and type in arrays
+ interface_names[$index]=$interface
+ interface_types[$index]=$type
+
+ ((index++))
+done
+
+# Prompt the user to select an interface
+read -p "Enter the number of the interface you want to use: " selection
+
+# Validate the user's input
+if [[ ! $selection =~ ^[0-9]+$ || $selection -lt 0 || $selection -ge $index ]]; then
+ echo "Invalid selection. Exiting."
+ exit
+fi
+
+INTERFACE=${interface_names[$selection]}
+INTERFACE_TYPE=${interface_types[$selection]}
+
+echo "Selected interface: $INTERFACE - $INTERFACE_TYPE"
+
+echo "Adding bridge $BRIDGE"
+ip link add name $BRIDGE type bridge
+
+echo "Flushing interface $INTERFACE"
+ip addr flush dev $INTERFACE
+
+echo "Setting $BRIDGE as master of $INTERFACE"
+ip link set $INTERFACE master $BRIDGE
+
+echo "Adding tap $TAP"
+ip tuntap add $TAP mode tap
+
+echo "Setting $BRIDGE as master of $TAP"
+ip link set $TAP master $BRIDGE
+
+echo "Setting $INTERFACE, $BRIDGE, and $TAP up"
+ip link set up dev $INTERFACE
+ip link set up dev $TAP
+ip link set up dev $BRIDGE
+
+echo "Stopping NetworkManager"
+systemctl stop NetworkManager
+
+echo "Requesting IP for $BRIDGE"
+dhclient -1 -v $BRIDGE
+
+if [ $? -eq 0 ]; then
+ echo "Requesting IP for $INTERFACE"
+ dhclient $INTERFACE
+ echo "Killing dhclient and starting NetworkManager"
+ pkill -9 dhclient
+ systemctl start NetworkManager
+fi
+
+# run qemu with the below arguments
+#
+# qemu-system-x86_64 -netdev tap,id=net0,ifname=tap0,script=no,downscript=no -device virtio-net-pci,netdev=net0
+