Compare commits
No commits in common. "43b79f92f6ac936008c19f622dea4ecd51b68a87" and "f0af0ff4a7044766e0da488595b673ce97a0395d" have entirely different histories.
43b79f92f6
...
f0af0ff4a7
2 changed files with 7 additions and 42 deletions
48
README.md
48
README.md
|
@ -1,48 +1,14 @@
|
||||||
# KOreader Sync Server
|
# KOreader Sync Server
|
||||||
This is a KOreader sync server, implemented in Rust. It uses the crates *axum*, *sqlx*, *serde* and *serde_json*.
|
This is a KOreader sync server, implemented in Rust. It uses the crates *axum*, *redis*, *serde* and *serde_json*.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
- Rust toolchain for compilation
|
- Rust toolchain (≥ 1.63) for compilation
|
||||||
- A running PostgreSQL server
|
- A running Redis server
|
||||||
- Nginx (or Apache) webserver as a reverse proxy, since kosyncrs only listens locally and uses HTTP.
|
- Nginx (or Apache) webserver as a reverse proxy, since kosyncrs only listens locally and uses HTTP.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
Just compile it with `cargo build --release`. You can then copy the executable for example to `/usr/local/bin/`.
|
Just compile it with `cargo build --release`. You can then copy the executable for example to `/usr/local/bin/`. If you want to start the service automatically, you can adapt the example systemd file for your needs. You can also use nginx as a reverse proxy, so that the sync server listens on port 443.
|
||||||
|
|
||||||
If you want to start the service automatically, you can adapt the example systemd file for your needs. Please pay particularly attention to the PG_URL environment variable.You have to adjust the database username and password.
|
## Todo
|
||||||
|
- Test, if it really works, and if it works reliably. Feedback is very welcome!
|
||||||
You can also use nginx as a reverse proxy, so that the sync server listens on port 443. An example file is provided.
|
- Make it more configurable
|
||||||
|
|
||||||
### Database setup
|
|
||||||
First, create a new database user and set a password:
|
|
||||||
```
|
|
||||||
$ createuser -P kosync
|
|
||||||
```
|
|
||||||
|
|
||||||
Then, create a new database which is owned by the newly created user:
|
|
||||||
```
|
|
||||||
$ createdb -O kosync kosync
|
|
||||||
```
|
|
||||||
|
|
||||||
Connect to the database (with psql) and create the database tables:
|
|
||||||
```sql
|
|
||||||
CREATE TABLE users (
|
|
||||||
id BIGSERIAL PRIMARY KEY,
|
|
||||||
username TEXT NOT NULL,
|
|
||||||
password TEXT
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE progresses (
|
|
||||||
id BIGSERIAL PRIMARY KEY,
|
|
||||||
user_id BIGINT,
|
|
||||||
document TEXT UNIQUE NOT NULL,
|
|
||||||
progress TEXT NOT NULL,
|
|
||||||
percentage REAL NOT NULL,
|
|
||||||
device TEXT NOT NULL,
|
|
||||||
device_id TEXT NOT NULL,
|
|
||||||
timestamp BIGINT NOT NULL,
|
|
||||||
FOREIGN KEY (user_id)
|
|
||||||
REFERENCES users(id) ON DELETE CASCADE,
|
|
||||||
UNIQUE (user_id, document)
|
|
||||||
);
|
|
||||||
```
|
|
|
@ -11,7 +11,6 @@ User=myuser
|
||||||
Group=users
|
Group=users
|
||||||
WorkingDirectory=/home/myuser
|
WorkingDirectory=/home/myuser
|
||||||
ExecStart=/usr/local/bin/kosyncrs
|
ExecStart=/usr/local/bin/kosyncrs
|
||||||
Environment="PG_URL=postgresql://kosync:password@localhost/kosync"
|
|
||||||
Restart=always
|
Restart=always
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue