From e1969303adc03fbf156cc43185894ec9923ec407 Mon Sep 17 00:00:00 2001 From: Moritz Ruth Date: Tue, 11 Apr 2023 00:47:47 +0200 Subject: [PATCH] Add Dockerfile and README.md --- Dockerfile | 11 +++++++++++ README.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 2 +- 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3391a7a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM clux/muslrust:stable as builder +WORKDIR /volume +COPY ./Cargo.toml ./Cargo.toml +COPY ./Cargo.lock ./Cargo.lock +COPY ./src ./src +RUN cargo build --release + +FROM alpine:latest +COPY --from=builder /volume/target/x86_64-unknown-linux-musl/release/hass-wol /app/hass-wol +VOLUME /data +CMD ["/app/hass-wol", "/config.toml", "/data"] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..49793c7 --- /dev/null +++ b/README.md @@ -0,0 +1,55 @@ +# hass-wol + +> Wake-on-LAN (WoL) for your Home Assistant + +## Usage + +This tool is intended to be used as a companion container to the Home Assistant container. + +Your `docker-compose.yml` may look like this: + +```yaml +version: "3.9" + +services: + homeassistant: + image: "homeassistant/home-assistant" + # ... + + hass-wol: + image: "git.moritzruth.de/moritzruth/hass-wol:1.0.0" + restart: unless-stopped + network_mode: host # this is required because WoL uses UDP broadcast packets + volumes: + - "./hass-wol.toml:/config.toml:ro" + - "./data:/data" # persistent data +``` + +And your `hass-wol.toml` like this: + +```toml +broadcast_address = "255.255.255.255" # don’t change this if you don’t need to + +[mqtt] +host = "MQTT_BROKER_IP_ADDRESS" +port = 1883 +client_id = "hass-wol" +credentials = { user = "USER", password = "PASSWORD" } + +[[host]] +display_name = "my_pc" +mac_address = "04:1B:BF:2D:C7:70" + +[[host]] +display_name = "my_server" +mac_address = "20:5D:48:98:94:C0" + +# These options are optional. +# hass_identifiers = [] # see https://www.home-assistant.io/integrations/button.mqtt/#identifiers +# packet_count = 6 +# ms_between_packets = 500 +``` + +## License + +hass-wol is licensed under the [Blue Oak Model License 1.0.0](./LICENSE.md). \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 25231f6..0a21925 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use std::collections::{HashMap, HashSet}; use std::env; -use std::net::{IpAddr, SocketAddr}; +use std::net::IpAddr; use std::path::{Path, PathBuf}; use std::process::exit; use std::str::FromStr;