plc-checkweigher 1.22.0 → 1.24.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.
@@ -1134,6 +1134,13 @@ update)
1134
1134
  echo ""
1135
1135
  need_sudo
1136
1136
 
1137
+ # ── Update report log (pushed to SMB at the end) ──────────────────────────
1138
+ ULOG_DIR="/home/pi/reports/logs"
1139
+ mkdir -p "$ULOG_DIR" 2>/dev/null || true
1140
+ ULOG="${ULOG_DIR}/update_$(date '+%Y%m%d_%H%M%S').log"
1141
+ ulog() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" >> "$ULOG"; }
1142
+ ulog "=== Update started ==="
1143
+
1137
1144
  # ── Warn if a batch is actively running ───────────────────────────────────
1138
1145
  _IS_RUNNING=0
1139
1146
  if [[ -f "/tmp/plc_live.json" ]]; then
@@ -1187,6 +1194,7 @@ update)
1187
1194
  exit 0
1188
1195
  fi
1189
1196
  spin_ok "Pulled ${_PREV_SHORT} → ${_NEW_SHORT}"
1197
+ ulog "GIT: pulled ${_PREV_SHORT} -> ${_NEW_SHORT}"
1190
1198
 
1191
1199
  # ── Show what changed ─────────────────────────────────────────────────────
1192
1200
  echo ""
@@ -1216,6 +1224,11 @@ update)
1216
1224
  else
1217
1225
  spin_warn "CLI install failed — still running previous version until next install"
1218
1226
  fi
1227
+ # Also sync ~/.local/bin/ if a copy exists there (it takes PATH priority)
1228
+ _LOCAL_CLI="/home/pi/.local/bin/plc_checkweigher"
1229
+ if [[ -f "$_LOCAL_CLI" ]]; then
1230
+ cp "${INSTALL_DIR}/bin/plc_checkweigher" "$_LOCAL_CLI" 2>/dev/null || true
1231
+ fi
1219
1232
 
1220
1233
  # ── Update systemd unit files if they changed ─────────────────────────────
1221
1234
  _UNITS_UPDATED=0
@@ -1233,6 +1246,168 @@ update)
1233
1246
  spin_ok "systemd reloaded"
1234
1247
  fi
1235
1248
 
