#!/bin/sh

# This unit loads the sbsa_gwdt watchdog module, which is blacklisted by default but required for specific devices.
# The devices are identified after their modalias

LOG_PREFIX="[sbsa_wdt loader] "
MODALIAS=$(cat /sys/devices/virtual/dmi/id/modalias)

case "$MODALIAS" in
    *NVIDIA_DGX_Spark*)
        echo "${LOG_PREFIX} NVIDIA DGX Spark device detected. Loading the sbsa_gwdt module that is blacklisted by default."
        modprobe sbsa_gwdt action=1 || echo "${LOG_PREFIX} Unable to load the sbsa_gwdt module"
        exit 0
        ;;
    *)
        echo "$LOG_PREFIX No modalias match."
        ;;
esac

echo "${LOG_PREFIX} No need to override load the watchdog module for this device."