1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Create an SSH host entry for your Kindle in ~/.ssh/config and then set
# KINDLE_SSH_HOST to the name of the host
KINDLE_SSH_HOST ?= kindle
GOSOURCES = go.mod *.go
EXECUTABLE = build/kindleto/bin/kindleto
WEBDIR = build/kindleto/web
INITFILE = build/etc/init.d/kindleto-init
INITFILE0 = build/etc/rc0.d/K02kindleto
INITFILE5 = build/etc/rc5.d/S97kindleto
INITFILE6 = build/etc/rc6.d/K02kindleto
RSYNC_ARGS = --recursive --links --compress --progress
.PHONY: all
all: $(EXECUTABLE) $(WEBDIR) $(INITFILE) $(INITFILE0) $(INITFILE5) $(INITFILE6)
$(EXECUTABLE): $(GOSOURCES)
env GOOS=linux GOARCH=arm go build -o $@
$(WEBDIR):
mkdir -p $@
$(INITFILE): kindleto-init
mkdir -p $(@D)
cp kindleto-init $@
$(INITFILE0):
mkdir -p $(@D)
ln -s ../init.d/kindleto-init $@
$(INITFILE5):
mkdir -p $(@D)
ln -s ../init.d/kindleto-init $@
$(INITFILE6):
mkdir -p $(@D)
ln -s ../init.d/kindleto-init $@
.PHONY: install
install: all
rsync $(RSYNC_ARGS) 'build/kindleto' $(KINDLE_SSH_HOST):'/mnt/us/'
ssh $(KINDLE_SSH_HOST) 'if [ ! -f /mnt/us/kindleto/client-certs.json ]; then printf "[\n]\n" > /mnt/us/kindleto/client-certs.json; fi'
ssh $(KINDLE_SSH_HOST) '/usr/sbin/mntroot rw'
rsync $(RSYNC_ARGS) 'build/etc/' $(KINDLE_SSH_HOST):'/etc/'
ssh $(KINDLE_SSH_HOST) '/usr/sbin/mntroot ro'
.PHONY: uninstall
uninstall:
ssh $(KINDLE_SSH_HOST) 'rm -rf /mnt/us/kindleto && /usr/sbin/mntroot rw && rm -f /etc/init.d/kindleto /etc/rc0.d/K02kindleto /etc/rc5.d/S97kindleto /etc/rc6.d/K02kindleto /usr/local/bin/kindleto /test/bin/kindleto && /usr/sbin/mntroot ro'
.PHONY: autostart
autostart:
ssh $(KINDLE_SSH_HOST) 'touch /mnt/us/kindleto/auto'
.PHONY: restart
restart:
ssh $(KINDLE_SSH_HOST) '/etc/init.d/kindleto-init restart'
.PHONY: clean
clean:
rm -rf build