1249
+ # ── Update Plymouth boot splash ───────────────────────────────────────────
1250
+ _THEME_DIR="/usr/share/plymouth/themes/saismruth"
1251
+ _LOGO_SRC="${INSTALL_DIR}/assets/logo.png"
1252
+ _PLY_CHANGED=0
1253
+
1254
+ if [[ -f "$_LOGO_SRC" ]] && [[ -d "$_THEME_DIR" ]]; then
1255
+ spin_start "Updating boot splash"
1256
+ # Regenerate logo + pre-rendered text (idempotent)
1257
+ "${PYTHON}" - << 'PYEOF' 2>/dev/null && _PLY_CHANGED=1 || true
1258
+ from PIL import Image, ImageDraw, ImageFont
1259
+ import os, hashlib
1260
+
1261
+ THEME = "/usr/share/plymouth/themes/saismruth"
1262
+ LOGO = os.path.join(os.path.dirname(os.path.abspath(
1263
+ "/home/pi/plc_checkweigher/assets/logo.png")), "..", "assets", "logo.png")
1264
+ LOGO = "/home/pi/plc_checkweigher/assets/logo.png"
1265
+ TEXT = "Sai Samarth Engineering"
1266
+
1267
+ changed = False
1268
+
1269
+ # Logo 400x400
1270
+ img = Image.open(LOGO).convert("RGBA").resize((400, 400), Image.LANCZOS)
1271
+ logo_dst = os.path.join(THEME, "logo.png")
1272
+ import io; buf = io.BytesIO(); img.save(buf, "PNG"); new_bytes = buf.getvalue()
1273
+ old_bytes = open(logo_dst, "rb").read() if os.path.exists(logo_dst) else b""
1274
+ if new_bytes != old_bytes:
1275
+ open(logo_dst, "wb").write(new_bytes); changed = True
1276
+
1277
+ # Pre-rendered text
1278
+ FONTS = ["/usr/share/fonts/truetype/freefont/FreeSansBold.ttf",
1279
+ "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf"]
1280
+ font = next((ImageFont.truetype(f, 30) for f in FONTS if os.path.exists(f)), ImageFont.load_default())
1281
+ bbox = font.getbbox(TEXT); pad = 10
1282
+ tw, th = bbox[2]-bbox[0], bbox[3]-bbox[1]
1283
+ canvas = Image.new("RGBA", (tw+pad*2, th+pad*2), (0,0,0,0))
1284
+ ImageDraw.Draw(canvas).text((pad-bbox[0], pad-bbox[1]), TEXT, fill=(255,255,255,255), font=font)
1285
+ text_dst = os.path.join(THEME, "text.png")
1286
+ buf2 = io.BytesIO(); canvas.save(buf2, "PNG"); new2 = buf2.getvalue()
1287
+ old2 = open(text_dst, "rb").read() if os.path.exists(text_dst) else b""
1288
+ if new2 != old2:
1289
+ open(text_dst, "wb").write(new2); changed = True
1290
+
1291
+ import sys; sys.exit(0 if changed else 99)
1292
+ PYEOF
1293
+ _PLY_PY_EXIT=$?
1294
+ [[ $_PLY_PY_EXIT -eq 99 ]] && _PLY_CHANGED=0 # exit 99 = no change
1295
+
1296
+ # Patch boot cmdline once (idempotent)
1297
+ _CMDLINE="/boot/firmware/cmdline.txt"
1298
+ if [[ -f "$_CMDLINE" ]]; then
1299
+ if ! grep -q "logo.nologo" "$_CMDLINE"; then
1300
+ sudo sed -i 's/$/ logo.nologo/' "$_CMDLINE" 2>/dev/null && _PLY_CHANGED=1
1301
+ fi
1302
+ if grep -q "loglevel=3" "$_CMDLINE"; then
1303
+ sudo sed -i 's/loglevel=3/loglevel=1/' "$_CMDLINE" 2>/dev/null && _PLY_CHANGED=1
1304
+ fi
1305
+ fi
1306
+ if ! grep -q "^disable_splash=1" /boot/firmware/config.txt 2>/dev/null; then
1307
+ echo "disable_splash=1" | sudo tee -a /boot/firmware/config.txt >/dev/null && _PLY_CHANGED=1
1308
+ fi
1309
+
1310
+ if [[ $_PLY_CHANGED -eq 1 ]]; then
1311
+ spin_ok "Boot splash updated — rebuilding initramfs (~30 s)"
1312
+ # Rebuild for the RUNNING kernel (plain -u may pick a different one)
1313
+ _KVER="$(uname -r)"
1314
+ sudo update-initramfs -u -k "${_KVER}" > /tmp/update_initramfs.log 2>&1 \
1315
+ && ok "initramfs rebuilt for ${_KVER}" \
1316
+ || warn "initramfs warnings — see /tmp/update_initramfs.log"
1317
+ # Sync to the firmware partition — this is what actually boots
1318
+ if [[ -f "/boot/initrd.img-${_KVER}" ]] \
1319
+ && grep -q "initramfs initramfs8-rt" /boot/firmware/config.txt 2>/dev/null; then
1320
+ sudo cp "/boot/initrd.img-${_KVER}" /boot/firmware/initramfs8-rt \
1321
+ && ok "initramfs8-rt synced — reboot to apply splash" \
1322
+ || warn "Could not sync initramfs8-rt"
1323
+ fi
1324
+ ulog "SPLASH: regenerated, initramfs rebuilt + synced (${_KVER})"
1325
+ else
1326
+ spin_ok "Boot splash already up to date"
1327
+ ulog "SPLASH: up to date"
1328
+ fi
1329
+ fi
1330
+
1331
+ # ── Verify crucial system configuration ───────────────────────────────────
1332
+ echo ""
1333
+ echo -e " ${B}▸ System Configuration Check${NC}"; hr; echo ""
1334
+
1335
+ # 1. RT kernel active in config.txt
1336
+ spin_start "RT kernel boot config"
1337
+ if grep -q "^kernel=kernel8-rt.img" /boot/firmware/config.txt 2>/dev/null \
1338
+ && grep -q "^initramfs initramfs8-rt" /boot/firmware/config.txt 2>/dev/null; then
1339
+ spin_ok "RT kernel + initramfs configured"
1340
+ ulog "CONFIG: RT kernel boot entries OK"
1341
+ else
1342
+ spin_warn "RT kernel boot entries missing in config.txt!"
1343
+ ulog "WARN: RT kernel boot entries missing"
1344
+ fi
1345
+
1346
+ # 2. RT initramfs freshness — resync if the source initrd is newer
1347
+ spin_start "RT initramfs freshness"
1348
+ _RT_KVER="$(uname -r)"
1349
+ _SRC_INITRD="/boot/initrd.img-${_RT_KVER}"
1350
+ _FW_INITRD="/boot/firmware/initramfs8-rt"
1351
+ if [[ -f "$_SRC_INITRD" && -f "$_FW_INITRD" ]] \
1352
+ && [[ "$_SRC_INITRD" -nt "$_FW_INITRD" ]]; then
1353
+ sudo cp "$_SRC_INITRD" "$_FW_INITRD" \
1354
+ && spin_ok "initramfs8-rt was stale — resynced" \
1355
+ || spin_warn "initramfs8-rt resync failed"
1356
+ ulog "FIXED: stale initramfs8-rt resynced"
1357
+ else
1358
+ spin_ok "initramfs8-rt up to date"
1359
+ ulog "CONFIG: initramfs8-rt fresh"
1360
+ fi
1361
+
1362
+ # 3. Boot cmdline parameters
1363
+ spin_start "Boot cmdline (quiet splash)"
1364
+ _CMD_MISSING=""
1365
+ for _param in "quiet" "splash" "logo.nologo" "systemd.show_status=0" \
1366
+ "plymouth.ignore-serial-consoles"; do
1367
+ grep -q "$_param" /boot/firmware/cmdline.txt 2>/dev/null \
1368
+ || _CMD_MISSING="${_CMD_MISSING} ${_param}"
1369
+ done
1370
+ if [[ -n "$_CMD_MISSING" ]]; then
1371
+ for _param in $_CMD_MISSING; do
1372
+ sudo sed -i "s/\$/ ${_param}/" /boot/firmware/cmdline.txt
1373
+ done
1374
+ spin_ok "Restored missing cmdline params:${_CMD_MISSING}"
1375
+ ulog "FIXED: cmdline params restored:${_CMD_MISSING}"
1376
+ else
1377
+ spin_ok "All boot cmdline params present"
1378
+ ulog "CONFIG: cmdline OK"
1379
+ fi
1380
+
1381
+ # 4. Plymouth theme still set
1382
+ spin_start "Plymouth theme"
1383
+ _CUR_THEME=$(sudo plymouth-set-default-theme 2>/dev/null || echo "")
1384
+ if [[ "$_CUR_THEME" != "saismruth" ]]; then
1385
+ sudo plymouth-set-default-theme saismruth 2>/dev/null \
1386
+ && spin_ok "Theme was '${_CUR_THEME:-none}' — reset to saismruth" \
1387
+ || spin_warn "Could not set theme"
1388
+ ulog "FIXED: plymouth theme reset (was: ${_CUR_THEME:-none})"
1389
+ else
1390
+ spin_ok "saismruth active"
1391
+ ulog "CONFIG: plymouth theme OK"
1392
+ fi
1393
+
1394
+ # 5. Non-essential services stay disabled (upgrades can re-enable them)
1395
+ spin_start "Non-essential services"
1396
+ _RE_DISABLED=""
1397
+ for _svc in bluetooth avahi-daemon cups apt-daily.timer apt-daily-upgrade.timer man-db.timer; do
1398
+ if systemctl is-enabled "$_svc" &>/dev/null; then
1399
+ sudo systemctl disable --now "$_svc" &>/dev/null \
1400
+ && _RE_DISABLED="${_RE_DISABLED} ${_svc}"
1401
+ fi
1402
+ done
1403
+ if [[ -n "$_RE_DISABLED" ]]; then
1404
+ spin_ok "Re-disabled:${_RE_DISABLED}"
1405
+ ulog "FIXED: re-disabled services:${_RE_DISABLED}"
1406
+ else
1407
+ spin_ok "All non-essential services off"
1408
+ ulog "CONFIG: services OK"
1409
+ fi
1410
+
1236
1411
  # ── Restart services ──────────────────────────────────────────────────────
