From a67afb7e90997620256bb76445c6cbc67782d407 Mon Sep 17 00:00:00 2001 From: Moritz Ruth Date: Fri, 10 Mar 2023 00:13:26 +0100 Subject: [PATCH] Document installation and add systemd unit files --- README.md | 34 +++++++++++++++++++----- distrib/systemd/system/hassliebe.service | 11 ++++++++ distrib/systemd/user/hassliebe.service | 11 ++++++++ src/main.rs | 2 +- 4 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 distrib/systemd/system/hassliebe.service create mode 100644 distrib/systemd/user/hassliebe.service diff --git a/README.md b/README.md index 46210d2..7b5eb1e 100644 --- a/README.md +++ b/README.md @@ -18,16 +18,36 @@ Ideas: - Camera video stream - 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` -- `[config]`: `/etc/hassliebe/config.toml` / `$XDG_CONFIG_HOME/hassliebe/config.toml` +```sh +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 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. - `"default"` (default) — use the default value of the notification server - `"never"` — stay until manually dismissed - - `{ ms: [millseconds] }` — stay for `[milliseconds]` + - `{ "ms": [millseconds] }` — stay for `[milliseconds]` - `urgency` (optional) — One of: `"low"`, `"normal"` (default), `"critical"`. - `summary_text` — The primary text content, often used as title. Must not be empty. - `long_content` (optional) — Optional additional content diff --git a/distrib/systemd/system/hassliebe.service b/distrib/systemd/system/hassliebe.service new file mode 100644 index 0000000..d66a872 --- /dev/null +++ b/distrib/systemd/system/hassliebe.service @@ -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 \ No newline at end of file diff --git a/distrib/systemd/user/hassliebe.service b/distrib/systemd/user/hassliebe.service new file mode 100644 index 0000000..d37a6af --- /dev/null +++ b/distrib/systemd/user/hassliebe.service @@ -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 \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index bb896fb..843241c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -104,7 +104,7 @@ async fn main() -> Result<()> { 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!("See https://git.moritzruth.de/moritzruth/Hassliebe for more information."); + println!("See {} for more information.", env!("CARGO_PKG_HOMEPAGE")); exit(exitcode::OK); }