summarylogtreecommitdiffstats
path: root/anki-sync-server.groff
blob: a953d7920327f3b33e35b52250fd2fd61291aac0 (plain)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
.ds server anki-sync-server
.ds server-dir /opt/anki-sync-server

.TH \*[server] 1 "January 23, 2022" "" "Post Installation Guide"

.SH NAME
.IP anki-sync-server

.SH SYNOPSIS
.
database
.RS
cd /opt/anki-sync-server &&
.br
sudo -u anki-sync-server ankisyncctl.py
.RE
.
server
.RS
cd /opt/anki-sync-server &&
.br
sudo -u anki-sync-server python -m ankisyncd
.RE
.
systemctl
.RS
systemctl <command> anki-sync-server
.RE
.
.YS

.SH POST INSTALLATION INSTRUCTIONS
.SS Adding a user
.PP
You'll need to go to:

.EX
    \*[server-dir]
.EE

and run:

.EX
    sudo -u \*[server] ./ankisyncctl.py adduser <username>
.EE

to add a new user to the \*[server] database.

.SS Plugin Installation
.PP
To have your anki client interface with the server, you'll need to copy the plugin
from \fI\*[server-dir]/plugins\fR to the relevant directory.

.ds anki-2.1.28 ~/.local/share/Anki2/addons21
.ds anki-2.1 ~/.local/share/Anki2/addons21
.ds anki-2 ~/Anki/addons
.ds anki-plugins \*[server-dir]/plugins

\fIAnki 2.1.28 (and up)\fR
.EX
    ln -s  \\
      \*[anki-plugins]/anki2.1.28/\*[server] \\
      \*[anki-2.1.28]/\*[server]
.EE

\fIAnki 2.1\fR
.EX
    ln -s  \\
      \*[anki-plugins]/anki2.1/\*[server] \\
      \*[anki-2.1]/\*[server]
.EE

\fIAnki 2.0\fR
.EX
    ln -s  \\
      \*[anki-plugins]/anki2.0/\*[server].py \\
      \*[anki-2]/\*[server].py
.EE

or your OS equivalent.

.SS Running The Server
.PP
The server should be set to auto start via \fIsystemctl\fR and should be already running.
See:

.EX
    systemctl status \*[server]
    systemctl status nginx
.EE

for details.

Otherwise, to run the server go to:

.EX
    \*[server-dir]/
.EE

then run:

.EX
    sudo -u \*[server] python -m ankisyncd
.EE

.B NOTE: if you run it as another user you may have to install the python dependencies again:

.EX
    pip install -r \*[server-dir]/requirements.txt [--user]
.EE

.B Be aware you may have trouble with permissions on your auth.db and
.B other files if you run as different users!

.SH NGINX
.PP
\fI/etc/nginx/nginx.conf\fR may have been modified. If the installation modifed
the \fInginx.conf\fR file, a backup has been saved to
\fI/etc/nginx/nginx.conf.pacsave\fR. It would be a good idea to to see if
anything has gone awry.

.SS Server Files
.
.PP
There are two servers included in \fI/etc/nginx/site-available\fR:

.RS
.IP \(bu 2
anki-sync-server-http
.IP \(bu
anki-sync-server-https
.RE

.SS Using The HTTPS Server

By default the HTTP server is enabled. The plugins for the anki client are
set to connect to the nginx server via HTTP.

You can turn on the nginx HTTPS server by symlinking the HTTPS server and
removing the HTTP server from \fI/etc/nginx/sites-enabled\fR.

.SS SSL Certificates
The HTTPS server requires two key files in order to work. You can generate
these keys by using a cert generator like \fImkcert\fR. The key needs to be
named the same thing as the ip address (or dns address) you will be connecting to
when you use the client.

.SS HTTPS Example Usage
.EX
If your server is running on \fI192.168.0.1\fR, then your keys should be
\fI<absolute-path>/192.168.0.1.pem\fR and \fI<absolute-path>/192.168.0.1-key.pem\fR.

Your client plugin will then need to be modified to connect to \fIhttps://192.168.0.1:27701\fR.
.EE

Lastly, you need to import the \fIrootCA.pem\fR (which is also generated by \fImkcert\fR) to your device that you are
using the anki client on.