plc-checkweigher 1.2.0 → 1.4.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.
- package/assets/logo.png +0 -0
- package/package.json +3 -2
- package/setup.sh +146 -6
package/assets/logo.png
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plc-checkweigher",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.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
|
"bin": {
|
|
6
6
|
"plc-checkweigher": "bin/cli.js"
|
|
7
7
|
},
|
|
8
8
|
"files": [
|
|
9
9
|
"bin/",
|
|
10
|
-
"setup.sh"
|
|
10
|
+
"setup.sh",
|
|
11
|
+
"assets/"
|
|
11
12
|
],
|
|
12
13
|
"keywords": [
|
|
13
14
|
"plc",
|
package/setup.sh
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# =============================================================================
|
|
3
|
-
# PLC Check-Weigher — Full Stack Installer v1.
|
|
3
|
+
# PLC Check-Weigher — Full Stack Installer v1.3
|
|
4
4
|
# =============================================================================
|
|
5
5
|
# Run on any fresh Raspberry Pi:
|
|
6
6
|
#
|
|
@@ -16,8 +16,10 @@
|
|
|
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.
|
|
20
|
-
# 11.
|
|
19
|
+
# 10. Boot logo — Plymouth theme with logo.png + "SAI SAMARTH ENGG"
|
|
20
|
+
# 11. Display — LightDM priority, CPU isolation, utmpx, GPU memory
|
|
21
|
+
# 12. PREEMPT_RT kernel ← installed last so only one reboot is needed
|
|
22
|
+
# 13. REBOOT
|
|
21
23
|
# =============================================================================
|
|
22
24
|
|
|
23
25
|
set -euo pipefail
|
|
@@ -364,7 +366,143 @@ EOF
|
|
|
364
366
|
chown "${PI_USER}:${PI_USER}" "${INSTALL_DIR}/plc_watcher.service"
|
|
365
367
|
}
|
|
366
368
|
|
|
367
|
-
# ──
|
|
369
|
+
# ── 10. Boot splash — Plymouth theme with logo + company name ────────────────
|
|
370
|
+
setup_boot_logo() {
|
|
371
|
+
step "Boot splash screen ..."
|
|
372
|
+
|
|
373
|
+
# Install Plymouth + font support (safe to run even if already installed)
|
|
374
|
+
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq \
|
|
375
|
+
plymouth plymouth-themes fonts-freefont-ttf
|
|
376
|
+
|
|
377
|
+
THEME_DIR="/usr/share/plymouth/themes/saismruth"
|
|
378
|
+
mkdir -p "${THEME_DIR}"
|
|
379
|
+
|
|
380
|
+
# ── Logo: resize assets/logo.png to 256×256 and copy into theme ──────────
|
|
381
|
+
LOGO_SRC="${INSTALL_DIR}/assets/logo.png"
|
|
382
|
+
if [[ -f "${LOGO_SRC}" ]]; then
|
|
383
|
+
"${VENV_DIR}/bin/python3" - << PYEOF
|
|
384
|
+
from PIL import Image
|
|
385
|
+
img = Image.open("${LOGO_SRC}").convert("RGBA")
|
|
386
|
+
img.thumbnail((256, 256), Image.LANCZOS)
|
|
387
|
+
img.save("${THEME_DIR}/logo.png", "PNG")
|
|
388
|
+
PYEOF
|
|
389
|
+
ok "Logo installed (256×256) → ${THEME_DIR}/logo.png"
|
|
390
|
+
else
|
|
391
|
+
warn "assets/logo.png not found — splash will show text only"
|
|
392
|
+
fi
|
|
393
|
+
|
|
394
|
+
# ── Theme config file ─────────────────────────────────────────────────────
|
|
395
|
+
cat > "${THEME_DIR}/saismruth.plymouth" << 'EOF'
|
|
396
|
+
[Plymouth Theme]
|
|
397
|
+
Name=SAI SAMARTH ENGG
|
|
398
|
+
Description=PLC Check-Weigher Boot Screen — SAI SAMARTH ENGG
|
|
399
|
+
ModuleName=script
|
|
400
|
+
|
|
401
|
+
[script]
|
|
402
|
+
ImageDir=/usr/share/plymouth/themes/saismruth
|
|
403
|
+
ScriptFile=/usr/share/plymouth/themes/saismruth/saismruth.script
|
|
404
|
+
EOF
|
|
405
|
+
|
|
406
|
+
# ── Plymouth script: logo centred, text below ─────────────────────────────
|
|
407
|
+
cat > "${THEME_DIR}/saismruth.script" << 'EOF'
|
|
408
|
+
# ── SAI SAMARTH ENGG — Boot Splash ────────────────────────────────────────────
|
|
409
|
+
Window.SetBackgroundTopColor(0.0, 0.0, 0.0);
|
|
410
|
+
Window.SetBackgroundBottomColor(0.0, 0.0, 0.0);
|
|
411
|
+
|
|
412
|
+
screen_w = Window.GetWidth();
|
|
413
|
+
screen_h = Window.GetHeight();
|
|
414
|
+
|
|
415
|
+
# ── Logo (centred, slightly above middle to leave room for text) ──────────────
|
|
416
|
+
logo_img = Image("logo.png");
|
|
417
|
+
logo_w = logo_img.GetWidth();
|
|
418
|
+
logo_h = logo_img.GetHeight();
|
|
419
|
+
logo_x = (screen_w - logo_w) / 2;
|
|
420
|
+
logo_y = (screen_h - logo_h) / 2 - 40;
|
|
421
|
+
|
|
422
|
+
logo_sprite = Sprite(logo_img);
|
|
423
|
+
logo_sprite.SetPosition(logo_x, logo_y, 0);
|
|
424
|
+
|
|
425
|
+
# ── Company name centred below logo ───────────────────────────────────────────
|
|
426
|
+
text_img = Image.Text("SAI SAMARTH ENGG", 1.0, 1.0, 1.0, 1.0, "Sans Bold 20");
|
|
427
|
+
text_w = text_img.GetWidth();
|
|
428
|
+
text_x = (screen_w - text_w) / 2;
|
|
429
|
+
text_y = logo_y + logo_h + 22;
|
|
430
|
+
|
|
431
|
+
text_sprite = Sprite(text_img);
|
|
432
|
+
text_sprite.SetPosition(text_x, text_y, 1);
|
|
433
|
+
EOF
|
|
434
|
+
|
|
435
|
+
# ── Activate theme ────────────────────────────────────────────────────────
|
|
436
|
+
plymouth-set-default-theme saismruth
|
|
437
|
+
ok "Plymouth theme set → saismruth"
|
|
438
|
+
|
|
439
|
+
# Rebuild current initramfs so Plymouth is included.
|
|
440
|
+
# The RT kernel's post-install will create its own initramfs with Plymouth
|
|
441
|
+
# already installed, so initramfs8-rt will also carry the theme.
|
|
442
|
+
echo -n " Rebuilding initramfs (may take ~30 s) ..."
|
|
443
|
+
update-initramfs -u > /tmp/initramfs.log 2>&1 \
|
|
444
|
+
&& echo "" && ok "initramfs rebuilt" \
|
|
445
|
+
|| { echo ""; warn "initramfs warnings — see /tmp/initramfs.log"; }
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
# ── 11. Display — LightDM priority, CPU isolation, utmpx, GPU memory ────────
|
|
449
|
+
setup_display() {
|
|
450
|
+
step "Display priority & LightDM ..."
|
|
451
|
+
|
|
452
|
+
# Install display stack if not present
|
|
453
|
+
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq \
|
|
454
|
+
lightdm labwc pi-greeter xserver-xorg 2>/dev/null || true
|
|
455
|
+
|
|
456
|
+
# ── Remove network dependency from LightDM ───────────────────────────────
|
|
457
|
+
# Display manager must not wait for network — it is independent of PLC services.
|
|
458
|
+
mkdir -p /etc/systemd/system/lightdm.service.d/
|
|
459
|
+
rm -f /etc/systemd/system/lightdm.service.d/wait-for-network.conf
|
|
460
|
+
|
|
461
|
+
cat > /etc/systemd/system/lightdm.service.d/display-priority.conf << 'EOF'
|
|
462
|
+
[Unit]
|
|
463
|
+
# Start after hardware udev settles (HDMI/DSI detected) — not after network.
|
|
464
|
+
After=systemd-udev-settle.service local-fs.target acpid.socket dbus.service
|
|
465
|
+
Wants=systemd-udev-settle.service
|
|
466
|
+
|
|
467
|
+
[Service]
|
|
468
|
+
# Generous restart policy — display should always recover.
|
|
469
|
+
StartLimitBurst=20
|
|
470
|
+
StartLimitIntervalSec=120
|
|
471
|
+
Restart=on-failure
|
|
472
|
+
RestartSec=3
|
|
473
|
+
|
|
474
|
+
# CPU cores 0-2 only — core 3 is reserved for SCHED_FIFO PLC process.
|
|
475
|
+
CPUAffinity=0 1 2
|
|
476
|
+
|
|
477
|
+
# Elevated priority — display stays responsive under PLC RT workload.
|
|
478
|
+
Nice=-5
|
|
479
|
+
|
|
480
|
+
LimitNOFILE=65536
|
|
481
|
+
EOF
|
|
482
|
+
ok "LightDM: CPUAffinity=0-2, Nice=-5, network dep removed"
|
|
483
|
+
|
|
484
|
+
# ── Fix utmpx — PAM needs /run/utmp to track sessions ───────────────────
|
|
485
|
+
cat > /etc/tmpfiles.d/utmp-fix.conf << 'EOF'
|
|
486
|
+
f /run/utmp 0664 root utmp -
|
|
487
|
+
EOF
|
|
488
|
+
systemd-tmpfiles --create /etc/tmpfiles.d/utmp-fix.conf 2>/dev/null || true
|
|
489
|
+
ok "/run/utmp fixed (utmpx PAM session tracking)"
|
|
490
|
+
|
|
491
|
+
# ── GPU memory — 128 MB: enough for 1080p desktop and HMI use ───────────
|
|
492
|
+
sed -i '/^gpu_mem=/d' "${BOOT_FW}/config.txt"
|
|
493
|
+
if grep -q "### PLC-RT-BLOCK-START ###" "${BOOT_FW}/config.txt"; then
|
|
494
|
+
sed -i '/### PLC-RT-BLOCK-START ###/i gpu_mem=128' "${BOOT_FW}/config.txt"
|
|
495
|
+
else
|
|
496
|
+
echo "gpu_mem=128" >> "${BOOT_FW}/config.txt"
|
|
497
|
+
fi
|
|
498
|
+
ok "gpu_mem=128 set in config.txt (128 MB VRAM)"
|
|
499
|
+
|
|
500
|
+
systemctl daemon-reload
|
|
501
|
+
systemctl enable lightdm.service 2>/dev/null || true
|
|
502
|
+
ok "LightDM enabled — starts on every boot when display is connected"
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
# ── 12. RT kernel — installed LAST so only one reboot is needed ───────────────
|
|
368
506
|
install_rt_kernel() {
|
|
369
507
|
step "PREEMPT_RT kernel (final step before reboot) ..."
|
|
370
508
|
|
|
@@ -462,8 +600,10 @@ main() {
|
|
|
462
600
|
setup_smb # 6 — interactive SMB config → smb_config.py
|
|
463
601
|
setup_network_online # 7
|
|
464
602
|
install_services # 8
|
|
465
|
-
|
|
466
|
-
|
|
603
|
+
setup_boot_logo # 9 — Plymouth: logo + "SAI SAMARTH ENGG"
|
|
604
|
+
setup_display # 10 — LightDM priority, CPU isolation, utmpx, GPU
|
|
605
|
+
install_rt_kernel # 11 — LAST, so only one reboot needed
|
|
606
|
+
do_reboot # 12 — single reboot applies everything
|
|
467
607
|
}
|
|
468
608
|
|
|
469
609
|
main "$@"
|