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
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
.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:
@clear
@echo "\n========================================="
@echo "========================================="
@echo " SpiriBase Installer "
@echo "========================================="
@echo "\nPlease choose an installation option:"
@echo "Please choose an installation option:"
@echo "[1] Full Install"
@echo "[2] Manually Select Components"
@echo "[3] Exit"
@ -30,7 +30,7 @@ interactive:
full-install:
@clear
@echo "\nStarting full installation..."
@echo "Starting full installation..."
$(MAKE) dependencies
@read -p "Is SpiriLink using 8812EU or 8812AU? Enter EU/AU: " driver; \
if [ "$$driver" = "EU" ] || [ "$$driver" = "eu" ]; then \
@ -43,11 +43,11 @@ full-install:
$(MAKE) spirilink-software
$(MAKE) configure-spirilink
$(MAKE) setup-webapp-service
@echo "\nFull installation complete."
@echo "Full installation complete."
manual-select:
@clear
@echo "\nPlease select the components to install:"
@echo "Please select the components to install:"
@echo "[1] Basic Tools (nano, htop, etc.)"
@echo "[2] MAVLink Router"
@echo "[3] Python Dependencies"
@ -70,7 +70,7 @@ manual-select:
done;
install:
@echo "\nStarting installation..."
@echo "Starting installation..."
@echo "Installation complete."
# Install dependencies from the array
@ -83,7 +83,7 @@ dependencies:
echo "Installing $$pkg ($$count of $$total)..."; \
$(SUDO) apt install -y $$pkg; \
done;
@echo "\nAll dependencies installed."
@echo "All dependencies installed."
# Install SpiriLink driver
.PHONY: spirilink-driver
@ -102,13 +102,14 @@ spirilink-driver:
else \
echo "Unknown driver type: $(DRIVER_TYPE). Skipping driver installation."; \
fi;
@echo "\nSpiriLink driver installation complete."
@echo "SpiriLink driver installation complete."
# Configure SpiriLink interface
.PHONY: configure-spirilink
configure-spirilink:
@echo "Configuring SpiriLink interface as spir0..."
spirilink_iface=$(shell lsusb | grep "0bda:a81a" | awk '{print $$2"/"$$4}' | sed 's/://'); \
@echo "\nConfiguring SpiriLink interface as spir0..."
# 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 \
echo "Error: SpiriLink interface not detected."; \
exit 1; \
@ -129,7 +130,7 @@ configure-spirilink:
$(SUDO) systemctl restart NetworkManager
@echo "Configuring wifibroadcast default interface..."
$(SUDO) bash -c 'echo "WFB_NICS=\"spir0\"" > /etc/default/wifibroadcast'
@echo "SpiriLink configuration complete."
@echo "\nSpiriLink configuration complete."
# Install SpiriLink software
.PHONY: spirilink-software
@ -153,7 +154,7 @@ spirilink-software:
# Set up web app service
.PHONY: setup-webapp-service
setup-webapp-service:
@echo "\nSetting up web app service..."
@echo "Setting up web app service..."
@if [ -d ~/tmp/spiri-base ]; then \
cd ~/tmp/spiri-base && git pull; \
else \
@ -168,14 +169,14 @@ setup-webapp-service:
else \
echo "Error: webapp.service not found in deployment folder."; \
fi;
@echo "\nWeb app service set up and running."
@echo "Web app service set up and running."
# Uninstall all installed components
.PHONY: uninstall
uninstall:
@echo "\nUninstalling all components..."
@echo "Uninstalling all components..."
$(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) systemctl disable webapp.service
$(SUDO) rm -f /etc/systemd/system/webapp.service
@echo "\nUninstallation complete."
@echo "Uninstallation complete."