Spir0 stuff

This commit is contained in:
Alex 2024-12-12 16:57:28 -04:00
parent dc775e6ea6
commit 998b09b602

View File

@ -7,7 +7,7 @@ DRY_RUN=false
# Define dependencies # Define dependencies
DEPENDENCIES := nano htop nload sshpass python3-pip git ninja-build pkg-config gcc g++ systemd dkms python3-all python3-all-dev libpcap-dev libsodium-dev libevent-dev python3-pip python3-pyroute2 python3-msgpack \ DEPENDENCIES := nano htop nload sshpass python3-pip git ninja-build pkg-config gcc g++ systemd dkms python3-all python3-all-dev libpcap-dev libsodium-dev libevent-dev python3-pip python3-pyroute2 python3-msgpack \
python3-future python3-twisted python3-serial python3-jinja2 iw virtualenv debhelper dh-python fakeroot build-essential python3-future python3-twisted python3-serial python3-jinja2 iw virtualenv debhelper dh-python fakeroot build-essential python3-autobahn
# Define installation targets and options # Define installation targets and options
.PHONY: enable install interactive dependencies uninstall default full-install spirilink-driver spirilink-software setup-webapp-service configure-spirilink .PHONY: enable install interactive dependencies uninstall default full-install spirilink-driver spirilink-software setup-webapp-service configure-spirilink
@ -16,10 +16,10 @@ default: interactive install
interactive: interactive:
@clear @clear
@echo "\n=========================================" @echo "========================================="
@echo " SpiriBase Installer " @echo " SpiriBase Installer "
@echo "=========================================" @echo "========================================="
@echo "\nPlease choose an installation option:" @echo "Please choose an installation option:"
@echo "[1] Full Install" @echo "[1] Full Install"
@echo "[2] Manually Select Components" @echo "[2] Manually Select Components"
@echo "[3] Exit" @echo "[3] Exit"
@ -30,7 +30,7 @@ interactive:
full-install: full-install:
@clear @clear
@echo "\nStarting full installation..." @echo "Starting full installation..."
$(MAKE) dependencies $(MAKE) dependencies
@read -p "Is SpiriLink using 8812EU or 8812AU? Enter EU/AU: " driver; \ @read -p "Is SpiriLink using 8812EU or 8812AU? Enter EU/AU: " driver; \
if [ "$$driver" = "EU" ] || [ "$$driver" = "eu" ]; then \ if [ "$$driver" = "EU" ] || [ "$$driver" = "eu" ]; then \
@ -43,11 +43,11 @@ full-install:
$(MAKE) spirilink-software $(MAKE) spirilink-software
$(MAKE) configure-spirilink $(MAKE) configure-spirilink
$(MAKE) setup-webapp-service $(MAKE) setup-webapp-service
@echo "\nFull installation complete." @echo "Full installation complete."
manual-select: manual-select:
@clear @clear
@echo "\nPlease select the components to install:" @echo "Please select the components to install:"
@echo "[1] Basic Tools (nano, htop, etc.)" @echo "[1] Basic Tools (nano, htop, etc.)"
@echo "[2] MAVLink Router" @echo "[2] MAVLink Router"
@echo "[3] Python Dependencies" @echo "[3] Python Dependencies"
@ -70,7 +70,7 @@ manual-select:
done; done;
install: install:
@echo "\nStarting installation..." @echo "Starting installation..."
@echo "Installation complete." @echo "Installation complete."
# Install dependencies from the array # Install dependencies from the array
@ -83,7 +83,7 @@ dependencies:
echo "Installing $$pkg ($$count of $$total)..."; \ echo "Installing $$pkg ($$count of $$total)..."; \
$(SUDO) apt install -y $$pkg; \ $(SUDO) apt install -y $$pkg; \
done; done;
@echo "\nAll dependencies installed." @echo "All dependencies installed."
# Install SpiriLink driver # Install SpiriLink driver
.PHONY: spirilink-driver .PHONY: spirilink-driver
@ -102,13 +102,14 @@ spirilink-driver:
else \ else \
echo "Unknown driver type: $(DRIVER_TYPE). Skipping driver installation."; \ echo "Unknown driver type: $(DRIVER_TYPE). Skipping driver installation."; \
fi; fi;
@echo "\nSpiriLink driver installation complete." @echo "SpiriLink driver installation complete."
# Configure SpiriLink interface # Configure SpiriLink interface
.PHONY: configure-spirilink .PHONY: configure-spirilink
configure-spirilink: configure-spirilink:
@echo "Configuring SpiriLink interface as spir0..." @echo "\nConfiguring SpiriLink interface as spir0..."
spirilink_iface=$(shell lsusb | grep "0bda:a81a" | awk '{print $$2"/"$$4}' | sed 's/://'); \ # Detect SpiriLink interface by USB ID
spirilink_iface=$(shell ip link show | grep -B 1 "wlx" | head -n 1 | awk -F': ' '{print $$2}'); \
if [ -z "$$spirilink_iface" ]; then \ if [ -z "$$spirilink_iface" ]; then \
echo "Error: SpiriLink interface not detected."; \ echo "Error: SpiriLink interface not detected."; \
exit 1; \ exit 1; \
@ -129,7 +130,7 @@ configure-spirilink:
$(SUDO) systemctl restart NetworkManager $(SUDO) systemctl restart NetworkManager
@echo "Configuring wifibroadcast default interface..." @echo "Configuring wifibroadcast default interface..."
$(SUDO) bash -c 'echo "WFB_NICS=\"spir0\"" > /etc/default/wifibroadcast' $(SUDO) bash -c 'echo "WFB_NICS=\"spir0\"" > /etc/default/wifibroadcast'
@echo "SpiriLink configuration complete." @echo "\nSpiriLink configuration complete."
# Install SpiriLink software # Install SpiriLink software
.PHONY: spirilink-software .PHONY: spirilink-software
@ -153,7 +154,7 @@ spirilink-software:
# Set up web app service # Set up web app service
.PHONY: setup-webapp-service .PHONY: setup-webapp-service
setup-webapp-service: setup-webapp-service:
@echo "\nSetting up web app service..." @echo "Setting up web app service..."
@if [ -d ~/tmp/spiri-base ]; then \ @if [ -d ~/tmp/spiri-base ]; then \
cd ~/tmp/spiri-base && git pull; \ cd ~/tmp/spiri-base && git pull; \
else \ else \
@ -168,14 +169,14 @@ setup-webapp-service:
else \ else \
echo "Error: webapp.service not found in deployment folder."; \ echo "Error: webapp.service not found in deployment folder."; \
fi; fi;
@echo "\nWeb app service set up and running." @echo "Web app service set up and running."
# Uninstall all installed components # Uninstall all installed components
.PHONY: uninstall .PHONY: uninstall
uninstall: uninstall:
@echo "\nUninstalling all components..." @echo "Uninstalling all components..."
$(SUDO) apt remove -y $(DEPENDENCIES) $(SUDO) apt remove -y $(DEPENDENCIES)
$(SUDO) rm -rf ~/tmp/mavlink-router-source ~/tmp/8812eu.ko ~/tmp/8812au.ko ~/tmp/spirilink ~/tmp/spiri-base /var/www/webapp $(SUDO) rm -rf ~/tmp/mavlink-router-source ~/tmp/8812eu.ko ~/tmp/8812au.ko ~/tmp/spirilink ~/tmp/spiri-base /var/www/webapp
$(SUDO) systemctl disable webapp.service $(SUDO) systemctl disable webapp.service
$(SUDO) rm -f /etc/systemd/system/webapp.service $(SUDO) rm -f /etc/systemd/system/webapp.service
@echo "\nUninstallation complete." @echo "Uninstallation complete."