#!/bin/sh

`hciconfig | grep -iq "UP RUNNING"` || exit 1

[ -f /etc/obex ] && . /etc/obex
if [ -z "$OBEXDIR" ]; then
  OBEXDIR=/mnt
else
#  OBEXDIR=`echo "$OBEXDIR" | sed "s/^\/mnt//" | sed "s/^\///"`
  `echo "$OBEXDIR" | grep -iq /` && DIR=${OBEXDIR%%/*} || DIR="$OBEXDIR"
  if `grep -iq "$DIR" /etc/mnts`; then
    DEV=`grep -iq "$DIR" /etc/mnts | cut -f1`
    grep -iq "$DEV" /var/rw || rw "/mnt/$DIR" rw || exit 1
  fi
  OBEXDIR="/mnt/$OBEXDIR"
  mkdir -p "$OBEXDIR" || exit 1
fi

OPTIONS="-c 9 -I -s 3 -r "
sobexsrv ${OPTIONS}"$OBEXDIR" > /dev/null 2>&1 &

exit 0
