#!/bin/sh
. /usr/syno/bin/jsoncmd

main()
{
	local export_path=$(jget "${SYNOPKG_BKP_INPUT}" ".temp_path")
	if [ $? -ne 0 ];then
		jerr "bad parameters"
		exit 1
	fi

	"${SYNOPKG_PKGPATH}/target/bin/syno_config_backup_restore" myDSLoginCheck
	if [ $? -eq 0 ]; then
		"${SYNOPKG_PKGPATH}/target/bin/syno_config_backup_restore" getOnlineLicenseCheck
		if [ $? -ne 0 ]; then
			jerrstr "error" "license_network_check_tip"
			exit 1
		fi
	fi

	"${SYNOPKG_PKGPATH}/target/bin/syno_config_backup_restore" backup "${export_path}"
	if [ 0 -ne $? ]; then
		jerrstr "error" "config_backup_fail_msg"
		exit 1
	fi

	jout_begin
	joutstr "app_data_version" "1.1"
	jout_end

	exit 0
}

main
