fixed default network

This commit is contained in:
2026-06-29 10:34:02 +03:00
parent cdb731d837
commit 980608a279
12 changed files with 108 additions and 3 deletions
Binary file not shown.
+5
View File
@@ -61,6 +61,11 @@ device-install.sh, все скрипты уже в LF). Бинарник по у
Перед сборкой обновите `.\software\`: свежий `ButtonTask` (arm64) и актуальный
`webconfig\` из репозитория (OTA не трогает `/opt/buttontask/scripts/` — всё
должно попасть в бандл сразу).
PNG/JPG/SVG/GIF из `.\software\` и `.\software\icons\` попадут в
`/opt/buttontask/icons/`. Дефолтный конфиг уже содержит кнопку
`Вызов клининга` с иконкой `cleaner1Crop.png`.
Сеть: отредактируйте `.\software\config\network.json` перед сборкой
(по умолчанию `eth0` static `192.168.1.60/24`).
---
Binary file not shown.
+27
View File
@@ -63,6 +63,24 @@ else
warn "config.json нет ни на устройстве, ни в бандле — приложение создаст дефолтный при старте"
fi
# network — не перезатираем существующий
if [ -f "$ROOT/config/network.json" ]; then
log "network.json уже есть — оставляю как есть"
elif [ -f "$BUNDLE_DIR/config/network.json" ]; then
cp -a "$BUNDLE_DIR/config/network.json" "$ROOT/config/"
log "network.json установлен"
else
warn "network.json нет в бандле — eth0 останется на DHCP"
fi
# default/shared icons — не удаляем пользовательские иконки, только докладываем новые
if ls "$BUNDLE_DIR"/icons/* >/dev/null 2>&1; then
cp -an "$BUNDLE_DIR"/icons/. "$ROOT/icons/"
log "иконки установлены"
else
warn "иконок в бандле нет"
fi
# ---------------------------------------------------------------------------
# 4. Привилегированные хелперы + sudoers
# ---------------------------------------------------------------------------
@@ -148,5 +166,14 @@ systemctl enable buttontask buttontask-web buttontask-network >/dev/null 2>&1 ||
systemctl enable buttontask buttontask-web >/dev/null 2>&1 || \
die "не удалось включить сервисы (проверьте имена юнитов)"
# применить сеть сразу (не ждать ребута), если есть сохранённый профиль
if [ -f "$ROOT/config/network.json" ] && [ -x "$ROOT/scripts/bt-netconfig-boot" ]; then
if "$ROOT/scripts/bt-netconfig-boot"; then
log "сеть применена из network.json"
else
warn "не удалось применить network.json — проверьте nmcli и кабель"
fi
fi
log "версия $VER развёрнута"
echo "INSTALL-OK"
+41 -2
View File
@@ -56,7 +56,7 @@ foreach ($s in $needScripts) {
$stage = Join-Path $Here "stage-$Version"
if (Test-Path $stage) { Remove-Item -Recurse -Force $stage }
foreach ($d in 'app', 'debs', 'scripts', 'config', 'systemd') {
foreach ($d in 'app', 'debs', 'scripts', 'config', 'icons', 'systemd') {
New-Item -ItemType Directory -Force -Path (Join-Path $stage $d) | Out-Null
}
@@ -94,12 +94,51 @@ else {
"background": { "type": "gradient", "color1": "#00007b", "color2": "#7b007b", "animated": true, "imagePath": "" },
"feedback": { "okColor": "#00cc44", "errorColor": "#cc2200", "okWidth": 6, "errorWidth": 6, "glowRadius": 20 },
"settings": { "darkMode": true, "password": "admin", "kioskMode": false, "iconsDir": "/opt/buttontask/icons", "webPort": 8080 },
"buttons": []
"buttons": [
{
"id": "cleaning-call",
"label": "Вызов клининга",
"iconPath": "cleaner1Crop.png",
"action": { "type": "http_get", "url": "http://192.168.1.55", "headers": {}, "body": "" },
"feedback": { "successText": "Вызов отправлен", "errorText": "Ошибка", "pendingText": "...", "fadeMs": 5000 },
"trigger": { "mode": "hold", "holdMs": 800 },
"color": "#7b007b"
}
]
}
'@
Write-Bytes (Join-Path $stage 'config\config.json') ($default -replace "`r`n", "`n")
}
$netCfg = Join-Path $SoftwareDir 'config\network.json'
if (Test-Path $netCfg) {
Copy-Item $netCfg (Join-Path $stage 'config\network.json')
Log "network.json: $netCfg"
}
else {
Warn 'network.json не найден в .\software\config\ — сеть останется на DHCP'
}
$iconExts = '.png', '.jpg', '.jpeg', '.bmp', '.svg', '.gif'
$iconSources = @()
$iconSources += Get-ChildItem $SoftwareDir -File -ErrorAction SilentlyContinue |
Where-Object { $iconExts -contains $_.Extension.ToLowerInvariant() }
$iconsDir = Join-Path $SoftwareDir 'icons'
if (Test-Path $iconsDir) {
$iconSources += Get-ChildItem $iconsDir -File -ErrorAction SilentlyContinue |
Where-Object { $iconExts -contains $_.Extension.ToLowerInvariant() }
}
$iconSources = @($iconSources | Sort-Object FullName -Unique)
foreach ($ic in $iconSources) {
Copy-Item $ic.FullName (Join-Path $stage "icons\$($ic.Name)")
}
if ($iconSources.Count -gt 0) {
Log "иконок в бандле: $($iconSources.Count)"
}
else {
Warn "иконки в .\software или .\software\icons не найдены"
}
if ($MasterPassword) {
Write-Bytes (Join-Path $stage 'config\.master') $MasterPassword
Log 'мастер-пароль записан в бандл (config/.master)'
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

+22 -1
View File
@@ -28,6 +28,27 @@
"webPort": 8080
},
"buttons": [
{
"id": "cleaning-call",
"label": "Вызов клининга",
"iconPath": "cleaner1Crop.png",
"action": {
"type": "http_get",
"url": "http://192.168.1.55",
"headers": {},
"body": ""
},
"feedback": {
"successText": "Вызов отправлен",
"errorText": "Ошибка",
"pendingText": "...",
"fadeMs": 5000
},
"trigger": {
"mode": "hold",
"holdMs": 800
},
"color": "#7b007b"
}
]
}
@@ -0,0 +1,8 @@
{
"iface": "eth0",
"mode": "static",
"address": "192.168.1.60",
"prefix": 24,
"gateway": "192.168.1.1",
"dns": "192.168.1.1"
}
@@ -55,6 +55,7 @@ def api_add_button():
"feedback": {
"successText": data.get("successText", ""),
"errorText": data.get("errorText", "Ошибка"),
"pendingText": data.get("pendingText", "..."),
"fadeMs": int(data.get("fadeMs", 5000)),
},
"trigger": {
@@ -87,6 +88,7 @@ def api_update_button(bid):
feedback = b.setdefault("feedback", {})
feedback["successText"] = data.get("successText", feedback.get("successText", ""))
feedback["errorText"] = data.get("errorText", feedback.get("errorText", "Ошибка"))
feedback["pendingText"] = data.get("pendingText", feedback.get("pendingText", "..."))
feedback["fadeMs"] = int(data.get("fadeMs", feedback.get("fadeMs", 5000)))
trigger = b.setdefault("trigger", {})
if "triggerMode" in data:
@@ -177,6 +177,7 @@ function openDialogFor(btn) {
$("#b-url").value = btn?.action?.url || "";
$("#b-success").value = btn?.feedback?.successText || "";
$("#b-error").value = btn?.feedback?.errorText || "Ошибка";
$("#b-pending").value = btn?.feedback?.pendingText ?? "...";
$("#b-color").value = btn?.color || "#7b007b";
$("#b-trigger-mode").value = btn?.trigger?.mode || "hold";
$("#b-hold").value = btn?.trigger?.holdMs || 800;
@@ -218,6 +219,7 @@ form?.addEventListener("submit", async (e) => {
url: $("#b-url").value,
successText: $("#b-success").value,
errorText: $("#b-error").value,
pendingText: $("#b-pending").value || "...",
color: $("#b-color").value,
triggerMode: $("#b-trigger-mode").value,
holdMs: parseInt($("#b-hold").value, 10),
@@ -369,6 +369,7 @@
<label>URL <input type="text" id="b-url" required></label>
<label>Текст успеха <input type="text" id="b-success"></label>
<label>Текст ошибки <input type="text" id="b-error" value="Ошибка"></label>
<label>Текст ожидания <input type="text" id="b-pending" value="..."></label>
<label>Цвет кнопки <input type="color" id="b-color" value="#7b007b"></label>
<label>Срабатывание
<select id="b-trigger-mode">