Merged in fix-sync-reboot (pull request #481)

init/Makefile: adding target to build syncreboot. This no longer assumes the utils dir exists.

resolves issue #373

Approved-by: Trek Hopton
This commit is contained in:
Saxon Milton 2022-06-10 01:27:44 +00:00
commit af9ae527f4
1 changed files with 21 additions and 12 deletions

View File

@ -6,7 +6,8 @@
# USR can also be passsed to customise user under which the code is housed. # USR can also be passsed to customise user under which the code is housed.
USER := $(shell whoami) USER := $(shell whoami)
PATH := /usr/local/go/bin:$(PATH) PATH := /usr/local/go/bin:$(PATH)
BIN_DIR := /src/bitbucket.org/ausocean/av/cmd/rv BIN_NAME := rv
BIN_DIR := /src/bitbucket.org/ausocean/av/cmd/$(BIN_NAME)
RUN_SCRIPT_DIR := /src/bitbucket.org/ausocean/av/init/run.sh RUN_SCRIPT_DIR := /src/bitbucket.org/ausocean/av/init/run.sh
ifeq ($(MA),) ifeq ($(MA),)
@ -24,15 +25,15 @@ endif
rebuild: rebuild:
chmod +x run.sh chmod +x run.sh
cd ../cmd/rv; go build -tags nocv cd ../cmd/$(BIN_NAME); go build -tags nocv
install: as_root make_dirs soft_copy_files rebuild install: as_root make_dirs soft_copy_files rebuild syncreboot
@echo "Install complete" @echo "Install complete"
install_hard: as_root make_dirs hard_copy_files set_mac rebuild install_hard: as_root make_dirs hard_copy_files set_mac rebuild syncreboot
@echo "Hard install complete" @echo "Hard install complete"
install_hard_treat: as_root make_dirs hard_copy_files_treat set_mac install_hard_treat: as_root make_dirs hard_copy_files_treat set_mac syncreboot
@echo "Hard install complete" @echo "Hard install complete"
as_root: as_root:
@ -51,12 +52,12 @@ make_dirs:
fi fi
soft_copy_files: soft_copy_files:
if [ -f /etc/systemd/system/rv.service ] ; then \ if [ -f /etc/systemd/system/$(BIN_NAME).service ] ; then \
echo "/etc/systemd/system/rv.service left unmodified" ; \ echo "/etc/systemd/system/$(BIN_NAME).service left unmodified" ; \
else \ else \
bash create_service.sh $(RUN_SCRIPT_DIR) $(BIN_DIR); \ bash create_service.sh $(RUN_SCRIPT_DIR) $(BIN_DIR); \
fi fi
systemctl enable rv.service systemctl enable $(BIN_NAME).service
if [ -f /etc/netsender.conf ] ; then \ if [ -f /etc/netsender.conf ] ; then \
echo "/etc/netsender.conf left unmodified" ; \ echo "/etc/netsender.conf left unmodified" ; \
else \ else \
@ -65,11 +66,11 @@ soft_copy_files:
fi fi
hard_copy_files: hard_copy_files:
if [ -f /etc/systemd/system/rv.service ] ; then \ if [ -f /etc/systemd/system/$(BIN_NAME).service ] ; then \
echo "/etc/systemd/system/rv.service overwritten" ; \ echo "/etc/systemd/system/$(BIN_NAME).service overwritten" ; \
fi fi
bash create_service.sh $(RUN_SCRIPT_DIR) $(BIN_DIR) bash create_service.sh $(RUN_SCRIPT_DIR) $(BIN_DIR)
systemctl enable rv.service systemctl enable $(BIN_NAME).service
if [ -f /etc/netsender.conf ] ; then \ if [ -f /etc/netsender.conf ] ; then \
echo "Backed up netsender.conf to /etc/netsender.conf.bak"; \ echo "Backed up netsender.conf to /etc/netsender.conf.bak"; \
cp /etc/netsender.conf /etc/netsender.conf.bak ; \ cp /etc/netsender.conf /etc/netsender.conf.bak ; \
@ -95,9 +96,17 @@ set_mac:
printf "ip link set eth0 address $(MA)\n" > /etc/dhcpcd.enter-hook printf "ip link set eth0 address $(MA)\n" > /etc/dhcpcd.enter-hook
chmod guo+x /etc/dhcpcd.enter-hook chmod guo+x /etc/dhcpcd.enter-hook
syncreboot:
if [ -e ../../utils ]; then \
cd ../../utils; git checkout -f master; git pull; \
else \
cd ../../; git clone https://bitbucket.org/ausocean/utils; \
fi
cd ../../utils/cmd/syncreboot; make; make install
clean: as_root clean: as_root
rm -rf /var/netsender rm -rf /var/netsender
rm -rf /var/log/netsender rm -rf /var/log/netsender
rm -rf /etc/systemd/system/rv.service rm -rf /etc/systemd/system/$(BIN_NAME).service
rm -rf /etc/netsender.conf rm -rf /etc/netsender.conf
@echo "Clean complete" @echo "Clean complete"