#!/bin/sh # usage: install-bluetooth # source_dir contains plain-text files of any filename. # for each file, this extracts the MAC and creates a symlink in destdir which # points to the original file, using the MAC name as file path # # bluetooth connection structure is /var/lib/bluetooth///{attributes,info} # bluetoothd/main.conf options can be found here: # - srcdir="$1" destdir="$2" if [ "x$destdir" = "x" ] then devmac=$(cat /sys/kernel/debug/bluetooth/hci0/identity | cut -f 1 -d' ' | tr "a-z" "A-Z") # default to the first MAC address on the host destdir="/var/lib/bluetooth/$devmac" test -d "$destdir" || mkdir "$destdir" || test -d "$destdir" fi for f in $(ls "$srcdir") do mac=$(sed -rn 's/# MAC=(.*)/\1/p' "$srcdir/$f") condir="$destdir/$mac" test -d "$condir" || mkdir "$condir" || test -d "$condir" ln -sf --no-dereference "$srcdir/$f" "$condir/info" touch "$condir/attributes" done