1237
1412
  spin_start "Restarting services"
1238
1413
  sudo systemctl restart plc_watcher plc_web 2>/dev/null
@@ -1249,6 +1424,30 @@ update)
1249
1424
  || echo -e " ${R}✗${NC} plc_web ${_UWb}"
1250
1425
  echo ""
1251
1426
  ok "Update complete (${_PREV_SHORT} → ${_NEW_SHORT})"
1427
+ [[ $_PLY_CHANGED -eq 1 ]] && warn "Reboot required for boot splash changes to take effect."
1428
+ ulog "SERVICES: plc_watcher=${_UW} plc_web=${_UWb}"
1429
+ ulog "=== Update complete: ${_PREV_SHORT} -> ${_NEW_SHORT} ==="
1430
+ info "Report: ${ULOG}"
1431
+
1432
+ # ── Push update report to SMB share ───────────────────────────────────────
1433
+ _SMB_HOST=$(smb_get "SMB_HOST")
1434
+ _SMB_SHARE=$(smb_get "SMB_SHARE")
1435
+ _SMB_USER=$(smb_get "SMB_USERNAME")
1436
+ _SMB_PASS=$(smb_get "SMB_PASSWORD")
1437
+ _SMB_EN=$(grep "^SMB_ENABLED" "${SMB_CFG}" 2>/dev/null | grep -qi "true" && echo "1" || echo "0")
1438
+
1439
+ if [[ "$_SMB_EN" == "1" && -n "$_SMB_HOST" && -n "$_SMB_USER" ]] \
1440
+ && command -v smbclient &>/dev/null; then
1441
+ spin_start "Pushing update report to SMB share"
1442
+ _ULOG_BASE="$(basename "$ULOG")"
1443
+ if smbclient "//${_SMB_HOST}/${_SMB_SHARE}" \
1444
+ -U "${_SMB_USER}%${_SMB_PASS}" \
1445
+ -c "mkdir logs; put ${ULOG} logs/${_ULOG_BASE}" &>/dev/null 2>&1; then
1446
+ spin_ok "Report pushed → //${_SMB_HOST}/${_SMB_SHARE}/logs/${_ULOG_BASE}"
1447
+ else
1448
+ spin_warn "SMB push failed — report saved locally at ${ULOG}"
1449
+ fi
1450
+ fi
1252
1451
  echo ""
