Alternative KOReader sync server. https://kosync.rustysoft.de
Find a file
2025-04-15 10:02:59 +02:00
nginx more documentation 2023-09-26 22:03:52 +02:00
python Migration Skript (Redis -> PostgreSQL) 2025-01-08 14:22:47 +01:00
src do not use UPSERT 2025-01-16 14:25:01 +01:00
systemd fix environment 2025-01-08 15:11:04 +01:00
.gitignore Initial commit 2023-09-25 15:12:47 +02:00
Cargo.lock cargo update 2025-01-16 14:34:21 +01:00
Cargo.toml 2024 edition 2025-02-21 08:49:44 +01:00
Containerfile RUN -> CMD 🤭 2025-04-15 10:02:59 +02:00
LICENSE LICENSE added 2025-01-15 09:56:42 +01:00
README.md Add instructions for Containerfile 2025-04-14 19:11:21 +02:00

KOReader Sync Server

This is a KOreader sync server, implemented in Rust. It uses the crates axum, sqlx, serde and serde_json.

Requirements

  • Rust toolchain for compilation
  • A running PostgreSQL server
  • Nginx (or Apache) webserver as a reverse proxy, since kosyncrs only listens locally and uses HTTP.

Installation

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. 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.

Container

To build the application for use with the Containerfile, you first have to add the musl-target: rustup target add x86_64-unknown-linux-musl

Then you can compile kosyncrs for it: cargo build --release --target=x86_64-unknown-linux-musl

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 as user kosync (for example with psql) and create the database tables:

CREATE TABLE users (
  id BIGSERIAL PRIMARY KEY,
  username TEXT UNIQUE NOT NULL,
  password TEXT
);

CREATE TABLE progresses (
  id BIGSERIAL PRIMARY KEY,
  user_id BIGINT NOT NULL,
  document TEXT 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)
);