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

WEBSTATION_CONFIG_PATH="/usr/syno/etc/packages/WebStation"
WEBSTATION_JSON_FILES="WebStation.json VirtualHost.json PHPSettings.json"

exportPath=$(jget "${SYNOPKG_BKP_INPUT}" ".temp_path")
if [ $? -ne 0 ];then
	msg="WebStation backup failed"
	error=$(printf "%s(%s)" "${msg}" "0x01")
	jerr "$error"
	exit 1
fi

/usr/syno/bin/synopkg version WebStation "${exportPath}/VERSION"

for file in ${WEBSTATION_JSON_FILES}; do
	if [ -e "${WEBSTATION_CONFIG_PATH}/${file}" ]; then
		cp -f "${WEBSTATION_CONFIG_PATH}/${file}" "${exportPath}/"
	fi
done

jout_begin
joutstr "app_data_version" "2.0"
jout_end
