#!/bin/bash

NOTIFICATION_URL=`grep "^NOTIFICATION_URL" /etc/features.conf | awk -F= '{ print $2 }'`

if [ "$NOTIFICATION_URL" == "" ]; then
    echo "NOTIFICATION_URL not found in /etc/features.conf";
    exit 1;
fi

SERIAL=`cat /etc/oe-release | grep Serial | sed 's/Serial //'`
/bin/DB2CS_NOTIFIER "${NOTIFICATION_URL}?Serial=$SERIAL" "/tmp/minidlna/files.db" &

if [ -f /tmp/minidlna/files.db ]; then
    /usr/sbin/oe-admin-helper set-config /etc/features.conf IndexDatabaseFile /tmp/minidlna/files.db =
else
    /usr/sbin/oe-admin-helper set-config /etc/features.conf IndexDatabaseFile "" =
fi

# TODO: S95kwilt-index
cat /tmpHost/storage.list | awk '{ print $3 " " $2 }' > /tmpHost/path_mapping.txt
