#!/bin/sh
# Copyright (c) 2000-2016 Synology Inc. All rights reserved.
UDC_PATH="/usr/syno/etc/user.data.conf"
UPGRADE_FILE="/tmp/synovpnplus.upgrade"

PACKAGE_HOOK_LOCATION="/usr/local/libexec"
CERTIFICATE_HOOK_PATH="${PACKAGE_HOOK_LOCATION}/certificate/change"

SERVICETOOL="/usr/syno/bin/servicetool"
FW_CONF="VPNPlusServer.sc"

VPNPLUS_TOOL="/var/packages/VPNPlusServer/target/tool/synovpnplustool"

# Remove certificate hook
/bin/rm ${CERTIFICATE_HOOK_PATH}/certReload.sh

# Real uninstall
if [ "x$SYNOPKG_PKG_STATUS" != "xUPGRADE" ]; then
	${SERVICETOOL} --remove-configure-file --package ${FW_CONF}

	# Remove app privileges in database
	${VPNPLUS_TOOL} -u -p

	# Remove user data collection
	/bin/rm ${UDC_PATH}/vpnplus.config
fi

exit 0
