2024-04-17 09:56:30 +03:00
|
|
|
# Install files and directories required by treatment (speaker driver software).
|
|
|
|
# This can also create a dhcpcd.enter-hook for setting the MAC address.
|
|
|
|
# MA and DK can be passed to Make if it is for a hard (first-time) installation:
|
|
|
|
# sudo MA=mac DK=dk make install_hard
|
|
|
|
# NB: The default (soft) install does not override conf files or set the MAC address.
|
2024-04-10 09:36:00 +03:00
|
|
|
# USR can also be passsed to customise user under which the code is housed.
|
|
|
|
USER := $(shell whoami)
|
|
|
|
PATH := /usr/local/go/bin:$(PATH)
|
2024-04-17 09:56:30 +03:00
|
|
|
BIN_NAME := treatment
|
2024-04-10 09:36:00 +03:00
|
|
|
BIN_DIR := /src/bitbucket.org/ausocean/av/cmd/$(BIN_NAME)
|
|
|
|
|
|
|
|
.SILENT:make_dirs
|
|
|
|
.SILENT:hard_copy_files
|
|
|
|
.SILENT:set_mac
|
|
|
|
.SILENT:clean
|
|
|
|
|
2024-04-17 09:56:30 +03:00
|
|
|
install: as_root make_dirs hard_copy_files rebuild syncreboot
|
2024-04-10 09:36:00 +03:00
|
|
|
@echo "Install complete"
|
|
|
|
|
2024-05-03 08:53:59 +03:00
|
|
|
install_no_rebuild: as_root make_dirs hard_copy_files syncreboot
|
|
|
|
@echo "Install complete"
|
|
|
|
|
2024-04-17 09:56:30 +03:00
|
|
|
install_set_mac: as_root make_dirs hard_copy_files set_mac rebuild syncreboot
|
|
|
|
@echo "Install complete, MAC address set to $(MA)"
|
2024-04-10 09:36:00 +03:00
|
|
|
|
|
|
|
as_root:
|
|
|
|
ifneq ($(USER),root)
|
|
|
|
$(error Must run as superuser!)
|
|
|
|
endif
|
|
|
|
|
2024-04-17 09:56:30 +03:00
|
|
|
rebuild:
|
|
|
|
@chmod +x treatment_run.sh
|
|
|
|
@go build
|
|
|
|
|
2024-04-10 09:36:00 +03:00
|
|
|
make_dirs:
|
2024-04-17 09:56:30 +03:00
|
|
|
@if [ ! -d /var/netsender ] ; then \
|
2024-04-10 09:36:00 +03:00
|
|
|
mkdir /var/netsender; \
|
|
|
|
chmod guo+rwx /var/netsender; \
|
|
|
|
fi
|
2024-04-17 09:56:30 +03:00
|
|
|
@if [ ! -d /var/log/netsender ] ; then \
|
2024-04-10 09:36:00 +03:00
|
|
|
mkdir /var/log/netsender; \
|
|
|
|
chmod guo+rwx /var/log/netsender; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
hard_copy_files:
|
2024-04-17 09:56:30 +03:00
|
|
|
ifeq ($(MA),)
|
|
|
|
$(error "Must provide MAC using MA=")
|
|
|
|
endif
|
|
|
|
ifeq ($(DK),)
|
|
|
|
$(error "Must provide device key using DK=")
|
|
|
|
endif
|
|
|
|
@if [ -f /etc/systemd/system/$(BIN_NAME).service ] ; then \
|
2024-04-10 09:36:00 +03:00
|
|
|
echo "/etc/systemd/system/$(BIN_NAME).service overwritten" ; \
|
|
|
|
fi
|
2024-04-17 09:56:30 +03:00
|
|
|
@cp -f $(BIN_NAME).service /etc/systemd/system
|
|
|
|
@systemctl enable $(BIN_NAME).service
|
|
|
|
@if [ -f /etc/netsender.conf ] ; then \
|
2024-04-10 09:36:00 +03:00
|
|
|
echo "Backed up netsender.conf to /etc/netsender.conf.bak"; \
|
|
|
|
cp /etc/netsender.conf /etc/netsender.conf.bak ; \
|
|
|
|
fi
|
2024-04-17 09:56:30 +03:00
|
|
|
@printf "ma $(MA)\ndk $(DK)\n" > /etc/netsender.conf
|
|
|
|
@chown $(USER) /etc/netsender.conf
|
2024-04-10 09:36:00 +03:00
|
|
|
|
|
|
|
set_mac:
|
2024-04-17 09:56:30 +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
|
2024-04-10 09:36:00 +03:00
|
|
|
|
|
|
|
syncreboot:
|
2024-04-17 09:56:30 +03:00
|
|
|
@if [ -e ../../../utils ]; then \
|
|
|
|
cd ../../../utils; git checkout -f master; git pull; \
|
2024-04-10 09:36:00 +03:00
|
|
|
else \
|
2024-04-17 09:56:30 +03:00
|
|
|
cd ../../../; git clone https://bitbucket.org/ausocean/utils; \
|
2024-04-10 09:36:00 +03:00
|
|
|
fi
|
2024-04-17 09:56:30 +03:00
|
|
|
@cd ../../../utils/cmd/syncreboot; make; make install
|
2024-04-10 09:36:00 +03:00
|
|
|
|
|
|
|
clean: as_root
|
|
|
|
rm -rf /var/netsender
|
|
|
|
rm -rf /var/log/netsender
|
|
|
|
rm -rf /etc/systemd/system/$(BIN_NAME).service
|
|
|
|
rm -rf /etc/netsender.conf
|
|
|
|
@echo "Clean complete"
|