2024-05-03 09:35:21 +03:00
|
|
|
# Install files and directories required by NetSender clients (such as gpio-netsender, rv, etc.).
|
|
|
|
# Optionally you can create a dhcpcd.enter-hook for setting the MAC address. (install_set_mac).
|
|
|
|
# MA and DK must be passed to Make for an installation:
|
|
|
|
# sudo make install MA=mac DK=dk
|
2022-05-31 08:17:06 +03:00
|
|
|
USER := $(shell whoami)
|
|
|
|
PATH := /usr/local/go/bin:$(PATH)
|
2022-06-07 09:58:38 +03:00
|
|
|
BIN_NAME := rv
|
|
|
|
BIN_DIR := /src/bitbucket.org/ausocean/av/cmd/$(BIN_NAME)
|
2022-06-06 14:16:14 +03:00
|
|
|
RUN_SCRIPT_DIR := /src/bitbucket.org/ausocean/av/init/run.sh
|
2023-02-08 12:02:56 +03:00
|
|
|
|
|
|
|
# Change this to withcv if you wish to use CV.
|
2023-05-29 08:49:05 +03:00
|
|
|
BUILD_TAG :=
|
2022-06-06 14:16:14 +03:00
|
|
|
|
2022-05-31 08:17:06 +03:00
|
|
|
.SILENT:make_dirs
|
|
|
|
.SILENT:hard_copy_files
|
|
|
|
.SILENT:set_mac
|
|
|
|
.SILENT:clean
|
|
|
|
|
2022-06-01 07:59:28 +03:00
|
|
|
rebuild:
|
2024-05-03 09:35:21 +03:00
|
|
|
@chmod +x run.sh
|
|
|
|
@cd ../cmd/$(BIN_NAME); \
|
2023-10-03 10:52:52 +03:00
|
|
|
if [ -z "$(BUILD_TAG)" ]; then \
|
|
|
|
go build; \
|
|
|
|
else \
|
|
|
|
go build -tags $(BUILD_TAG); \
|
|
|
|
fi
|
2022-05-31 08:17:06 +03:00
|
|
|
|
2024-05-03 09:35:21 +03:00
|
|
|
install: as_root make_dirs hard_copy_files rebuild syncreboot
|
2022-05-31 08:17:06 +03:00
|
|
|
@echo "Install complete"
|
|
|
|
|
2024-05-03 09:35:21 +03:00
|
|
|
install_no_rebuild: as_root make_dirs hard_copy_files syncreboot
|
|
|
|
@echo "Install complete"
|
2022-05-31 08:17:06 +03:00
|
|
|
|
2024-05-03 09:35:21 +03:00
|
|
|
install_set_mac: as_root make_dirs hard_copy_files set_mac rebuild syncreboot
|
|
|
|
@echo "Install complete, MAC address set to $(MA)"
|
2022-05-31 08:17:06 +03:00
|
|
|
|
|
|
|
as_root:
|
|
|
|
ifneq ($(USER),root)
|
|
|
|
$(error Must run as superuser!)
|
|
|
|
endif
|
|
|
|
|
|
|
|
make_dirs:
|
2024-05-03 09:35:21 +03:00
|
|
|
@if [ ! -d /var/netsender ] ; then \
|
2022-05-31 08:17:06 +03:00
|
|
|
mkdir /var/netsender; \
|
|
|
|
chmod guo+rwx /var/netsender; \
|
|
|
|
fi
|
2024-05-03 09:35:21 +03:00
|
|
|
@if [ ! -d /var/log/netsender ] ; then \
|
2022-05-31 08:17:06 +03:00
|
|
|
mkdir /var/log/netsender; \
|
|
|
|
chmod guo+rwx /var/log/netsender; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
hard_copy_files:
|
2024-05-03 09:35:21 +03:00
|
|
|
ifeq ($(MA),)
|
|
|
|
$(error "Must provide MAC using MA=")
|
|
|
|
endif
|
|
|
|
ifeq ($(DK),)
|
|
|
|
$(error "Must provide device key using DK=")
|
|
|
|
endif
|
2022-06-07 09:58:38 +03:00
|
|
|
if [ -f /etc/systemd/system/$(BIN_NAME).service ] ; then \
|
|
|
|
echo "/etc/systemd/system/$(BIN_NAME).service overwritten" ; \
|
2022-05-31 08:17:06 +03:00
|
|
|
fi
|
2022-06-06 14:16:14 +03:00
|
|
|
bash create_service.sh $(RUN_SCRIPT_DIR) $(BIN_DIR)
|
2024-05-03 09:35:21 +03:00
|
|
|
@systemctl enable $(BIN_NAME).service
|
|
|
|
@if [ -f /etc/netsender.conf ] ; then \
|
2022-05-31 08:17:06 +03:00
|
|
|
echo "Backed up netsender.conf to /etc/netsender.conf.bak"; \
|
|
|
|
cp /etc/netsender.conf /etc/netsender.conf.bak ; \
|
|
|
|
fi
|
2024-05-03 09:35:21 +03:00
|
|
|
@printf "ma $(MA)\ndk $(DK)\n" > /etc/netsender.conf
|
2022-06-06 14:16:14 +03:00
|
|
|
bash permissions.sh
|
2022-05-31 08:17:06 +03:00
|
|
|
|
|
|
|
set_mac:
|
2024-05-03 09:35:21 +03:00
|
|
|
ifeq ($(MA),)
|
|
|
|
$(error "Must provide MAC using MA=")
|
|
|
|
endif
|
|
|
|
@printf "ip link set eth0 address $(MA)\n" > /etc/dhcpcd.enter-hook
|
|
|
|
@chmod guo+x /etc/dhcpcd.enter-hook
|
2022-05-31 08:17:06 +03:00
|
|
|
|
2022-06-07 09:58:38 +03:00
|
|
|
syncreboot:
|
2024-05-03 09:35:21 +03:00
|
|
|
@if [ -e ../../utils ]; then \
|
2022-06-07 09:58:38 +03:00
|
|
|
cd ../../utils; git checkout -f master; git pull; \
|
|
|
|
else \
|
|
|
|
cd ../../; git clone https://bitbucket.org/ausocean/utils; \
|
|
|
|
fi
|
2024-05-03 09:35:21 +03:00
|
|
|
@cd ../../utils/cmd/syncreboot; make; make install
|
2022-06-07 09:58:38 +03:00
|
|
|
|
2022-05-31 08:17:06 +03:00
|
|
|
clean: as_root
|
|
|
|
rm -rf /var/netsender
|
|
|
|
rm -rf /var/log/netsender
|
2022-06-07 09:58:38 +03:00
|
|
|
rm -rf /etc/systemd/system/$(BIN_NAME).service
|
2022-05-31 08:17:06 +03:00
|
|
|
rm -rf /etc/netsender.conf
|
|
|
|
@echo "Clean complete"
|