ptth/docs/how-to/run-ptth-server.md

54 lines
1.6 KiB
Markdown

# How-to: Run `ptth_server`
Note: On Termux for Android you might run `umask 0022` first. Otherwise
`ptth_server` might accidentally make files world-unreadable when it opens
them, and PTTH refuses to serve world-unreadable files. 0022 is the default
on desktops, so this is probably an Android security thing. PTTH uses the
same permissions to protect its config file, so the two interfere.
## Without writing your own config file
(Ideal if you're running `ptth_server` autonomously from a script or something)
```
ptth_server \
--auto-gen-key \
--config-path ptth_server.toml \
--relay_url https://example.com/7ZSFUKGV \
--name my_server_name
```
ptth_server will:
- Try to use the API key from `ptth_server.toml`
- If that config file doesn't exist, create it, mark it as not readable to other
Unix users, and fill it with a random key
- Attempt to contact the `ptth_relay` instance with the base URL `https://example.com/7ZSFUKGV`
- Identify itself to that relay with the name `my_server_name` and the
random key
## With your own config file
(Ideal for long-lived instances)
```
mkdir config
touch config/ptth_server.toml
chmod 600 config/ptth_server.toml
dd if=/dev/urandom bs=64 count=1 | base64 >> config/ptth_server.toml
```
Open `config/ptth_server.toml` in your text editor.
There will be 64 bytes of random Base64 in the file already. Use that for the
`api_key` field. Fill out the other fields as desired:
```
name = "my_server_name"
relay_url = "https://example.com/7ZSFUKGV"
file_server_root = "/home/user/public"
api_key =
```
Then run `ptth_server` with no arguments.