#!/bin/sh

PHOTO_APACHE_CONF="SYNO.SDS.PhotoStation.conf"
SITES_ENABLED_USER_DIR="/usr/syno/etc/sites-enabled-user"
UPGRADE_FILE="/tmp/synophoto.upgrade"

signal_hup_httpd_user()
{
	local pid=`cat /var/run/httpd-user.pid 2>/dev/null`
	if [ -n $pid ]; then
		kill -HUP $pid
	fi
}

remove_apache_config()
{
	rm $SITES_ENABLED_USER_DIR/$PHOTO_APACHE_CONF
}

remove_apache_config

PACKAGE_NAME=$SYNOPKG_PKGNAME

INDEX_PACKAGE_PATH=/usr/syno/etc/synoindex/packages/${PACKAGE_NAME}/

# special action for real-uninstall
if [ ! -e ${UPGRADE_FILE} ]; then
        # remove index config file
        #Stop related daemons
        /usr/syno/etc.defaults/rc.d/S66synoindexd.sh stop
        /usr/syno/etc.defaults/rc.d/S77synomkthumbd.sh stop
        /usr/syno/etc.defaults/rc.d/S88synomkflvd.sh stop

	rm -rf ${INDEX_PACKAGE_PATH}

        #Start related daemons
        /usr/syno/etc.defaults/rc.d/S66synoindexd.sh start
        /usr/syno/etc.defaults/rc.d/S77synomkthumbd.sh start
        /usr/syno/etc.defaults/rc.d/S88synomkflvd.sh start
fi

exit 0
