Optionally supply MA and DK and create a dhcpcd.enter-hook.

This commit is contained in:
Alan Noble 2019-03-05 23:45:06 +00:00
parent 05c2c77f31
commit fcbeea6695
1 changed files with 20 additions and 6 deletions

View File

@ -1,18 +1,28 @@
# install files and directories required by NetSender clients (such as gpio-netsender, revid-cli, etc.) # Install files and directories required by NetSender clients (such as gpio-netsender, revid-cli, etc.)
# NB: the default (soft) install does not override conf files # and create a dhcpcd.enter-hook for setting the MAC address.
# MA and DK can be optionally passed to Make, e.g, for a hard (first-time) installation:
# sudo MA=mac DK=dk hard_install
# NB: The default (soft) install does not override conf files.
USER := $(shell whoami) USER := $(shell whoami)
PATH := /usr/local/go/bin:$(PATH) PATH := /usr/local/go/bin:$(PATH)
ifeq ($(MA),)
MA := "00:E0:4C:00:00:01"
endif
ifeq ($(DK),)
DK := 1
endif
.SILENT:make_dirs .SILENT:make_dirs
.SILENT:soft_copy_files .SILENT:soft_copy_files
.SILENT:hard_copy_files .SILENT:hard_copy_files
.SILENT:set_mac
.SILENT:syncreboot .SILENT:syncreboot
.SILENT:clean .SILENT:clean
install: as_root make_dirs soft_copy_files syncreboot install: as_root make_dirs soft_copy_files
@echo "Install complete" @echo "Install complete"
install_hard: as_root make_dirs hard_copy_files syncreboot install_hard: as_root make_dirs hard_copy_files set_mac syncreboot
@echo "Hard install complete" @echo "Hard install complete"
as_root: as_root:
@ -39,7 +49,7 @@ soft_copy_files:
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 \
cp netsender.conf /etc; \ printf "ma $(MA)\ndk $(DK)\n" > /etc/netsender.conf; \
chown pi /etc/netsender.conf; \ chown pi /etc/netsender.conf; \
fi fi
@ -53,9 +63,13 @@ hard_copy_files:
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 ; \
fi fi
cp -f netsender.conf /etc printf "ma $(MA)\ndk $(DK)\n" > /etc/netsender.conf; \
chown pi /etc/netsender.conf chown pi /etc/netsender.conf
set_mac:
printf "ip link set eth0 address $(MA)\n" > /etc/dhcpcd.enter-hook
chmod guo+x /etc/dhcpcd.enter-hook
syncreboot: syncreboot:
cd ../../utils/cmd/syncreboot; make; make install cd ../../utils/cmd/syncreboot; make; make install