#!/bin/sh
# Copyright (c) 2000-2012 Synology Inc. All rights reserved.

# Get DSM Version
[ -f "/etc.defaults/VERSION" ] || exit 1
DSM_VERSION=`grep ^majorversion= /etc.defaults/VERSION | cut -d'"' -f2`
[ -z "$DSM_VERSION" ] && exit 1

# DSM 4 use different config
if [ "$DSM_VERSION" -eq "4" ]; then
	SITES_ENABLED_USER_DIR="/usr/syno/etc/sites-enabled-user"
	ApacheUserScript="/usr/syno/etc/rc.d/S97apache-user.sh"

	if [ -d $SITES_ENABLED_USER_DIR ]; then
		 rm $SITES_ENABLED_USER_DIR"/SYNO.SDS.Joomla.conf"
		 $ApacheUserScript restart > /dev/null 2>&1
	fi
else
	PHP_CONF_DIR="/etc/php/conf.d"

	mkdir -p $PHP_CONF_DIR
	rm $PHP_CONF_DIR"/SYNO.SDS.Joomla.ini"
	initctl restart php-fpm > /dev/null 2>&1
fi

/bin/rm -rf /var/services/web/joomla

exit 0
