#!/bin/bash

PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin

wdstop

if [ -f /tmp/watchdog ] ; then
    rm /tmp/watchdog
fi

# Special for HP server
if dmidecode | grep -q "Vendor: HP"; then
    if dmidecode | grep -q 'Product Name: ProLiant .* G7'; then
        rmmod iTCO_wdt >/dev/null 2>&1  # Remove because this doesn't work
        modprobe hpwdt soft_margin=300 nowayout=0
    else
        rmmod hpwdt >/dev/null 2>&1  # Remove because this doesn't work
        modprobe iTCO_wdt heartbeat=300 nowayout=0
    fi
    wdstart.hp
fi

if [ "$CPU" = "Geode" -o "$CPU" = "Atom" ] ; then
    # MSC
    if which uspepc >/dev/null;then
        if uspepc -INFO -b 2>/dev/null| head -1 | grep -q "HW platform:.*Q7-US15W";then
            if [ -f /dev/watchdog ] ; then
                rm /dev/watchdog
            fi
            wdstart.msc
        fi
    fi
        
        
    # Congatec    
    if which cgutlcmd >/dev/null;then
        if cgutlcmd cginfo /ot:board /dump /cgos 2>/dev/null >/dev/null ;then     
            if [ -f /dev/watchdog ] ; then
                rm /dev/watchdog
            fi
            wdstart.cgt
        fi
    fi
fi
/usr/bin/wdhole &
