#!/bin/sh

BLUETOOTH_DIR=/opt/bluetooth

BLUETOOTH_CONF_FILE=$BLUETOOTH_DIR/etc/bluetooth.conf
PRODUCT=`status -v sys | sed -n -e "s/^Product Type\s\+:\s\+\(.*\)/\1/p"`
echo "[General]" > $BLUETOOTH_CONF_FILE
echo "Name = $PRODUCT" >> $BLUETOOTH_CONF_FILE
echo "Class = 0x000300" >> $BLUETOOTH_CONF_FILE
echo "DiscoverableTimeout = 0" >> $BLUETOOTH_CONF_FILE
echo "PairableTimeout = 30" >> $BLUETOOTH_CONF_FILE
echo "FastConnectable = true" >> $BLUETOOTH_CONF_FILE
echo "[Policy]" >> $BLUETOOTH_CONF_FILE
echo "AutoEnable = true" >> $BLUETOOTH_CONF_FILE

ln -sf $BLUETOOTH_DIR/share/dbus-1 /usr/share
ln -sf $BLUETOOTH_DIR/bin/dbus-daemon /usr/bin/dbus-daemon
ln -sf $BLUETOOTH_DIR/bin/dbus-monitor /usr/bin/dbus-monitor
ln -sf $BLUETOOTH_DIR/bin/dbus-send /usr/bin/dbus-send

ln -sf $BLUETOOTH_DIR/bin/bluetoothctl /usr/bin/bluetoothctl
ln -sf $BLUETOOTH_DIR/libexec/bluetooth/bluetoothd /usr/bin/bluetoothd
ln -sf $BLUETOOTH_DIR/bin/btmon /usr/bin/btmon
ln -sf $BLUETOOTH_DIR/bin/l2ping /usr/bin/l2ping
ln -sf $BLUETOOTH_DIR/bin/l2test /usr/bin/l2test
ln -sf $BLUETOOTH_DIR/bin/bneptest /usr/bin/bneptest
