File: //proc/25618/root/var/packages/CMS/scripts/preuninst
#!/bin/sh
# Copyright (c) 2000-2013 Synology Inc. All rights reserved.
PACKAGE_TARGET_DIR="/var/packages/${SYNOPKG_PKGNAME}/target"
DSTOOL="${PACKAGE_TARGET_DIR}/tools/synocmsds"
GET_SECTION_KEY_VALUE="/usr/syno/bin/get_section_key_value"
SYNO_CLUSTER="${PACKAGE_TARGET_DIR}/sbin/synocluster"
# $1: file , $2: section , $3: key
fetch_string()
{
local file="$1"
local section="$2"
local key="$3"
local value=""
value="`${GET_SECTION_KEY_VALUE} ${file} ${section} ${key}`"
if [ 0 -ne $? ]; then
return -1
else
echo ${value}
return 0
fi
}
fetch_uninstall_with_cluster_msg()
{
local local_language="${SYNOPKG_DSM_LANGUAGE}"
local string_file="/var/packages/CMS/target/ui/texts/${local_language}/strings"
fetch_string ${string_file} gluster warn_uninstall_cms_with_cluster
}
if [ "xUPGRADE" != "x$SYNOPKG_PKG_STATUS" ] && [ -x "${SYNO_CLUSTER}" ]; then
IS_CLUSTER_ENABLE="`${SYNO_CLUSTER} -s`"
# if cluster is enabled, the uninstall is not allow
if [ "enable" == "${IS_CLUSTER_ENABLE}" ]; then
echo "`fetch_uninstall_with_cluster_msg`" > ${SYNOPKG_TEMP_LOGFILE}
exit 1
fi
fi
if [ "xUPGRADE" != "x$SYNOPKG_PKG_STATUS" ] && [ -x "${DSTOOL}" ]; then
SELF_JOIN=`/bin/get_key_value /etc/synoinfo.conf dsm_cms_self_join`
if [ "yes" = "${SELF_JOIN}" ]; then
sed -i '/dsm_cms_self_join=.*$/d' /etc/synoinfo.conf
sed -i '/join_dsm_cms=.*$/d' /etc/synoinfo.conf
fi
DS_LIST=`${DSTOOL} --list | grep "^ID" | sed 's/^.*\([0-9][0-9]*\).*$/\1/g'`
for ds in $DS_LIST
do
${DSTOOL} --bgsend $ds api="SYNO.Core.CMS" version="1" method="disjoin" 2>&1 > /dev/null
done
fi
exit 0