#!/bin/sh

MANAGER_STOP_ON_CHANGE_D="/etc/manager.d/stop-on-change.d"

manager_stop_on_change () {
	if [ $ENABLE_DEBUG == 1 ]; then busybox echo "Stopping  miniDLNA & netTalk..."; fi
	if [ $ENABLE_NETATALK == 1 ]; then /etc/init.d/S50netatalk stop ; fi
	if [ $ENABLE_MINIDLNA == 1 ]; then /etc/init.d/S98minidlna stop ; fi

    # TODO: S95kwilt-index
	if [ $ENABLE_DB2CS == 1 ]; then  kill -9 `pidof DB2CS_NOTIFIER` ; fi

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

	sleep 2
}