diff --git a/Makefile b/Makefile index ef0f7cc..ff69057 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # Makefile for installation of echomav_deploy on EchoPilot AI hardware -# This is installation of mavlink-router, cockpit and network setup +# This is installation of mavlink-router, cockpit, and network setup # Spiri modified to install additional features .DEFAULT_GOAL := default SHELL := /bin/bash @@ -13,16 +13,66 @@ DRY_RUN=false LOCAL=/usr/local LOCAL_SCRIPTS=temperature.sh cockpitScript.sh -.PHONY = enable install see uninstall static default no-static +.PHONY: enable install see uninstall static default no-static verify_spir0 interactive set_network_manager_config configure_wifibroadcast -default: - @$(MAKE) --no-print-directory install - @$(MAKE) --no-print-directory static +default: interactive install static set_network_manager_config configure_wifibroadcast + +# New interactive target +interactive: + @clear + @echo " " + @echo " _____ _____ _____ _____ _____ " + @echo " / ____|| __ \|_ _|| __ \ |_ _| " + @echo " | (___ | |__) | | | | |__) | | | " + @echo " \___ \ | ___/ | | | _ / | | " + @echo " ____) || | _| |_ | | \ \ _| |_ " + @echo " |_____/ |_| __|_____||_|__\_\|_____| " + @echo " | \/ || | | ||__ \ " + @echo " | \ / || | | | ) | " + @echo " | |\/| || | | | / / " + @echo " | | | || |__| | / /_ " + @echo " |_| |_| \____/ |____| " + @echo " " + @echo "Installing Mu2 Default Settings/Programs " + @echo "" + @read -p "Do you want to set a static IP address? (Y/N): " set_ip; \ + if [ "$$set_ip" = "Y" ] || [ "$$set_ip" = "y" ]; then \ + echo ""; \ + echo "Please enter the last segment of the IP address for this setup (between 15-250)"; \ + read -p "IP Address: 192.168.10. " ip_address; \ + $(MAKE) explicit-ip ip=192.168.10.$$ip_address; \ + else \ + echo "Proceeding without setting a static IP address."; \ + fi explicit-ip: @$(MAKE) --no-print-directory install @$(SUDO) ./static-network.sh -i eth0 -a $(ip) +# New target to configure NetworkManager to ignore spir0 +set_network_manager_config: + @echo "" + @echo "Configuring NetworkManager to ignore SpiriLink interface (spir0)..." + @echo "" + @$(SUDO) mkdir -p /etc/NetworkManager + @$(SUDO) touch /etc/NetworkManager/NetworkManager.conf + @if ! grep -q "\[keyfile\]" /etc/NetworkManager/NetworkManager.conf; then \ + echo "[keyfile]" | $(SUDO) tee -a /etc/NetworkManager/NetworkManager.conf > /dev/null; \ + fi + @if ! grep -q "unmanaged-devices=interface-name:spir0" /etc/NetworkManager/NetworkManager.conf; then \ + echo "unmanaged-devices=interface-name:spir0" | $(SUDO) tee -a /etc/NetworkManager/NetworkManager.conf > /dev/null; \ + fi + @$(SUDO) systemctl restart NetworkManager + @echo "NetworkManager has been configured to ignore spir0." + +# New target to configure wifibroadcast settings +configure_wifibroadcast: + @echo "" + @echo "Configuring /etc/default/wifibroadcast with interface spir0..." + @echo "" + @$(SUDO) bash -c "echo 'WFB_NICS=\"spir0\"' > /etc/default/wifibroadcast" + @echo "Configuration updated: /etc/default/wifibroadcast has been set with WFB_NICS=\"spir0\"." + no-static: @$(MAKE) --no-print-directory install @@ -43,7 +93,7 @@ static: # set up static ip address on eth0 @$(SUDO) ./static-network.sh -i eth0 -a auto -install: +install: verify_spir0 # install helper apps # @$(SUDO) rm -r /var/lib/apt/lists/* @$(SUDO) apt update @@ -88,9 +138,7 @@ install: @$(SUDO) apt -y install dkms @$(SUDO) ./dkms-install.sh -# configure naming of wireless interface - -# Install WFB-NG dependancies and compile deb +# Install WFB-NG dependencies and compile deb @git clone -b stable https://github.com/svpcom/wfb-ng.git ~/tmp/wfb-ng && cd ~/tmp/wfb-ng @$(SUDO) apt -y install python3-all libpcap-dev libsodium-dev python3-pip python3-pyroute2 python3-future python3-twisted python3-serial python3-all-dev iw virtualenv debhelper dh-python build-essential @$(SUDO) make deb @@ -129,5 +177,3 @@ uninstall: @$(MAKE) --no-print-directory disable @( for s in $(SERVICES) ; do $(SUDO) rm $(LIBSYSTEMD)/$${s%.*}.service ; done ; true ) @if [ ! -z "$(SERVICES)" ] ; then $(SUDO) systemctl daemon-reload ; fi - - diff --git a/verify_wlan_usb.sh b/verify_wlan_usb.sh new file mode 100644 index 0000000..bd31f2f --- /dev/null +++ b/verify_wlan_usb.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Desired USB Vendor ID and Product ID for the Wi-Fi card +USB_VENDOR="0bda" +USB_PRODUCT="a81a" +NEW_INTERFACE_NAME="spir0" +UDEV_RULES_FILE="/etc/udev/rules.d/70-persistent-net.rules" + +# Create a udev rule to rename the Wi-Fi adapter based on USB Vendor and Product ID +echo "Creating udev rule for SpiriLink adapter..." + +# Create the udev rules directory if it doesn't exist +sudo mkdir -p /etc/udev/rules.d + +# Write the udev rule +sudo bash -c "cat < $UDEV_RULES_FILE +SUBSYSTEM==\"net\", ACTION==\"add\", ATTRS{idVendor}==\"$USB_VENDOR\", ATTRS{idProduct}==\"$USB_PRODUCT\", NAME=\"$NEW_INTERFACE_NAME\" +EOF" + +# Reload udev rules +echo "Reloading udev rules..." +sudo udevadm control --reload +sudo udevadm trigger + +echo "udev rule created successfully to rename the SpiriLink adapter to $NEW_INTERFACE_NAME."