kosyncrs/README.md

49 lines
1.5 KiB
Markdown
Raw Normal View History

2023-09-26 21:27:35 +02:00
# KOreader Sync Server
2025-01-08 11:06:25 +01:00
This is a KOreader sync server, implemented in Rust. It uses the crates *axum*, *sqlx*, *serde* and *serde_json*.
2023-09-27 08:34:51 +02:00
## Requirements
2025-01-08 11:06:25 +01:00
- Rust toolchain for compilation
- A running PostgreSQL server
2023-09-27 08:34:51 +02:00
- Nginx (or Apache) webserver as a reverse proxy, since kosyncrs only listens locally and uses HTTP.
2023-09-26 22:03:52 +02:00
## Installation
2025-01-08 11:06:25 +01:00
Just compile it with `cargo build --release`. You can then copy the executable for example to `/usr/local/bin/`.
2023-09-26 22:24:00 +02:00
2025-01-08 11:06:25 +01:00
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.
You can also use nginx as a reverse proxy, so that the sync server listens on port 443. An example file is provided.
### 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
```
2025-01-08 12:59:57 +01:00
Connect to the database as user *kosync* (with psql) and create the database tables:
2025-01-08 11:06:25 +01:00
```sql
CREATE TABLE users (
id BIGSERIAL PRIMARY KEY,
2025-01-08 14:19:13 +01:00
username TEXT UNIQUE NOT NULL,
2025-01-08 11:06:25 +01:00
password TEXT
);
CREATE TABLE progresses (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT,
2025-01-08 14:19:13 +01:00
document TEXT NOT NULL,
2025-01-08 11:06:25 +01:00
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)
);
2025-01-08 14:19:13 +01:00
```