#!/usr/bin/env bash # stop-for-glmnf3.sh — Stop non-essential services on this node. # Frees unified memory for GLM-5.2 NF3-Hybrid inference. # # Usage: # scp scripts/stop-for-glmnf3.sh dgxN.lan:~/ # ssh dgxN.lan 'sudo bash ~/stop-for-glmnf3.sh' # # Reboot to restore services, or run start-after-glmnf3.sh. set -euo pipefail SERVICES_STOP=( snapd.service fwupd.service udisks2.service upower.service ModemManager.service bluetooth.service avahi-daemon.service cups.service cups-browsed.service colord.service smartmontools.service rsyslog.service rtkit-daemon.service dgx-dashboard-admin.service dgx-dashboard.service ) USER_KILL=( "pipewire" "pipewire-pulse" "wireplumber" "snapd-desktop-integration" ) echo "=== [$HOSTNAME] Stopping non-essential services ===" for svc in "${SERVICES_STOP[@]}"; do if systemctl is-active --quiet "$svc" 2>/dev/null; then echo " Stopping $svc ..." systemctl stop "$svc" 2>/dev/null || true systemctl disable "$svc" 2>/dev/null || true fi done for proc in "${USER_KILL[@]}"; do pids=$(pgrep -x "$proc" 2>/dev/null || true) if [ -n "$pids" ]; then echo " Killing $proc (PIDs: $pids) ..." kill -TERM $pids 2>/dev/null || true fi done systemctl stop snapd.service snapd.socket 2>/dev/null || true echo " Dropping page cache + dentries ..." sync echo 3 > /proc/sys/vm/drop_caches 2>/dev/null || true echo "=== [$HOSTNAME] Done ==="