stop-for-glmnf3.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/usr/bin/env bash
  2. # stop-for-glmnf3.sh — Stop non-essential services on this node.
  3. # Frees unified memory for GLM-5.2 NF3-Hybrid inference.
  4. #
  5. # Usage:
  6. # scp scripts/stop-for-glmnf3.sh dgxN.lan:~/
  7. # ssh dgxN.lan 'sudo bash ~/stop-for-glmnf3.sh'
  8. #
  9. # Reboot to restore services, or run start-after-glmnf3.sh.
  10. set -euo pipefail
  11. SERVICES_STOP=(
  12. snapd.service
  13. fwupd.service
  14. udisks2.service
  15. upower.service
  16. ModemManager.service
  17. bluetooth.service
  18. avahi-daemon.service
  19. cups.service
  20. cups-browsed.service
  21. colord.service
  22. smartmontools.service
  23. rsyslog.service
  24. rtkit-daemon.service
  25. dgx-dashboard-admin.service
  26. dgx-dashboard.service
  27. )
  28. USER_KILL=(
  29. "pipewire"
  30. "pipewire-pulse"
  31. "wireplumber"
  32. "snapd-desktop-integration"
  33. )
  34. echo "=== [$HOSTNAME] Stopping non-essential services ==="
  35. for svc in "${SERVICES_STOP[@]}"; do
  36. if systemctl is-active --quiet "$svc" 2>/dev/null; then
  37. echo " Stopping $svc ..."
  38. systemctl stop "$svc" 2>/dev/null || true
  39. systemctl disable "$svc" 2>/dev/null || true
  40. fi
  41. done
  42. for proc in "${USER_KILL[@]}"; do
  43. pids=$(pgrep -x "$proc" 2>/dev/null || true)
  44. if [ -n "$pids" ]; then
  45. echo " Killing $proc (PIDs: $pids) ..."
  46. kill -TERM $pids 2>/dev/null || true
  47. fi
  48. done
  49. systemctl stop snapd.service snapd.socket 2>/dev/null || true
  50. echo " Dropping page cache + dentries ..."
  51. sync
  52. echo 3 > /proc/sys/vm/drop_caches 2>/dev/null || true
  53. echo "=== [$HOSTNAME] Done ==="