#!/bin/sh

# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)

. /etc/profile

oe_setup_addon service.minidlna

if [ ! -f "$ADDON_HOME/config/minidlna.conf" ]; then
  mkdir -p $ADDON_HOME/config
  cp $ADDON_DIR/config/minidlna.conf $ADDON_HOME/config
fi

if [ ! -d "$ADDON_HOME/db" ]; then
  mkdir -p $ADDON_HOME/db
fi

chmod a+x $ADDON_DIR/bin/*

exec $ADDON_DIR/bin/minidlnad -S -f $ADDON_HOME/config/minidlna.conf -p $minidlna_port &>$ADDON_HOME/service.log
