Configure full MQTT topics in the private INI
Use configured topics for commands, state, availability and Last Will. Replace shared installation prefixes with generic examples. Validate configuration before stopping an existing service; add tests for custom and invalid topics.
This commit is contained in:
1 parent
25cacd4894
commit
593f86e6dd
5 files changed
+167
-47
No files matched your search
+13
-5
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# Zorruno — MeshCore Phone App Mode v1.0 — 2026-10-03
|
||||
# Install on beaver; preserves an existing credentials file and leaves the
|
||||
# Zorruno — MeshCore Phone App Mode v1.1 — 2026-10-03
|
||||
# Install on the Docker host; preserves an existing credentials file and leaves the
|
||||
# service stopped until you have entered credentials and explicitly started it.
|
||||
set -euo pipefail
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
@@ -15,15 +15,23 @@ apt-get install -y python3-venv
|
||||
install -d -m 0755 /opt/meshcore-phone-mode
|
||||
python3 -m venv /opt/meshcore-phone-mode/venv
|
||||
/opt/meshcore-phone-mode/venv/bin/python -m pip install -r "$source_dir/requirements.txt"
|
||||
if [ ! -e /etc/meshcore-phone-mode.ini ]; then
|
||||
install -m 0600 "$source_dir/meshcore-phone-mode.ini.example" /etc/meshcore-phone-mode.ini
|
||||
fi
|
||||
# Validate with the new code before stopping or replacing an existing controller.
|
||||
python3 - "$source_dir/controller.py" <<'PY'
|
||||
import runpy
|
||||
import sys
|
||||
runpy.run_path(sys.argv[1])["load_config"]("/etc/meshcore-phone-mode.ini")
|
||||
PY
|
||||
if systemctl is-active --quiet meshcore-phone-mode.service; then
|
||||
systemctl stop meshcore-phone-mode.service
|
||||
fi
|
||||
install -m 0644 "$source_dir/controller.py" /opt/meshcore-phone-mode/controller.py
|
||||
install -m 0644 "$source_dir/requirements.txt" /opt/meshcore-phone-mode/requirements.txt
|
||||
if [ ! -e /etc/meshcore-phone-mode.ini ]; then
|
||||
install -m 0600 "$source_dir/meshcore-phone-mode.ini.example" /etc/meshcore-phone-mode.ini
|
||||
fi
|
||||
install -m 0644 "$source_dir/meshcore-phone-mode.service" /etc/systemd/system/meshcore-phone-mode.service
|
||||
systemctl daemon-reload
|
||||
echo 'Upgrading from 1.0? Add command_topic, state_topic and availability_topic under [mqtt].'
|
||||
echo 'Use your existing full topics to preserve the current Home Assistant switch.'
|
||||
echo 'Installed. Edit /etc/meshcore-phone-mode.ini locally, then run:'
|
||||
echo 'sudo systemctl enable --now meshcore-phone-mode.service'
|
||||
Reference in new issue
Block a user