1253
1452
  ;;
1254
1453
 
@@ -1468,7 +1667,7 @@ uninstall)
1468
1667
  echo " ╔══════════════════════════════════════════════════════════╗"
1469
1668
  echo " ║ Uninstall complete. ║"
1470
1669
  echo " ║ ║"
1471
- echo " ║ A reboot is needed to apply kernel revert. ║"
1670
+ echo " ║ A reboot is needed to apply kernel revert. ║"
1472
1671
  echo " ╚══════════════════════════════════════════════════════════╝"
1473
1672
  echo -e "${NC}"
1474
1673
  [[ "${KEEP_REPORTS^^}" == "Y" ]] && info "PDFs still at: ${REPORTS_DIR} (remove manually if needed)"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plc-checkweigher",
3
- "version": "1.22.0",
3
+ "version": "1.24.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
@@ -16,7 +16,7 @@
16
16
  # 7. SMB — enter host IP, share name, credentials → smb_config.py
17
17
  # 8. NetworkManager-wait-online
18
18
  # 9. systemd services (plc_watcher + plc_web)
19
- # 10. Boot logo — Plymouth theme with logo.png + "SAI SAMARTH ENGG"
19
+ # 10. Boot logo — Plymouth theme with logo.png + "Sai Samarth Engineering"
20
20
  # 11. Display — LightDM priority, CPU isolation, utmpx
