Merge remote-tracking branch 'origin/dev' into buildroot

This commit is contained in:
Yellowcooln
2026-04-23 20:28:19 -04:00
4 changed files with 1263 additions and 3 deletions

1148
buildroot-manage.sh Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,73 @@
{
"default_board": "luckfox-pimesh-v2",
"default_radio_preset": "USA/Canada (Recommended)",
"buildroot_hardware": {
"luckfox-pimesh-v2": {
"name": "Luckfox PiMesh V2",
"description": "Luckfox Pico Pi with PiMesh-1W V2 / E22P wiring",
"hardware_id": "pimesh-1w-v2",
"aliases": [
"1",
"v2",
"pimesh-v2",
"pimesh-1w-v2"
],
"sx1262_overrides": {
"cs_pin": -1,
"reset_pin": 54,
"busy_pin": 122,
"irq_pin": 121,
"en_pin": 0,
"txen_pin": -1,
"rxen_pin": -1,
"use_dio2_rf": true,
"use_dio3_tcxo": true,
"dio3_tcxo_voltage": 1.8
}
},
"luckfox-pimesh-v1": {
"name": "Luckfox PiMesh V1",
"description": "Luckfox Pico Pi with PiMesh-1W V1 wiring",
"hardware_id": "pimesh-1w-v1",
"aliases": [
"2",
"v1",
"pimesh-v1",
"pimesh-1w-v1"
],
"sx1262_overrides": {
"cs_pin": 145,
"reset_pin": 54,
"busy_pin": 123,
"irq_pin": 55,
"en_pin": -1,
"txen_pin": 52,
"rxen_pin": 53,
"use_dio2_rf": false,
"use_dio3_tcxo": true,
"dio3_tcxo_voltage": 1.8
}
},
"luckfox-meshadv": {
"name": "Luckfox MeshAdv",
"description": "Luckfox Pico Pi with MeshAdv wiring",
"hardware_id": "meshadv",
"aliases": [
"3",
"meshadv"
],
"sx1262_overrides": {
"cs_pin": 145,
"reset_pin": 54,
"busy_pin": 123,
"irq_pin": 55,
"en_pin": -1,
"txen_pin": 52,
"rxen_pin": 53,
"use_dio2_rf": false,
"use_dio3_tcxo": true,
"dio3_tcxo_voltage": 1.8
}
}
}
}

View File

@@ -4,22 +4,57 @@ Provides functions for service control operations like restart.
"""
import logging
import os
import subprocess
from typing import Tuple
logger = logging.getLogger("ServiceUtils")
INIT_SCRIPT = "/etc/init.d/S80pymc-repeater"
def is_buildroot() -> bool:
if os.path.exists("/etc/pymc-image-build-id"):
return True
if os.path.exists("/etc/os-release"):
try:
with open("/etc/os-release", "r", encoding="utf-8") as handle:
return any(line.strip() == "ID=buildroot" for line in handle)
except OSError:
return False
return False
def restart_service() -> Tuple[bool, str]:
"""
Restart the pymc-repeater service via systemctl.
Restart the pymc-repeater service.
Tries polkit-based restart first (plain systemctl), then falls back
to sudo-based restart (requires sudoers.d rule installed by manage.sh).
On Buildroot/Luckfox, use the shipped init script directly.
On systemd hosts, try polkit-based restart first (plain systemctl), then
fall back to sudo-based restart (requires sudoers.d rule installed by
manage.sh).
Returns:
Tuple[bool, str]: (success, message)
"""
if is_buildroot():
if not os.path.exists(INIT_SCRIPT):
logger.error("Buildroot init script not found: %s", INIT_SCRIPT)
return False, f"init script not found: {INIT_SCRIPT}"
try:
subprocess.Popen(
["/bin/sh", "-c", f"sleep 1; exec {INIT_SCRIPT} restart >/dev/null 2>&1"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
stdin=subprocess.DEVNULL,
start_new_session=True,
)
logger.info("Service restart scheduled via Buildroot init script")
return True, "Service restart initiated"
except Exception as exc:
logger.error(f"Buildroot restart failed: {exc}")
return False, f"Restart failed: {exc}"
# Try polkit-based restart first (works on bare metal / VMs with polkit running)
try:
result = subprocess.run(

View File

@@ -743,6 +743,10 @@ def _migrate_service_unit() -> None:
"""Strip legacy PYTHONPATH, fix WorkingDirectory, and ensure ExecStart
uses the venv python in the systemd service unit.
"""
if os.path.exists("/etc/pymc-image-build-id"):
logger.info("[Update] Buildroot image detected, skipping systemd unit migration.")
return
import subprocess as _sp
_SVC_UNIT = "/etc/systemd/system/pymc-repeater.service"
_VENV_PYTHON = "/opt/pymc_repeater/venv/bin/python"