#!/bin/sh

MANAGER_START_ON_CHANGE_D="/etc/manager.d/start-on-change.d"

manager_start_on_change () {
	[ ${ENABLE_DEBUG} == 1 ] && echo "Restarting miniDLNA & netTalk..."

	if [ ${ENABLE_MINIDLNA} == 1 ]; then
		rm -f /tmp/minidlna/*
		/etc/init.d/S98minidlna start
		sleep 2
		/sbin/minidlna-internal
	fi

	[ ${ENABLE_NETATALK} == 1 ] && /etc/init.d/S50netatalk

    # Execute target-specific scripts in /etc/manager.d/start-on-change.d/
    if [ "`ls -A ${MANAGER_START_ON_CHANGE_D}/* 2>/dev/null`" != "" ]; then
        for each in ${MANAGER_START_ON_CHANGE_D}/* ; do
            sh ${each}
        done
    fi
}