add controls to lvx

This commit is contained in:
2026-04-27 06:50:04 -04:00
parent 00ab311d92
commit 04720c3b92
14 changed files with 856 additions and 39 deletions

View File

@@ -61,6 +61,7 @@ sudo install -m 755 "$TMP_RESOLVER" /usr/local/sbin/lvx-resolve-links
# --- 5. systemd units + drop-ins -------------------------------------------
msg "Installing systemd units"
sudo install -m 644 "${BASE}/etc/systemd/system/lvx-resolve-links.service" /etc/systemd/system/
sudo install -m 644 "${BASE}/etc/systemd/system/lvx-control.service" /etc/systemd/system/
sudo install -m 644 "${BASE}/etc/systemd/system/powermon.service" /etc/systemd/system/
sudo install -m 644 "${BASE}/etc/systemd/system/powermon2.service" /etc/systemd/system/
sudo mkdir -p /etc/systemd/system/powermon.service.d /etc/systemd/system/powermon2.service.d
@@ -70,6 +71,14 @@ sudo install -m 644 "${BASE}/etc/systemd/system/powermon2.service.d/10-resolver.
/etc/systemd/system/powermon2.service.d/10-resolver.conf
sudo systemctl daemon-reload
# --- 5b. lvx-control script (HA → powermon adhoc bridge) -------------------
msg "Installing /usr/local/bin/lvx-control (shebang → ${POWERMON_PY})"
TMP_CONTROL="$(mktemp)"
trap 'rm -f "$TMP_RESOLVER" "$TMP_CONTROL"' EXIT
awk -v py="${POWERMON_PY}" 'NR==1 { print "#!" py; next } { print }' \
"${BASE}/lvx-control/lvx-control" > "$TMP_CONTROL"
sudo install -m 755 "$TMP_CONTROL" /usr/local/bin/lvx-control
# --- 6. user configs (only if not already deployed; don't clobber creds) ---
msg "Installing powermon configs (skipping existing files — edit creds manually if new)"
mkdir -p "${HOME}/.config/powermon"
@@ -103,6 +112,12 @@ else
systemctl --no-pager status powermon.service powermon2.service | head -30
fi
# lvx-control reads broker creds from ~/.config/powermon/powermon.yaml, so it
# only needs to start once that file has real credentials.
if ! grep -q '<MQTT_PASSWORD>' "${HOME}/.config/powermon/powermon.yaml" 2>/dev/null; then
sudo systemctl enable --now lvx-control.service
fi
msg "Done"
echo "Next steps (if any of these don't match your hardware, edit and restart):"
echo " - /usr/local/sbin/lvx-resolve-links : SERIAL_UNIT_1 / SERIAL_UNIT_2"