HEX
Server: Apache/2.2.34 (Unix) mod_fastcgi/mod_fastcgi-SNAP-0910052141
System: Linux Kou-Etsu-Dou 4.4.59+ #25556 SMP PREEMPT Thu Mar 4 18:03:46 CST 2021 x86_64
User: hosam (1026)
PHP: 7.2.29
Disabled: NONE
Upload Files
File: //usr/syno/sbin/install_backup_plugin.sh
#!/bin/sh
# Copyright (c) 2000-2014 Synology Inc. All rights reserved.
. /usr/syno/bin/jsoncmd

PKGNAME_TRIGGER=$1
SOURCE_PLUGIN_PATH=/usr/syno/share/synoappbackuptemp
BIN_CP=/bin/cp
BIN_SYNOPKG=/usr/syno/bin/synopkg

PKGNAME_SURVEILLANCE=SurveillanceStation

myLog()
#1: err message
{
	/usr/bin/logger -s -p err -t syno_install_backup_plugin $1
}

checkVersion()
#1: Package ID
{
	pkg_name=$1

#Get installed package version
	version_install=`${BIN_SYNOPKG} version ${pkg_name}`
	if [ $? -eq 1 ]; then
		return 0 #package not installed
	fi
	version_install=\"${version_install}\"

	version_json=`/bin/cat ${SOURCE_PLUGIN_PATH}/${pkg_name}/package_version`
	version_list=$(jfilter "${version_json}" .[])
	if [ $? -ne 0 ];then
		  myLog "Package NOT install, skip install plugin [${pkg_name}]"
		  return 0   #failed to get version list, maybe data format is wrong
	fi

	for version_allow in ${version_list}; do
		if [ "x${version_allow}" = "x${version_install}" ]; then
			myLog "Version match [${version_install}] ==> Install package [${pkg_name}]"
			return 1 #match
		fi
	done

	myLog "Version NOT match [${version_install}] ==> Not install plugin [${pkg_name}]"

	return 0
}

#SurveillanceStation
if [ -z "${PKGNAME_TRIGGER}" -o "x${PKGNAME_TRIGGER}" = "x${PKGNAME_SURVEILLANCE}" ];then
	checkVersion ${PKGNAME_SURVEILLANCE}
	IsVersionMatch=$?

	if [ ${IsVersionMatch} -eq 1 ];then
		${BIN_CP} -rf ${SOURCE_PLUGIN_PATH}/${PKGNAME_SURVEILLANCE}/scripts/backup /var/packages/${PKGNAME_SURVEILLANCE}/scripts/
	fi
fi