#!/bin/sh
#
# $Id: usb-watchdog 6889 2010-09-27 19:45:40Z NiLuJe $
#

# Pull some helper functions for logging
_FUNCTIONS=/etc/rc.d/functions
[ -f ${_FUNCTIONS} ] && . ${_FUNCTIONS}

LINKSS_BASEDIR="/mnt/us/linkss"
WATCHDOG_PID="${LINKSS_BASEDIR}/run/usb-watchdog.pid"
WATCHDOG_HELPER="${LINKSS_BASEDIR}/bin/usb-watchdog-helper"

# Make sure the watchdog's always up
while true ; do
    msg "starting USB watchdog (dbus-monitor)" I
    /usr/bin/dbus-monitor --system "type='signal', interface='com.lab126.hal', path='/default', member='usbPlugOut'" | ${WATCHDOG_HELPER}
    sleep 2
done

# Remove our pidfile
rm -f ${WATCHDOG_PID}
