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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# SPDX-FileCopyrightText: 2021-2022 Sotiris Papatheodorou
# SPDX-License-Identifier: CC0-1.0
# 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
GOSRC != find * -name '*.go'
GOSRC += go.mod go.sum
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): $(GOSRC)
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: rsync
rsync: all
rsync $(RSYNC_ARGS) 'build/kindleto' $(KINDLE_SSH_HOST):'/mnt/us/'
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: install
install: rsync autostart
.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: manualstart
manualstart:
ssh $(KINDLE_SSH_HOST) 'rm -f /mnt/us/kindleto/auto'
.PHONY: start
start:
ssh $(KINDLE_SSH_HOST) '/etc/init.d/kindleto-init start'
.PHONY: stop
stop:
ssh $(KINDLE_SSH_HOST) '/etc/init.d/kindleto-init stop'
.PHONY: restart
restart:
ssh $(KINDLE_SSH_HOST) '/etc/init.d/kindleto-init restart'
.PHONY: clean
clean:
rm -rf build