-
Notifications
You must be signed in to change notification settings - Fork 15
/
install.sh
executable file
·81 lines (61 loc) · 1.99 KB
/
install.sh
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
#!/bin/bash
set -eu
check_go() {
if ! command -v go &> /dev/null; then
printf "\nGo could not be found, please install it first\n\n"
return 1
fi
export GOPATH=$HOME
export GOBIN=$GOPATH/bin
mkdir -p "$GOBIN"
}
compile_bin_files() {
printf "\ncompiling pocket2rm...\n"
cd "$INSTALL_SCRIPT_DIR/cmd/pocket2rm-setup"
go get
go build main.go
cd "$INSTALL_SCRIPT_DIR/cmd/pocket2rm"
go get
GOOS=linux GOARCH=arm GOARM=7 go build -o pocket2rm.arm
cd "$INSTALL_SCRIPT_DIR/cmd/pocket2rm-reload"
go get
GOOS=linux GOARCH=arm GOARM=7 go build -o pocket2rm-reload.arm
printf "pocket2rm successfully compiled"
printf "\n\n"
"$INSTALL_SCRIPT_DIR/cmd/pocket2rm-setup/main"
printf "\n"
}
copy_bin_files_to_remarkable() {
cd "$INSTALL_SCRIPT_DIR"
scp "$HOME/.pocket2rm" root@"$REMARKABLE_IP":/home/root/.
ssh root@"$REMARKABLE_IP" systemctl stop pocket2rm 2> /dev/null;
ssh root@"$REMARKABLE_IP" systemctl stop pocket2rm-reload 2> /dev/null;
scp cmd/pocket2rm/pocket2rm.arm root@"$REMARKABLE_IP":/home/root/.
scp cmd/pocket2rm-reload/pocket2rm-reload.arm root@"$REMARKABLE_IP":/home/root/.
}
copy_service_files_to_remarkable() {
cd "$INSTALL_SCRIPT_DIR"
scp cmd/pocket2rm/pocket2rm.service root@"$REMARKABLE_IP":/etc/systemd/system/.
scp cmd/pocket2rm-reload/pocket2rm-reload.service root@"$REMARKABLE_IP":/etc/systemd/system/.
}
register_and_run_service_on_remarkable() {
ssh root@"$REMARKABLE_IP" systemctl enable pocket2rm-reload
ssh root@"$REMARKABLE_IP" systemctl start pocket2rm-reload
}
INSTALL_SCRIPT_DIR=""
REMARKABLE_IP=""
main() {
INSTALL_SCRIPT_DIR=$(pwd)
printf "\n"
read -r -p "Enter your Remarkable IP address [10.11.99.1]: " REMARKABLE_IP
REMARKABLE_IP=${REMARKABLE_IP:-10.11.99.1}
if [ ! -f "$HOME/.pocket2rm" ]; then
check_go
compile_bin_files
copy_bin_files_to_remarkable
fi
copy_service_files_to_remarkable
register_and_run_service_on_remarkable
printf "\npocket2rm successfully installed on your Remarkable\n"
}
main