diff --git a/init/Makefile b/init/Makefile index d0fe2b17..00ed95d0 100644 --- a/init/Makefile +++ b/init/Makefile @@ -3,6 +3,9 @@ # MA and DK can be optionally passed to Make, e.g, for a hard (first-time) installation: # sudo MA=mac DK=dk install_hard # NB: The default (soft) install does not override conf files. +# USR can also be passsed to customise user under which the code is housed. +# For example, if you're trying to make rv on your laptop instead of a pi, +# set USR=. USER := $(shell whoami) PATH := /usr/local/go/bin:$(PATH) ifeq ($(MA),) @@ -11,6 +14,9 @@ endif ifeq ($(DK),) DK := 0 endif +ifeq ($(USR),) + USR := "pi" +endif .SILENT:make_dirs .SILENT:soft_copy_files @@ -32,6 +38,8 @@ as_root: ifneq ($(USER),root) $(error Must run as superuser!) endif + sed -i 's/pi/$(USR)/' rv.service + sed -i 's/pi/$(USR)/' run.sh make_dirs: if [ ! -d /var/netsender ] ; then \ @@ -50,12 +58,12 @@ soft_copy_files: cp rv.service /etc/systemd/system; \ fi systemctl enable rv.service - chmod +x pi_run.sh + chmod +x run.sh if [ -f /etc/netsender.conf ] ; then \ echo "/etc/netsender.conf left unmodified" ; \ else \ printf "ma $(MA)\ndk $(DK)\n" > /etc/netsender.conf; \ - chown pi /etc/netsender.conf; \ + chown $(USR) /etc/netsender.conf; \ fi hard_copy_files: @@ -64,13 +72,13 @@ hard_copy_files: fi cp -f rv.service /etc/systemd/system systemctl enable rv.service - chmod +x pi_run.sh + chmod +x run.sh 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 printf "ma $(MA)\ndk $(DK)\n" > /etc/netsender.conf - chown pi /etc/netsender.conf + chown $(USR) /etc/netsender.conf hard_copy_files_treat: if [ -f /etc/systemd/system/treatment.service ] ; then \ @@ -84,7 +92,7 @@ hard_copy_files_treat: cp /etc/netsender.conf /etc/netsender.conf.bak ; \ fi printf "ma $(MA)\ndk $(DK)\n" > /etc/netsender.conf - chown pi /etc/netsender.conf + chown $(USR) /etc/netsender.conf set_mac: printf "ip link set eth0 address $(MA)\n" > /etc/dhcpcd.enter-hook diff --git a/init/pi_run.sh b/init/run.sh old mode 100644 new mode 100755 similarity index 100% rename from init/pi_run.sh rename to init/run.sh diff --git a/init/rv.service b/init/rv.service index 818bcc86..019c4490 100644 --- a/init/rv.service +++ b/init/rv.service @@ -3,8 +3,8 @@ Description=Netsender Client for Media Collection and Forwarding [Service] Type=simple -ExecStart=/home/pi/go/src/bitbucket.org/ausocean/av/init/pi_run.sh +ExecStart=/home/pi/go/src/bitbucket.org/ausocean/av/init/run.sh Restart=on-failure [Install] -WantedBy=multi-user.target \ No newline at end of file +WantedBy=multi-user.target