prompt user if files exist

This commit is contained in:
Alex 2024-10-20 21:47:16 -03:00
parent 014819d342
commit dd21835e84

106
Makefile
View File

@ -5,6 +5,7 @@
SHELL := /bin/bash SHELL := /bin/bash
SUDO := $(shell test $${EUID} -ne 0 && echo "sudo") SUDO := $(shell test $${EUID} -ne 0 && echo "sudo")
.EXPORT_ALL_VARIABLES: .EXPORT_ALL_VARIABLES:
CURDIR := $(shell pwd)
SYSCFG = /etc/mavlink-router SYSCFG = /etc/mavlink-router
CONFIG ?= /var/local CONFIG ?= /var/local
LIBSYSTEMD=/lib/systemd/system LIBSYSTEMD=/lib/systemd/system
@ -17,7 +18,6 @@ LOCAL_SCRIPTS=temperature.sh cockpitScript.sh
default: interactive install static set_network_manager_config configure_wifibroadcast default: interactive install static set_network_manager_config configure_wifibroadcast
# New interactive target
interactive: interactive:
@clear @clear
@echo " " @echo " "
@ -82,8 +82,8 @@ disable:
enable: enable:
@( for c in stop disable ; do $(SUDO) systemctl $${c} $(SERVICES) ; done ; true ) @( for c in stop disable ; do $(SUDO) systemctl $${c} $(SERVICES) ; done ; true )
@( for s in $(SERVICES) ; do $(SUDO) install -Dm644 $${s%.*}.service $(LIBSYSTEMD)/$${s%.*}.service ; done ; true ) @( for s in $(SERVICES) ; do $(SUDO) install -Dm644 $${s%.*}.service $(LIBSYSTEMD)/$${s%.*}.service ; done ; true )
@if [ ! -z "$(SERVICES)" ] ; then $(SUDO) systemctl daemon-reload ; fi @if [ ! -z "$(SERVICES)" ]; then $(SUDO) systemctl daemon-reload; fi
@( for s in $(SERVICES) ; do $(SUDO) systemctl enable $${s%.*} ; done ; true ) @( for s in $(SERVICES) ; do $(SUDO) systemctl enable $${s%.*}; done; true )
@echo "" @echo ""
@echo "Service is installed. To run now use sudo systemctl start mavlink-router and sudo systemctl start cockpit.socket" @echo "Service is installed. To run now use sudo systemctl start mavlink-router and sudo systemctl start cockpit.socket"
@echo "Inspect output with sudo journalctl -fu mavlink-router" @echo "Inspect output with sudo journalctl -fu mavlink-router"
@ -95,59 +95,109 @@ static:
install: verify_spir0 install: verify_spir0
# install helper apps # install helper apps
@$(SUDO) apt update $(SUDO) apt update
@$(SUDO) apt install -y nano nload htop picocom sshpass $(SUDO) apt install -y nano nload htop picocom sshpass
# install mavlink-router # install mavlink-router if not already installed
@rm -rf ~/tmp/mavlink-router-source @if [ -d ~/tmp/mavlink-router-source ]; then \
@git clone https://github.com/EchoMAV/mavlink-router-src ~/tmp/mavlink-router-source && \ read -p "Mavlink-router source already exists. Do you want to reinstall? (Y/N): " reinstall; \
if [ "$$reinstall" = "Y" ] || [ "$$reinstall" = "y" ]; then \
echo "Reinstalling Mavlink-router..."; \
cd ~/tmp/mavlink-router-source && git submodule update --init --recursive && \ cd ~/tmp/mavlink-router-source && git submodule update --init --recursive && \
$(SUDO) apt -y install git ninja-build pkg-config gcc g++ systemd && \ $(SUDO) apt -y install git ninja-build pkg-config gcc g++ systemd && \
$(SUDO) apt -y install python3-pip && \ $(SUDO) apt -y install python3-pip && \
$(SUDO) pip3 install meson smbus && \ $(SUDO) pip3 install meson smbus && \
meson setup build . && $(SUDO) ninja -C build install meson setup build . && $(SUDO) ninja -C build install; \
else \
echo "Skipping Mavlink-router installation."; \
fi; \
else \
rm -rf ~/tmp/mavlink-router-source && \
git clone https://github.com/EchoMAV/mavlink-router-src ~/tmp/mavlink-router-source && \
cd ~/tmp/mavlink-router-source && git submodule update --init --recursive && \
$(SUDO) apt -y install git ninja-build pkg-config gcc g++ systemd && \
$(SUDO) apt -y install python3-pip && \
$(SUDO) pip3 install meson smbus && \
meson setup build . && $(SUDO) ninja -C build install; \
fi
# install the config file # install the config file
@$(SUDO) mkdir -p $(SYSCFG) $(SUDO) mkdir -p $(SYSCFG)
@$(SUDO) cp main.conf $(SYSCFG)/. $(SUDO) cp main.conf $(SYSCFG)/.
# make ensure-cockpit.sh executable and run it # make ensure-cockpit.sh executable and run it
$(SUDO) chmod +x $(CURDIR)/ensure-cockpit.sh $(SUDO) chmod +x $(CURDIR)/ensure-cockpit.sh
@if [ -x "$(CURDIR)/ensure-cockpit.sh" ]; then \ if [ -x "$(CURDIR)/ensure-cockpit.sh" ]; then \
$(SUDO) $(CURDIR)/ensure-cockpit.sh; \ $(SUDO) $(CURDIR)/ensure-cockpit.sh; \
else \ else \
echo "Error: ensure-cockpit.sh not found or not executable"; \ echo "Error: ensure-cockpit.sh not found or not executable"; \
exit 1; \ exit 1; \
fi fi
# set up cockpit files # set up cockpit files if not already done
@$(SUDO) rm -rf /usr/share/cockpit/general/ @if [ ! -d /usr/share/cockpit/general ]; then \
@$(SUDO) mkdir /usr/share/cockpit/general/ $(SUDO) mkdir -p /usr/share/cockpit/general/ && \
@$(SUDO) cp -rf ui/general/* /usr/share/cockpit/general/ $(SUDO) cp -rf ui/general/* /usr/share/cockpit/general/; \
@$(SUDO) cp -rf ui/branding-ubuntu/* /usr/share/cockpit/branding/ubuntu/ fi
@$(SUDO) cp -rf ui/static/* /usr/share/cockpit/static/ @if [ ! -d /usr/share/cockpit/branding/ubuntu ]; then \
@$(SUDO) cp -rf ui/base1/* /usr/share/cockpit/base1/ $(SUDO) mkdir -p /usr/share/cockpit/branding/ubuntu && \
$(SUDO) cp -rf ui/branding-ubuntu/* /usr/share/cockpit/branding/ubuntu/; \
fi
$(SUDO) cp -rf ui/static/* /usr/share/cockpit/static/
$(SUDO) cp -rf ui/base1/* /usr/share/cockpit/base1/
@[ -d $(LOCAL)/echopilot ] || $(SUDO) mkdir $(LOCAL)/echopilot @[ -d $(LOCAL)/echopilot ] || $(SUDO) mkdir $(LOCAL)/echopilot
@for s in $(LOCAL_SCRIPTS); do $(SUDO) install -Dm755 $${s} $(LOCAL)/echopilot/$${s}; done @for s in $(LOCAL_SCRIPTS); do $(SUDO) install -Dm755 $${s} $(LOCAL)/echopilot/$${s}; done
# install modified 8812EU drivers # install modified 8812EU drivers if not already installed
@git clone https://github.com/libc0607/rtl88x2eu-20230815 ~/tmp/rtl88x2eu && \ @if [ -d ~/tmp/rtl88x2eu ]; then \
read -p "8812EU drivers source already exists. Do you want to reinstall? (Y/N): " reinstall; \
if [ "$$reinstall" = "Y" ] || [ "$$reinstall" = "y" ]; then \
echo "Reinstalling 8812EU drivers..."; \
cd ~/tmp/rtl88x2eu && git submodule update --init --recursive && \ cd ~/tmp/rtl88x2eu && git submodule update --init --recursive && \
$(SUDO) sed -i 's/CONFIG_PLATFORM_I386_PC = y/CONFIG_PLATFORM_I386_PC = n/g' Makefile && \ $(SUDO) sed -i 's/CONFIG_PLATFORM_I386_PC = y/CONFIG_PLATFORM_I386_PC = n/g' Makefile && \
$(SUDO) sed -i 's/CONFIG_PLATFORM_ARM64_RPI = n/CONFIG_PLATFORM_ARM64_RPI = y/g' Makefile && \ $(SUDO) sed -i 's/CONFIG_PLATFORM_ARM64_RPI = n/CONFIG_PLATFORM_ARM64_RPI = y/g' Makefile && \
$(SUDO) chmod +x ./dkms-install.sh && \
$(SUDO) apt -y install dkms && \ $(SUDO) apt -y install dkms && \
$(SUDO) ./dkms-install.sh $(SUDO) chmod +x ./dkms-install.sh && \
$(SUDO) ./dkms-install.sh; \
else \
echo "Skipping 8812EU drivers installation."; \
fi; \
else \
git clone https://github.com/libc0607/rtl88x2eu-20230815 ~/tmp/rtl88x2eu && \
cd ~/tmp/rtl88x2eu && git submodule update --init --recursive && \
$(SUDO) sed -i 's/CONFIG_PLATFORM_I386_PC = y/CONFIG_PLATFORM_I386_PC = n/g' Makefile && \
$(SUDO) sed -i 's/CONFIG_PLATFORM_ARM64_RPI = n/CONFIG_PLATFORM_ARM64_RPI = y/g' Makefile && \
$(SUDO) apt -y install dkms && \
$(SUDO) chmod +x ./dkms-install.sh && \
$(SUDO) ./dkms-install.sh; \
fi
# Install WFB-NG dependencies and compile deb # Install WFB-NG dependencies and compile deb if not already installed
@git clone -b stable https://github.com/svpcom/wfb-ng.git ~/tmp/wfb-ng && \ @if [ -d ~/tmp/wfb-ng ]; then \
read -p "WFB-NG source already exists. Do you want to reinstall? (Y/N): " reinstall; \
if [ "$$reinstall" = "Y" ] || [ "$$reinstall" = "y" ]; then \
echo "Reinstalling WFB-NG..."; \
cd ~/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) 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 && \ $(SUDO) make deb && \
$(SUDO) dpkg -i /deb_dist/wfb*.deb $(SUDO) dpkg -i /deb_dist/wfb*.deb; \
else \
echo "Skipping WFB-NG installation."; \
fi; \
else \
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 && \
$(SUDO) dpkg -i /deb_dist/wfb*.deb; \
fi
# create initial WFB-NG config file # create initial WFB-NG config file if not already exists
@$(SUDO) cp wifibroadcast.cfg /etc/ @if [ ! -f /etc/wifibroadcast.cfg ]; then \
$(SUDO) cp wifibroadcast.cfg /etc/; \
else \
echo "WFB-NG configuration already exists, skipping creation."; \
fi
# move drone encryption key to /etc/ # move drone encryption key to /etc/
@$(SUDO) cp drone.key /etc/ @$(SUDO) cp drone.key /etc/