Document installation and add systemd unit files

This commit is contained in:
Moritz Ruth 2023-03-10 00:13:26 +01:00
parent a6e721009e
commit a67afb7e90
Signed by: moritzruth
GPG key ID: C9BBAB79405EE56D
4 changed files with 50 additions and 8 deletions

View file

@ -18,16 +18,36 @@ Ideas:
- Camera video stream - Camera video stream
- Idle time (→ libseat) - Idle time (→ libseat)
## Installation and configuration ## Installation
TBD ### As a systemd _system_ service
Hassliebe uses different paths depending on whether it is run as root or as a normal user: - Download [the latest binary](https://git.moritzruth.de/moritzruth/Hassliebe/releases) and put it into `/usr/bin`.
- Download [the unit file](distrib/systemd/system/hassliebe.service) and put it into `/etc/systemd/system`.
- Create the configuration file (see below) at `/etc/hassliebe/config.toml`.
- Enable and start the unit:
- `[data]`: `/var/lib/hassliebe` / `$XDG_DATA_HOME/hassliebe` ```sh
- `[config]`: `/etc/hassliebe/config.toml` / `$XDG_CONFIG_HOME/hassliebe/config.toml` systemctl enable hassliebe && systemctl start hassliebe
```
Example: ### As a systemd _user_ service
- Download [the latest binary](https://git.moritzruth.de/moritzruth/Hassliebe/releases) and put it into `~/.local/bin`.
- Download [the unit file](distrib/systemd/user/hassliebe.service) and put it into `~/.local/share/systemd/user`.
- Create the configuration file (see below) at `$XDG_CONFIG_HOME/hassliebe/config.toml`.
- Enable and start the unit:
```sh
systemctl --user enable hassliebe && systemctl --user start hassliebe
```
## Configuration
Depending on whether Hassliebe is run as root or as a regular user, the configuration is read from
`/etc/hassliebe/config.toml` or `$XDG_CONFIG_HOME/hassliebe/config.toml`.
### Example
```toml ```toml
friendly_id = "my_pc" # Used as prefix for MQTT topics and Home Assistant IDs friendly_id = "my_pc" # Used as prefix for MQTT topics and Home Assistant IDs
@ -124,7 +144,7 @@ Complex messages have these properties:
- `timeout` (optional) — Controls how long the notification will stay. - `timeout` (optional) — Controls how long the notification will stay.
- `"default"` (default) — use the default value of the notification server - `"default"` (default) — use the default value of the notification server
- `"never"` — stay until manually dismissed - `"never"` — stay until manually dismissed
- `{ ms: [millseconds] }` — stay for `[milliseconds]` - `{ "ms": [millseconds] }` — stay for `[milliseconds]`
- `urgency` (optional) — One of: `"low"`, `"normal"` (default), `"critical"`. - `urgency` (optional) — One of: `"low"`, `"normal"` (default), `"critical"`.
- `summary_text` — The primary text content, often used as title. Must not be empty. - `summary_text` — The primary text content, often used as title. Must not be empty.
- `long_content` (optional) — Optional additional content - `long_content` (optional) — Optional additional content

View file

@ -0,0 +1,11 @@
[Unit]
Description=Home Assistant integration daemon
Documentation=https://git.moritzruth.de/moritzruth/Hassliebe
[Service]
Type=simple
ExecStart=/usr/bin/hassliebe
Restart=on-failure
[Install]
WantedBy=default.target

View file

@ -0,0 +1,11 @@
[Unit]
Description=Home Assistant integration daemon
Documentation=https://git.moritzruth.de/moritzruth/Hassliebe
[Service]
Type=simple
ExecStart=%h/.local/bin/hassliebe
Restart=on-failure
[Install]
WantedBy=default.target

View file

@ -104,7 +104,7 @@ async fn main() -> Result<()> {
if env::args().any(|a| a == "-v" || a == "--version" || a == "-h" || a == "--help") { if env::args().any(|a| a == "-v" || a == "--version" || a == "-h" || a == "--help") {
println!("Hassliebe v{} is licensed under the Blue Oak Model License 1.0.0.", env!("CARGO_PKG_VERSION")); println!("Hassliebe v{} is licensed under the Blue Oak Model License 1.0.0.", env!("CARGO_PKG_VERSION"));
println!("See https://git.moritzruth.de/moritzruth/Hassliebe for more information."); println!("See {} for more information.", env!("CARGO_PKG_HOMEPAGE"));
exit(exitcode::OK); exit(exitcode::OK);
} }