21
21
  # 11b. VS Code — priority daemon: cores 0-2, Nice=-5
22
22
  # 12. PREEMPT_RT kernel ← installed last so only one reboot is needed
@@ -97,8 +97,11 @@ preflight() {
97
97
 
98
98
  # ── 1. System packages ────────────────────────────────────────────────────────
99
99
  install_system_packages() {
100
- step "System packages ..."
100
+ step "System update + packages ..."
101
101
  DEBIAN_FRONTEND=noninteractive apt-get update -qq
102
+ echo " Upgrading all packages to latest (this can take several minutes) ..."
103
+ DEBIAN_FRONTEND=noninteractive apt-get full-upgrade -y -qq
104
+ ok "System fully upgraded"
102
105
  DEBIAN_FRONTEND=noninteractive apt-get install -y -qq \
103
106
  git python3-venv python3-pip python3-dev \
104
107
  samba-client cifs-utils network-manager curl build-essential
@@ -158,6 +161,8 @@ install_cli() {
158
161
  if [[ -f "${CLI_SRC}" ]]; then
159
162
  chmod +x "${CLI_SRC}"
160
163
  cp "${CLI_SRC}" "${CLI_DEST}"
164
+ # Remove stale ~/.local/bin/ copy — it takes PATH priority and can shadow updates
165
+ rm -f "/home/pi/.local/bin/plc_checkweigher" 2>/dev/null || true
161
166
  ok "plc_checkweigher → ${CLI_DEST}"
162
167
  ok "Run: plc_checkweigher status (full system diagnostic)"
163
168
  else
@@ -407,16 +412,45 @@ setup_boot_logo() {
407
412
  THEME_DIR="/usr/share/plymouth/themes/saismruth"
408
413
  mkdir -p "${THEME_DIR}"
409
414
 
410
- # ── Logo: resize assets/logo.png to 256×256 and copy into theme ──────────
415
+ # ── Logo (400×400) + pre-rendered text PNG ───────────────────────────────
411
416
  LOGO_SRC="${INSTALL_DIR}/assets/logo.png"
412
417
  if [[ -f "${LOGO_SRC}" ]]; then
413
418
  "${VENV_DIR}/bin/python3" - << PYEOF
414
- from PIL import Image
419
+ from PIL import Image, ImageDraw, ImageFont
420
+ import os, sys
421
+
422
+ THEME = "${THEME_DIR}"
423
+ TEXT = "Sai Samarth Engineering"
424
+
425
+ # Logo — 400×400 (more visible on HD display)
415
426
  img = Image.open("${LOGO_SRC}").convert("RGBA")
416
- img.thumbnail((256, 256), Image.LANCZOS)
417
- img.save("${THEME_DIR}/logo.png", "PNG")
427
+ img = img.resize((400, 400), Image.LANCZOS)
428
+ img.save(os.path.join(THEME, "logo.png"), "PNG")
429
+
430
+ # Pre-rendered company name (white on transparent) — avoids font issues in initramfs
431
+ FONT_PATHS = [
432
+ "/usr/share/fonts/truetype/freefont/FreeSansBold.ttf",
433
+ "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf",
434
+ "/usr/share/fonts/truetype/liberation/LiberationSans-Bold.ttf",
435
+ ]
436
+ font = None
437
+ for fp in FONT_PATHS:
438
+ if os.path.exists(fp):
439
+ font = ImageFont.truetype(fp, 30)
440
+ break
441
+ if font is None:
442
+ font = ImageFont.load_default()
443
+
444
+ bbox = font.getbbox(TEXT)
445
+ tw, th = bbox[2] - bbox[0], bbox[3] - bbox[1]
446
+ pad = 10
447
+ canvas = Image.new("RGBA", (tw + pad * 2, th + pad * 2), (0, 0, 0, 0))
448
+ ImageDraw.Draw(canvas).text((pad - bbox[0], pad - bbox[1]), TEXT,
449
+ fill=(255, 255, 255, 255), font=font)
450
+ canvas.save(os.path.join(THEME, "text.png"), "PNG")
451
+ print(" logo 400x400, text", canvas.size)
418
452
  PYEOF
419
- ok "Logo installed (256×256) → ${THEME_DIR}/logo.png"
453
+ ok "Logo + text images installed → ${THEME_DIR}/"
420
454
  else
421
455
  warn "assets/logo.png not found — splash will show text only"
422
456
  fi
@@ -424,8 +458,8 @@ PYEOF
424
458
  # ── Theme config file ─────────────────────────────────────────────────────
425
459
  cat > "${THEME_DIR}/saismruth.plymouth" << 'EOF'
426
460
  [Plymouth Theme]
427
- Name=SAI SAMARTH ENGG
428
- Description=PLC Check-Weigher Boot Screen — SAI SAMARTH ENGG
461
+ Name=Sai Samarth Engineering
462
+ Description=PLC Check-Weigher Boot Screen — Sai Samarth Engineering
429
463
  ModuleName=script
430
464
 
431
465
  [script]
@@ -433,30 +467,30 @@ ImageDir=/usr/share/plymouth/themes/saismruth
433
467
  ScriptFile=/usr/share/plymouth/themes/saismruth/saismruth.script
434
468
  EOF
435
469
 
436
- # ── Plymouth script: logo centred, text below ─────────────────────────────
470
+ # ── Plymouth script: logo + pre-rendered text, both centred ──────────────
437
471
  cat > "${THEME_DIR}/saismruth.script" << 'EOF'
438
- # ── SAI SAMARTH ENGG — Boot Splash ────────────────────────────────────────────
472
+ # Sai Samarth Engineering — Boot Splash
439
473
  Window.SetBackgroundTopColor(0.0, 0.0, 0.0);
440
474
  Window.SetBackgroundBottomColor(0.0, 0.0, 0.0);
441
475
 
442
476
  screen_w = Window.GetWidth();
443
477
  screen_h = Window.GetHeight();
444
478
 
445
- # ── Logo (centred, slightly above middle to leave room for text) ──────────────
479
+ # Logo centred, slightly above middle
446
480
  logo_img = Image("logo.png");
447
481
  logo_w = logo_img.GetWidth();
448
482
  logo_h = logo_img.GetHeight();
449
483
  logo_x = (screen_w - logo_w) / 2;
450
- logo_y = (screen_h - logo_h) / 2 - 40;
484
+ logo_y = (screen_h - logo_h) / 2 - 50;
451
485
 
452
486
  logo_sprite = Sprite(logo_img);
453
487
  logo_sprite.SetPosition(logo_x, logo_y, 0);
454
488
 
455
- # ── Company name centred below logo ───────────────────────────────────────────
456
- text_img = Image.Text("SAI SAMARTH ENGG", 1.0, 1.0, 1.0, 1.0, "Sans Bold 20");
489
+ # Company name — pre-rendered PNG, centred below logo
490
+ text_img = Image("text.png");
457
491
  text_w = text_img.GetWidth();
458
492
  text_x = (screen_w - text_w) / 2;
459
- text_y = logo_y + logo_h + 22;
493
+ text_y = logo_y + logo_h + 24;
460
494
 
461
495
  text_sprite = Sprite(text_img);
462
496
  text_sprite.SetPosition(text_x, text_y, 1);
@@ -466,6 +500,26 @@ EOF
466
500
  plymouth-set-default-theme saismruth
467
501
  ok "Plymouth theme set → saismruth"
468
502
 
503
+ # ── Suppress all other boot visuals ──────────────────────────────────────
504
+ # Hide Pi firmware rainbow square
505
+ grep -q "^disable_splash=1" /boot/firmware/config.txt \
506
+ || echo "disable_splash=1" >> /boot/firmware/config.txt
507
+
508
+ # Hide kernel Tux logo + reduce loglevel so only our splash is visible
509
+ if ! grep -q "logo.nologo" /boot/firmware/cmdline.txt; then
510
+ sed -i 's/$/ logo.nologo/' /boot/firmware/cmdline.txt
511
+ fi
512
+ sed -i 's/loglevel=3/loglevel=1/' /boot/firmware/cmdline.txt 2>/dev/null || true
513
+ # Silence systemd service status lines + udev on the console.
514
+ # plymouth.ignore-serial-consoles is CRITICAL: with console=serial0 in
515
+ # cmdline, Plymouth falls back to text mode and no splash renders at all.
516
+ for _param in "systemd.show_status=0" "rd.systemd.show_status=0" \
517
+ "udev.log_level=3" "plymouth.ignore-serial-consoles"; do
518
+ grep -q "$_param" /boot/firmware/cmdline.txt \
519
+ || sed -i "s/\$/ ${_param}/" /boot/firmware/cmdline.txt
520
+ done
521
+ ok "Boot cmdline patched (logo.nologo, loglevel=1, silent systemd, disable_splash=1)"
522
+
469
523
  # Rebuild current initramfs so Plymouth is included.
470
524
  # The RT kernel's post-install will create its own initramfs with Plymouth
471
525
  # already installed, so initramfs8-rt will also carry the theme.
@@ -642,6 +696,43 @@ lock_source_files() {
642
696
  }
643
697
 
644
698
  # ── 12. RT kernel — installed LAST so only one reboot is needed ───────────────
699
+ # ── 11d. System optimization — disable everything not needed by the tool ─────
700
+ setup_system_optimize() {
701
+ step "System optimization (disable non-essential services) ..."
702
+
703
+ # Services NOT used by: PLC stack, web UI, WiFi, SSH, SMB push (client-only),
704
+ # LightDM kiosk, VS Code, or Raspberry Pi Connect.
705
+ # KEEP: NetworkManager, ssh, lightdm, rpi-connect, systemd-timesyncd,
706
+ # fstrim.timer (SD card health), e2scrub (fs health).
707
+ local _DISABLE=(
708
+ bluetooth # no BT devices used
709
+ hciuart # BT UART helper
710
+ ModemManager # no cellular modem
711
+ triggerhappy # hotkey daemon
712
+ avahi-daemon # mDNS discovery — tool uses direct IPs
713
+ cups # no printing
714
+ cups-browsed
715
+ apt-daily.timer # no background auto-update (manual: tool update)
716
+ apt-daily-upgrade.timer
717
+ man-db.timer # man page reindexing
718
+ packagekit # GUI package manager backend
719
+ )
720
+ for _svc in "${_DISABLE[@]}"; do
721
+ if systemctl list-unit-files "${_svc}"* 2>/dev/null | grep -q "${_svc}"; then
722
+ systemctl disable --now "${_svc}" &>/dev/null \
723
+ && ok "disabled ${_svc}" \
724
+ || true
725
+ fi
726
+ done
727
+
728
+ # Power off the Bluetooth radio entirely at boot
729
+ grep -q "^dtoverlay=disable-bt" "${BOOT_FW}/config.txt" \
730
+ || echo "dtoverlay=disable-bt" >> "${BOOT_FW}/config.txt"
731
+ ok "Bluetooth radio disabled at boot (dtoverlay=disable-bt)"
732
+
733
+ ok "System optimized — PLC stack, WiFi, SSH, Pi Connect untouched"
734
+ }
735
+
645
736
  install_rt_kernel() {
646
737
  step "PREEMPT_RT kernel (final step before reboot) ..."
647
738
 
@@ -746,10 +837,11 @@ main() {
746
837
  setup_smb # 7 — interactive SMB config → smb_config.py
747
838
  setup_network_online # 8
748
839
  install_services # 9
749
- setup_boot_logo # 10 — Plymouth: logo + "SAI SAMARTH ENGG"
840
+ setup_boot_logo # 10 — Plymouth: logo + "Sai Samarth Engineering"
750
841
  setup_display # 11 — LightDM priority, CPU isolation, utmpx
751
842
  setup_vscode_priority # 11b — VS Code: cores 0-2, Nice=-5
752
843
  lock_source_files # 11c — root:root on .py, pi:pi on data/
844
+ setup_system_optimize # 11d — disable bluetooth/avahi/cups/apt-timers
753
845
  install_rt_kernel # 12 — LAST, so only one reboot needed
754
846
  do_reboot # 12 — single reboot applies everything
755
847
  }
package/uninstall.sh CHANGED
File without changes