summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorNaoaki Ueda <nao@uedder.com>2022-09-23 17:31:03 +0900
committerNaoaki Ueda <nao@uedder.com>2022-09-23 20:12:34 +0900
commit2156a3c597412631d9c84290aa12e8a855b5991a (patch)
tree50e79a24baa6e4aec2e3365c162b806bbd0f5292 /Makefile
downloadasustor-nas-tailscale-installer-2156a3c597412631d9c84290aa12e8a855b5991a.tar.gz
asustor-nas-tailscale-installer-2156a3c597412631d9c84290aa12e8a855b5991a.tar.bz2
asustor-nas-tailscale-installer-2156a3c597412631d9c84290aa12e8a855b5991a.zip
Initial commit
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile42
1 files changed, 42 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..7fab907
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,42 @@
+-include custom.mk
+
+.PHONY: help
+help:
+ @echo 'usage: make install ASUS_HOST=<your-nas-host>'
+ @echo '<your-nas-host> needs to be able to connect through rsync or ssh.'
+
+PREFIX_2_DIGIT ?= 55
+init_file = S$(PREFIX_2_DIGIT)tailscale
+
+.PHONY: install
+install: tailscaled tailscale install.sh | $(init_file)
+ $(if $(ASUS_HOST),,$(error ASUS_HOST variable is not defined))
+ @set -eu; \
+ remote_temp_dir=$$(ssh $(ASUS_HOST) -- mktemp -d); \
+ if [[ -z "$$remote_temp_dir" ]] ; then \
+ echo 'cannot create a temporary directory on `$(ASUS_HOST)`'; \
+ exit 1; \
+ fi; \
+ set -v; \
+ rsync -rltv $^ $(init_file) $(ASUS_HOST):$${remote_temp_dir}/; \
+ set +v; \
+ echo "warn: Don't forget exec \`$${remote_temp_dir}/install.sh $(init_file)\` on remote host to install"
+
+$(init_file): SXXtailscale.template
+ cp -a $< $@
+
+tailscale tailscaled: $$(tailscale.tgz)
+ tar --strip-components 1 -xmvzf $$< $(basename $$<)/$@
+
+$$(tailscale.tgz):
+ curl -L $(TGZ_URL) -O
+
+.PHONY: clean
+clean:
+ rm -f *.tgz $(init_file) tailscale tailscaled
+
+.SECONDEXPANSION:
+# default is latest
+VER ?= $(shell curl -s https://api.github.com/repos/tailscale/tailscale/releases/latest | perl -nle '/"name":\s*"(.+)"/ and print $$1')
+TGZ_URL = https://pkgs.tailscale.com/stable/tailscale_$(VER)_arm64.tgz
+tailscale.tgz = $(notdir $(TGZ_URL))