plc-checkweigher 1.29.1 → 1.31.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.31.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"
@@ -725,7 +746,51 @@ lock_source_files() {
725
746
  }
726
747
 
727
748
  # ── 12. RT kernel — installed LAST so only one reboot is needed ───────────────
728
- # ── 11d. System optimization disable everything not needed by the tool ─────
749
+ # ── 11d. Debloatpurge applications unused by the PLC stack ────────────────
750
+ # KEEP: chromium (kiosk display), code / VS Code (maintenance), NetworkManager,
751
+ # ssh, lightdm + compositor, rpi-connect, python3, git, nodejs, samba-client,
752
+ # plymouth, build-essential.
753
+ setup_debloat() {
754
+ step "Removing unused applications (dedicating resources to the tool) ..."
755
+ local _PURGE=(
756
+ firefox # kiosk uses chromium
757
+ chromium-l10n # browser locale packs — English UI only
758
+ vlc vlc-l10n # no media playback on the line
759
+ realvnc-vnc-server # Pi Connect (wayvnc) provides screen share
760
+ rpi-imager rpi-userguide rp-bookshelf piwiz
761
+ pocketsphinx-en-us # offline speech model
762
+ python3-mypy
763
+ thonny geany geany-common
764
+ firmware-atheros firmware-mediatek firmware-libertas # non-Pi WiFi chips
765
+ avahi-daemon
766
+ cups cups-daemon cups-browsed
767
+ bluez # BT radio already disabled at boot
768
+ wolfram-engine sonic-pi scratch scratch2 scratch3 minecraft-pi
769
+ claws-mail mu-editor smartsim sense-emu-tools
770
+ libreoffice-core libreoffice-common
771
+ )
772
+ local _TO_REMOVE=() _p
773
+ for _p in "${_PURGE[@]}"; do
774
+ dpkg -l "$_p" 2>/dev/null | grep -q "^ii" && _TO_REMOVE+=("$_p")
775
+ done
776
+ if [[ ${#_TO_REMOVE[@]} -gt 0 ]]; then
777
+ local _BEFORE
778
+ _BEFORE=$(df --output=avail / | tail -1)
779
+ DEBIAN_FRONTEND=noninteractive apt-get purge -y -qq "${_TO_REMOVE[@]}" \
780
+ > /tmp/debloat.log 2>&1 || warn "Some purges had warnings — see /tmp/debloat.log"
781
+ ok "Purged: ${_TO_REMOVE[*]}"
782
+ DEBIAN_FRONTEND=noninteractive apt-get autoremove --purge -y -qq \
783
+ >> /tmp/debloat.log 2>&1 || true
784
+ apt-get clean
785
+ local _AFTER
786
+ _AFTER=$(df --output=avail / | tail -1)
787
+ ok "Orphans removed, apt cache cleared — freed $(( (_AFTER - _BEFORE) / 1024 )) MB"
788
+ else
789
+ ok "No unused applications found"
790
+ fi
791
+ }
792
+
793
+ # ── 11e. System optimization — disable everything not needed by the tool ─────
729
794
  setup_system_optimize() {
730
795
  step "System optimization (disable non-essential services) ..."
731
796
 
@@ -892,13 +957,15 @@ main() {
892
957
  install_cli # 5 — plc_checkweigher status command
893
958
  setup_wifi # 6 — interactive WiFi picker
894
959
  setup_smb # 7 — interactive SMB config → smb_config.py
960
+ setup_console_passwd # 7b — web maintenance terminal access code
895
961
  setup_network_online # 8
896
962
  install_services # 9
897
963
  setup_boot_logo # 10 — Plymouth: logo + "Sai Samarth Engineering"
898
964
  setup_display # 11 — LightDM priority, CPU isolation, utmpx
899
965
  setup_vscode_priority # 11b — VS Code: cores 0-2, Nice=-5
900
966
  lock_source_files # 11c — root:root on .py, pi:pi on data/
901
- setup_system_optimize # 11d — disable bluetooth/avahi/cups/apt-timers
967
+ setup_debloat # 11d — purge unused applications (~800 MB+)
968
+ setup_system_optimize # 11e — disable bluetooth/avahi/cups/apt-timers
902
969
  install_rt_kernel # 12 — LAST, so only one reboot needed
903
970
  do_reboot # 12 — single reboot applies everything
904
971
  }