#!/bin/sh

DEFAULT=/etc/fprobe.conf
OPTIONS=""
[ -f $DEFAULT ] && . $DEFAULT
[ -n "$IFNAME" ] && OPTIONS="$OPTIONS -i $IFNAME"
[ -n "$LOG_LEVEL" ] && OPTIONS="$OPTIONS -v $LOG_LEVEL"
[ -n "$REMOTE" ] && OPTIONS="$OPTIONS $REMOTE"

case $1 in
 start)
  [ -d /var/run ] || mkdir -p /var/run
  /usr/sbin/fprobe $OPTIONS
  ;;
 stop)
  [ -f /var/run/fprobe.pid ] && kill $(cat /var/run/fprobe.pid) >/dev/null 2>&1
  ;;
 *)
  echo "usage: $0 (start|stop)"
  exit 1
esac

exit $?
