blob: 2fbc9bf37ef75e3cd90afeb1c113867bed41a6a8 (
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
|
post_install() {
# create user and set ownership
useradd -d /opt/anki-sync-server -r -s /sbin/nologin anki-sync-server
chown -R anki-sync-server /opt/anki-sync-server
chgrp -R anki-sync-server /opt/anki-sync-server
# link systemd service file
ln -s /opt/anki-sync-server/plugins/systemd/anki-sync-server.service /etc/systemd/system/
systemctl enable anki-sync-server
systemctl start anki-sync-server
# install prerequisites as stated on the website
echo "installing python packages as anki-sync-server user..."
sudo -u anki-sync-server pip install webob --user
sudo -u anki-sync-server pip install decorator --user
# post installation instructions
cat << EOF
=======================================================================
------------------
Post Installation:
------------------
You'll need to go to:
/opt/anki-sync-server
and run:
sudo -u anki-sync-server ./ankisyncctl.py adduser <username>
to add a new user to the anki database.
--------------------
Plugin Installation:
--------------------
To have anki interface with the server, you'll need to copy the plugin
from /opt/anki-sync-server/plugins to the relevant directory.
Anki 2.1: ~/.local/share/Anki2/addons21/
ln -s /opt/anki-sync-server/plugins/anki2.1/ankisyncd \\
~/.local/share/Anki2/addons21/
Anki 2.0: ~/Anki/addons
ln -s /opt/anki-sync-server/plugins/anki2.0/anki-sync-server.py \\
~/Anki/addons
or your OS equivalent.
---------------
Run The Server:
---------------
To just run the server, go to:
/opt/anki-sync-server/
then run:
sudo -u anki-sync-server python -m ankisyncd
if you run it as another user you may have to install some dependencies again:
sudo pacman -S python2-webob python2-decorator
or:
pip install --user webob decorator
=== (be aware you may have trouble with permissions on your auth.db if you run as different users!) ===
The server is set to auto start via systemctl.
See:
systemctl status anki-sync-server
for details.
------------------------
Run Bundled Anki Client:
------------------------
If you want to run the supplied anki client execute:
/opt/anki-sync-server/anki-bundled/runanki
You'll need to install the listed requirements to get it running first. You can run the file
sh install_anki_bundled.sh
to do that.
=======================================================================
EOF
}
post_remove(){
# stop service (and remove systemd files)
systemctl stop anki-sync-server
systemctl disable anki-sync-server
echo "Executing systemctl daemon-reload"
systemctl daemon-reload
# remove user (& group)
getent passwd anki-sync-server &>/dev/null && userdel anki-sync-server || true
getent group anki-sync-server &>/dev/null && groupdel anki-sync-server || true
echo "==================================================================="
echo "rm -rf /opt/anki-sync-server to remove the database and cache files"
echo "==================================================================="
}
pre_upgrade(){
sudo systemctl stop anki-sync-server.service
cd "/opt/anki-sync-server"
auth="auth.db"
coll="collections"
sess="session.db"
if [ -f "${auth}" ]; then
sudo mv -v "${auth}" "${auth}.BAK"
fi
if [ -d "${coll}" ]; then
sudo mv -v "${coll}" "${coll}.BAK"
fi
if [ -f "${sess}" ]; then
sudo mv -v "${sess}" "${sess}.BAK"
fi
}
post_upgrade(){
cd "/opt/anki-sync-server"
auth="auth.db"
coll="collections"
sess="session.db"
if [ -f "${auth}.BAK" ]; then
sudo mv -v "${auth}.BAK" "${auth}"
fi
if [ -d "${coll}.BAK" ]; then
sudo mv -v "${coll}.BAK" "${coll}"
fi
if [ -f "${sess}.BAK" ]; then
sudo mv -v "${sess}.BAK" "${sess}"
fi
sudo chown -R anki-sync-server /opt/anki-sync-server
sudo chgrp -R anki-sync-server /opt/anki-sync-server
sudo systemctl daemon-reload
sudo systemctl start anki-sync-server
}
|