in
Clone
0 watching0 forksRust528.7 KiBecfdd29Tahinli1 month ago17 commits
README.md
in
in is the family's file drive. It keeps folders and files, resumable uploads, previews and thumbnails, a
trash, sharing with people and by link, and per-person quotas. It also stores bytes for the other family
apps through a machine API. It is one binary, in, with the web UI, the API, the background workers and the
operator commands. Files are plain files in a blob tree, and in export writes them out as an ordinary folder
tree that needs no in to read.
in depends on im for sign-in (OpenID Connect) and the people directory. Once a person is signed in, their
files keep working while im is down. The shared contracts are in docs/contracts.md; the design is in
docs/architecture.md; the code rules are in docs/conventions.md.
Build
You need Rust stable (edition 2024). The stylesheet is compiled from style/ at build time, so there is no
Node step.
cargo build --release -p in-web # binary: target/release/in
cargo test --workspace
Install the binary and the unit:
sudo install -m 0755 target/release/in /usr/local/bin/in
sudo useradd --system --home-dir /var/lib/in --shell /usr/sbin/nologin in
sudo install -d -o in -g in -m 0700 /var/lib/in
sudo install -d -m 0755 /etc/in
sudo install -m 0644 deploy/in.service /etc/systemd/system/in.service
Do not enable the unit until the configuration and the im client below are in place.
Configuration
in reads --config <path>, then IN_CONFIG, then config/in.toml. A missing file is created from
config/in.example.toml on first run. Unknown keys are an error, so a typo fails at start-up.
The file holds no secrets. The OIDC client secret and the S3 keys are read from files that only the service user can read:
| Key | Meaning |
|---|---|
database, data_dir |
Database file and data directory (blobs, staging, in.key, in.lock). The data directory is created with mode 0700. |
listen |
Address to bind. Keep it on loopback and put the reverse proxy in front. |
base_url |
Public origin with no trailing slash. An https origin turns on Secure cookies and HSTS. |
trusted_proxies |
Proxies whose X-Forwarded-For is believed. |
[oidc] |
issuer (the im origin), client_id (in), client_secret_file. |
[storage] |
backend = "local" (default) or "s3" with [storage.s3]. |
[backup] |
Optional. dir, interval_hours, keep, healthcheck_url. See Backups. |
[limits] |
Optional defaults the admin page may override: quotas, purge days, upload size, link length. |
The admin page at /admin shows, next to each runtime value, whether it was set there, comes from the file, or
is the built-in default. A blank field on that page removes the page's value again.
First run
-
Start the server once to create the configuration and the instance key, then stop it:
IN_CONFIG=/etc/in/in.toml in serve -
Register
inas a client ofim(run on theimhost, where its data directory is). Replace<base>with the value ofbase_url:im client add --name in \ --redirect-uri "<base>/auth/callback" \ --post-logout-uri "<base>/" \ --backchannel-uri "<base>/auth/backchannel-logout" \ --family-key inimprints the client id and its secret once. Save the secret to the file named byclient_secret_file(/var/lib/in/oidc_client_secret, mode 0600, owned byin). The default scopes (openid profile email) are whatinneeds; the family'sdirectory.readscope is granted to every family client by default. -
Put the reverse proxy in front (see
deploy/ferron.kdl, an example for Ferron that proxieshttps://in.example.comto127.0.0.1:7655). Ferron must not buffer responses: the live update stream depends on it. -
Start the service:
sudo systemctl enable --now in curl -s http://127.0.0.1:7655/healthz # ok <build>The first person who signs in becomes a member. Administrators are the people
immarks as admins.
The service unit runs in serve as the in user with systemd hardening (read-only system, no capabilities,
a system-call filter). Its writable paths are the state directory and, when [backup] is set, the backup
directory, which you add to ReadWritePaths.
Backups
With [backup] set, in serve writes a backup set every interval_hours, keeps the newest keep sets, and
pings healthcheck_url after each good run (a failed ping is logged and nothing else).
A set is a directory set-<time> in dir, holding:
in.db: a consistent snapshot of the database (VACUUM INTO, checkpointed to one file).manifest.json: the snapshot's size and SHA-256, and every blob with its key, size and SHA-256.manifest.mac: an HMAC-SHA256 of the exact bytes ofmanifest.json, keyed with a subkey of the instance key (in.key, in the data directory). Anyone who can write to the backup directory can rewrite a set, but cannot make an edited manifest pass withoutin.key. Keepin.keywith the rest of the server's secrets, and back it up separately from the backup directory.
Blob bytes are not copied. Keep the blob tree (data_dir/blobs) under its own backup, or use an S3 bucket
with its own versioning. The manifest is what lets in fsck --hash and a restore check what should be there.
Restore
-
Stop the service.
in restorerefuses to run while the server holds the data-directory lock. -
Run the restore with the set you want:
in --config /etc/in/in.toml restore --from /var/lib/in/backups/set-2026-10-28T09-00-00-000000000ZIt checks the manifest's MAC against
in.keyfirst (a set without that key, or one that was edited, is refused), then the manifest format, the snapshot's size and hash, and the snapshot's integrity before it changes anything. A set that fails a check is refused and nothing is replaced. The database it replaces is moved todata_dir/restore-<time>/and is not deleted. -
Run
in fsckto see whether every row has its blob. Blobs listed in the manifest but missing from the blob tree are reported by the restore; they were deleted after the set was written. -
Start the service.
The database must lie inside data_dir. Restore does not replace anything outside it.
Command line
| Command | What it does |
|---|---|
in serve |
Runs the server. A bare in does the same. |
in export --member <sub or email> --out <dir> |
Copies one person's live files into <dir> as a folder tree with their names. Names are sanitized so nothing is written outside <dir>. Each file is hashed as it is copied and checked against its row. |
in fsck [--hash] |
Checks PRAGMA integrity_check, that every file, ready thumbnail and object has a blob of the recorded size, and with --hash the SHA-256 of every blob. Lists orphan blobs. Changes nothing. Exit status 1 when a problem is found. |
in restore --from <set> |
Replaces the database with the one in a backup set, after verification (see Restore). |
in quota recompute |
Recomputes every person's used bytes from their files and prints the ones that were wrong. |
The commands other than serve take the data-directory lock. While the server runs they stop with
in is running on this data directory. Stop the server first, then run the command again.
Layout
crates/in-core/ domain, store, migrations, config, settings, blobs, backup, export, fsck
crates/in-web/ the `in` binary: pages, sign-in, machine API, workers, CLI
deploy/ systemd unit and reverse-proxy example
docs/ contracts, architecture, conventions