2020-03-23 13:22:12 +03:00
|
|
|
# Install files and directories required by NetSender clients (such as gpio-netsender, rv, etc.)
|
2019-03-06 02:45:06 +03:00
|
|
|
# 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:
|
2019-03-06 02:53:42 +03:00
|
|
|
# sudo MA=mac DK=dk install_hard
|
2019-03-06 02:45:06 +03:00
|
|
|
# NB: The default (soft) install does not override conf files.
|
2018-06-02 11:44:55 +03:00
|
|
|
USER := $(shell whoami)
|
2019-03-02 14:40:54 +03:00
|
|
|
PATH := /usr/local/go/bin:$(PATH)
|
2019-03-06 02:45:06 +03:00
|
|
|
ifeq ($(MA),)
|
|
|
|
MA := "00:E0:4C:00:00:01"
|
|
|
|
endif
|
|
|
|
ifeq ($(DK),)
|
2019-03-06 02:53:42 +03:00
|
|
|
DK := 0
|
2019-03-06 02:45:06 +03:00
|
|
|
endif
|
2018-06-02 11:44:55 +03:00
|
|
|
|
|
|
|
.SILENT:make_dirs
|
|
|
|
.SILENT:soft_copy_files
|
|
|
|
.SILENT:hard_copy_files
|
2019-03-06 02:45:06 +03:00
|
|
|
.SILENT:set_mac
|
2019-03-02 14:40:54 +03:00
|
|
|
.SILENT:syncreboot
|
2018-06-02 11:44:55 +03:00
|
|
|
.SILENT:clean
|
|
|
|
|
2020-03-23 13:22:12 +03:00
|
|
|
install: as_root make_dirs soft_copy_files
|
|
|
|
@echo "Install complete"
|
2018-06-02 11:44:55 +03:00
|
|
|
|
2019-03-06 02:45:06 +03:00
|
|
|
install_hard: as_root make_dirs hard_copy_files set_mac syncreboot
|
2020-03-23 13:22:12 +03:00
|
|
|
@echo "Hard install complete"
|
2018-06-02 11:44:55 +03:00
|
|
|
|
|
|
|
as_root:
|
|
|
|
ifneq ($(USER),root)
|
|
|
|
$(error Must run as superuser!)
|
|
|
|
endif
|
|
|
|
|
|
|
|
make_dirs:
|
|
|
|
if [ ! -d /var/netsender ] ; then \
|
|
|
|
mkdir /var/netsender; \
|
|
|
|
chmod guo+rwx /var/netsender; \
|
|
|
|
fi
|
|
|
|
if [ ! -d /var/log/netsender ] ; then \
|
|
|
|
mkdir /var/log/netsender; \
|
|
|
|
chmod guo+rwx /var/log/netsender; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
soft_copy_files:
|
2020-05-12 19:04:57 +03:00
|
|
|
if [ -f /etc/systemd/system/rv.service ] ; then \
|
|
|
|
echo "/etc/systemd/system/rv.service left unmodified" ; \
|
2018-06-02 11:44:55 +03:00
|
|
|
else \
|
2020-05-12 19:04:57 +03:00
|
|
|
cp rv.service /etc/systemd/system; \
|
2018-06-02 11:44:55 +03:00
|
|
|
fi
|
2020-05-12 19:04:57 +03:00
|
|
|
systemctl enable rv.service
|
|
|
|
chmod +x pi_run.sh
|
2018-06-02 11:44:55 +03:00
|
|
|
if [ -f /etc/netsender.conf ] ; then \
|
|
|
|
echo "/etc/netsender.conf left unmodified" ; \
|
|
|
|
else \
|
2019-03-06 02:45:06 +03:00
|
|
|
printf "ma $(MA)\ndk $(DK)\n" > /etc/netsender.conf; \
|
2019-03-02 14:40:54 +03:00
|
|
|
chown pi /etc/netsender.conf; \
|
2018-06-02 11:44:55 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
hard_copy_files:
|
2020-05-12 19:04:57 +03:00
|
|
|
if [ -f /etc/systemd/system/rv.service ] ; then \
|
|
|
|
echo "/etc/systemd/system/rv.service overwritten" ; \
|
2018-06-02 11:44:55 +03:00
|
|
|
fi
|
2020-05-16 17:33:34 +03:00
|
|
|
cp -f rv.service /etc/systemd/system
|
2020-05-12 19:04:57 +03:00
|
|
|
systemctl enable rv.service
|
|
|
|
chmod +x pi_run.sh
|
2018-06-02 11:44:55 +03:00
|
|
|
if [ -f /etc/netsender.conf ] ; then \
|
|
|
|
echo "Backed up netsender.conf to /etc/netsender.conf.bak"; \
|
|
|
|
cp /etc/netsender.conf /etc/netsender.conf.bak ; \
|
|
|
|
fi
|
2019-03-06 03:00:42 +03:00
|
|
|
printf "ma $(MA)\ndk $(DK)\n" > /etc/netsender.conf
|
2019-03-02 14:40:54 +03:00
|
|
|
chown pi /etc/netsender.conf
|
|
|
|
|
2019-03-06 02:45:06 +03:00
|
|
|
set_mac:
|
|
|
|
printf "ip link set eth0 address $(MA)\n" > /etc/dhcpcd.enter-hook
|
|
|
|
chmod guo+x /etc/dhcpcd.enter-hook
|
|
|
|
|
2019-03-02 14:40:54 +03:00
|
|
|
syncreboot:
|
|
|
|
cd ../../utils/cmd/syncreboot; make; make install
|
2018-06-02 11:44:55 +03:00
|
|
|
|
|
|
|
clean: as_root
|
|
|
|
rm -rf /var/netsender
|
|
|
|
rm -rf /var/log/netsender
|
2020-05-12 19:04:57 +03:00
|
|
|
rm -rf /etc/systemd/system/rv.service
|
2018-06-02 11:44:55 +03:00
|
|
|
rm -rf /etc/netsender.conf
|
2020-03-23 13:22:12 +03:00
|
|
|
@echo "Clean complete"
|