From f1b1d5c880d419b991260826022ff5938727b359 Mon Sep 17 00:00:00 2001 From: Saxon Nelson-Milton Date: Tue, 7 Jun 2022 16:28:38 +0930 Subject: [PATCH] init/Makefile: adding target to build syncreboot. This no longer assumes the utils dir exists --- init/Makefile | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/init/Makefile b/init/Makefile index a0e2b86e..cd9386cf 100644 --- a/init/Makefile +++ b/init/Makefile @@ -6,7 +6,8 @@ # USR can also be passsed to customise user under which the code is housed. USER := $(shell whoami) 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 ifeq ($(MA),) @@ -24,15 +25,15 @@ endif rebuild: 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" -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" -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" as_root: @@ -51,12 +52,12 @@ make_dirs: fi soft_copy_files: - if [ -f /etc/systemd/system/rv.service ] ; then \ - echo "/etc/systemd/system/rv.service left unmodified" ; \ + if [ -f /etc/systemd/system/$(BIN_NAME).service ] ; then \ + echo "/etc/systemd/system/$(BIN_NAME).service left unmodified" ; \ else \ bash create_service.sh $(RUN_SCRIPT_DIR) $(BIN_DIR); \ fi - systemctl enable rv.service + systemctl enable $(BIN_NAME).service if [ -f /etc/netsender.conf ] ; then \ echo "/etc/netsender.conf left unmodified" ; \ else \ @@ -65,11 +66,11 @@ soft_copy_files: fi hard_copy_files: - if [ -f /etc/systemd/system/rv.service ] ; then \ - echo "/etc/systemd/system/rv.service overwritten" ; \ + if [ -f /etc/systemd/system/$(BIN_NAME).service ] ; then \ + echo "/etc/systemd/system/$(BIN_NAME).service overwritten" ; \ fi bash create_service.sh $(RUN_SCRIPT_DIR) $(BIN_DIR) - systemctl enable rv.service + systemctl enable $(BIN_NAME).service if [ -f /etc/netsender.conf ] ; then \ echo "Backed up netsender.conf to /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 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 rm -rf /var/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 @echo "Clean complete"