plc-checkweigher 1.29.1 → 1.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -586,6 +586,30 @@ smb-config)
586
586
  prompt_smb_config
587
587
  ;;
588
588
 
589
+ # ─────────────────────────────────────────────────────────────────────────────
590
+ # CONSOLE-PASSWD — set / change the web maintenance terminal access code
591
+ # ─────────────────────────────────────────────────────────────────────────────
592
+ console-passwd)
593
+ banner "Maintenance Console Access Code"
594
+ echo ""
595
+ info "Required by the dashboard terminal (>_ button). Stored as SHA-256."
596
+ echo ""
597
+ mkdir -p "${DATA_DIR}" 2>/dev/null || true
598
+ while true; do
599
+ read -r -s -p " New access code: " _PW </dev/tty; echo ""
600
+ if [[ -z "$_PW" ]]; then err "Cannot be empty"; continue; fi
601
+ read -r -s -p " Confirm: " _PW2 </dev/tty; echo ""
602
+ [[ "$_PW" == "$_PW2" ]] && break
603
+ warn "Codes do not match — try again"
604
+ done
605
+ printf '%s' "$_PW" | sha256sum | cut -d' ' -f1 > "${DATA_DIR}/console_passwd"
606
+ chmod 600 "${DATA_DIR}/console_passwd" 2>/dev/null || true
607
+ echo ""
608
+ ok "Console access code updated — active immediately, no restart needed"
609
+ info "Existing browser sessions stay signed in until they expire (8 h)."
610
+ echo ""
611
+ ;;
612
+
589
613
  # ─────────────────────────────────────────────────────────────────────────────
590
614
  # FIX — auto-detect and repair common issues
591
615
  # Usage: fix [-wifi] [-health] [-programs] [-errors] (no flags = run all)
@@ -1450,6 +1474,16 @@ PYEOF
1450
1474
  ulog "CONFIG: journal OK"
1451
1475
  fi
1452
1476
 
1477
+ # 9a. Console password present (web terminal is fail-closed without it)
1478
+ spin_start "Console access code"
1479
+ if [[ -f "${DATA_DIR}/console_passwd" ]]; then
1480
+ spin_ok "Console access code set"
1481
+ ulog "CONFIG: console password OK"
1482
+ else
1483
+ spin_warn "Not set — web terminal locked. Run: plc_checkweigher console-passwd"
1484
+ ulog "WARN: console password not set"
1485
+ fi
1486
+
1453
1487
  # 9b. Web maintenance sudoers rule (dashboard terminal)
1454
1488
  spin_start "Web maintenance sudoers rule"
1455
1489
  _SUDOERS_F="/etc/sudoers.d/010_plc-web-fix"
@@ -1801,6 +1835,7 @@ help|--help|-h)
1801
1835
  echo ""
1802
1836
  echo -e " ${W}Configuration${NC}"
1803
1837
  echo " smb-config Interactively update SMB delivery target"
1838
+ echo " console-passwd Set/change web maintenance terminal access code"
1804
1839
  echo " push-test Push latest PDF to SMB target now"
1805
1840
  echo " update Pull latest code from GitHub and restart services"
1806
1841
  echo ""
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plc-checkweigher",
3
- "version": "1.29.1",
3
+ "version": "1.30.0",
4
4
  "description": "One-command installer for the PLC Check-Weigher system on Raspberry Pi (PREEMPT_RT kernel, Python stack, WiFi, SMB, systemd RT services)",
5
5
  "scripts": {
6
6
  "postinstall": "node bin/cli.js"
package/setup.sh CHANGED
@@ -277,6 +277,27 @@ setup_wifi() {
277
277
  fi
278
278
  }
279
279
 
280
+ # ── 6b. Web maintenance terminal access code ─────────────────────────────────
281
+ setup_console_passwd() {
282
+ step "Maintenance console access code ..."
283
+ echo " The dashboard's maintenance terminal (>_ button) requires an"
284
+ echo " access code. It is stored as a SHA-256 hash, never in plain text."
285
+ echo ""
286
+ local PW PW2
287
+ while true; do
288
+ read -r -s -p " Set console access code: " PW </dev/tty; echo ""
289
+ if [[ -z "$PW" ]]; then echo " Cannot be empty — try again."; continue; fi
290
+ read -r -s -p " Confirm access code: " PW2 </dev/tty; echo ""
291
+ [[ "$PW" == "$PW2" ]] && break
292
+ echo " Codes do not match — try again."
293
+ done
294
+ mkdir -p "${DATA_DIR}"
295
+ printf '%s' "$PW" | sha256sum | cut -d' ' -f1 > "${DATA_DIR}/console_passwd"
296
+ chown "${PI_USER}:${PI_USER}" "${DATA_DIR}/console_passwd"
297
+ chmod 600 "${DATA_DIR}/console_passwd"
298
+ ok "Console access code set (change later: plc_checkweigher console-passwd)"
299
+ }
300
+
280
301
  # ── 6. SMB file sharing — interactive ────────────────────────────────────────
281
302
  setup_smb() {
282
303
  step "SMB File Sharing Setup"
@@ -892,6 +913,7 @@ main() {
892
913
  install_cli # 5 — plc_checkweigher status command
893
914
  setup_wifi # 6 — interactive WiFi picker
894
915
  setup_smb # 7 — interactive SMB config → smb_config.py
916
+ setup_console_passwd # 7b — web maintenance terminal access code
895
917
  setup_network_online # 8
896
918
  install_services # 9
897
919
  setup_boot_logo # 10 — Plymouth: logo + "Sai Samarth Engineering"