# Vapor for Linux

Vapor is a self-hosted personal media server. The Linux release is a headless
server payload for `systemd`.

This archive contains:

- `vapord` - the server with the web client embedded
- `install.sh` - installs Vapor as a service
- `vapor.service` - the systemd unit installed by `install.sh`
- `README.md` - this file

## Install

Unpack the archive, then run:

```sh
sudo ./install.sh
```

The installer creates or uses the `vapor` service user and installs:

- `/opt/vapor/vapord`
- `/var/lib/vapor/library.db`
- `/etc/vapor/vapor.env`
- `/etc/systemd/system/vapor.service`

Check status and logs:

```sh
systemctl status vapor
journalctl -u vapor -f
```

Open Vapor on the server at:

```text
http://127.0.0.1:8770
```

## Ports And LAN Access

Vapor listens on loopback by default:

```text
127.0.0.1:8770
```

To expose Vapor on your LAN, edit `/etc/vapor/vapor.env`:

```sh
MEDIASERVER_ADDR=0.0.0.0:8770
```

Then restart:

```sh
sudo systemctl restart vapor
```

LAN and remote clients must pair from the local console before they can browse
or play.

## Add Your First Library

1. Open Vapor in a browser.
2. Choose **Add Library**.
3. Pick a mode such as Music, Movies, or TV.
4. Choose a local folder mounted on this Linux server, or add an SMB network
   share.
5. Click **Create & scan**.

Vapor scans read-only. It never renames, moves, edits, or deletes files in your
media folders.

For SMB, enter `smb://host/share` or `\\host\share` plus credentials in the Add
Library storage picker. Passwords are stored server-side and are never returned
to clients.

## Optional Reference Datasets

For richer local metadata, prepare the reference indexes beside
`/var/lib/vapor/library.db`:

```sh
sudo -u vapor /opt/vapor/vapord -db /var/lib/vapor/library.db -prepare-datasets all
sudo systemctl restart vapor
```

IMDb downloads public dataset files. Discogs and MusicBrainz use local dump
directories by default; set `MEDIASERVER_DATASET_DOWNLOAD=1` if you want Vapor
to download those large dumps itself.

## Updates

The server checks the release manifest once a day, verifies the payload's
sha256, and swaps `/opt/vapor/vapord` in place. The new version takes over on
the next restart, reboot, or crash recovery. The server never restarts itself
mid-stream.

Opt out with this line in `/etc/vapor/vapor.env`:

```sh
MEDIASERVER_NO_SELFUPDATE=1
```

## Server-Only Run

To run in the foreground without installing systemd:

```sh
./vapord -db ./library.db
```

Then open:

```text
http://127.0.0.1:8770
```

## Troubleshooting

Library unreachable:

Reconnect the disk, mount the NAS, or update SMB credentials, then use **Retry**
or rescan the library.

Logs:

```sh
journalctl -u vapor -f
```

Reset:

```sh
sudo systemctl stop vapor
sudo mv /var/lib/vapor /var/lib/vapor.backup
sudo systemctl start vapor
```

For a database-only reset, stop the service and remove
`/var/lib/vapor/library.db`. Media files are not modified.

## Uninstall

```sh
sudo systemctl disable --now vapor
sudo rm -rf /opt/vapor /etc/systemd/system/vapor.service
```

Keep or remove your library data separately:

```text
/var/lib/vapor
```
