2024-08-18 02:13:35 +07:00
|
|
|
#!/usr/bin/env ash
|
2024-08-31 22:36:41 +07:00
|
|
|
#
|
|
|
|
# Copyright (C) 2023 AuxXxilium <https://github.com/AuxXxilium>
|
|
|
|
#
|
|
|
|
# This is free software, licensed under the MIT License.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
|
|
|
|
|
|
|
function copy_file() {
|
|
|
|
local target="${1}"
|
|
|
|
local file="${2}"
|
|
|
|
local input="${3}"
|
|
|
|
local mode="${4}"
|
|
|
|
|
|
|
|
mv -f "${target}/${file}" "${target}/${file}".bak
|
|
|
|
cp -f "${input}/${file}" "${target}/${file}"
|
|
|
|
chown SurveillanceStation:SurveillanceStation "${target}/${file}"
|
|
|
|
chmod "${mode}" "${target}/${file}"
|
|
|
|
}
|
2024-08-18 02:13:35 +07:00
|
|
|
|
|
|
|
if [ "${1}" = "late" ]; then
|
2024-08-19 05:03:13 +07:00
|
|
|
echo "Installing addon sspatch - ${1}"
|
|
|
|
mkdir -p "/tmpRoot/usr/arc/addons/"
|
|
|
|
cp -vf "${0}" "/tmpRoot/usr/arc/addons/"
|
|
|
|
|
2024-08-31 22:36:41 +07:00
|
|
|
SSPATH="/tmpRoot/var/packages/SurveillanceStation/target"
|
|
|
|
INPUTPATH="/usr/arc/addons"
|
|
|
|
ADDONSPATH="/tmpRoot/usr/arc/addons"
|
|
|
|
if [ -d "${SSPATH}" ]; then
|
2024-09-01 00:55:49 +07:00
|
|
|
# Define the hosts entries to be added
|
|
|
|
ENTRIES=("0.0.0.0 synosurveillance.synology.com")
|
|
|
|
for ENTRY in "${ENTRIES[@]}"
|
|
|
|
do
|
2024-09-01 01:13:18 +07:00
|
|
|
if [ -f "/tmpRoot/etc/hosts" ]; then
|
2024-09-01 00:55:49 +07:00
|
|
|
# Check if the entry is already in the file
|
|
|
|
if grep -Fxq "${ENTRY}" /tmpRoot/etc/hosts; then
|
2024-09-01 01:13:18 +07:00
|
|
|
echo "Entry ${ENTRY} already exists"
|
2024-09-01 00:55:49 +07:00
|
|
|
else
|
2024-09-01 01:13:18 +07:00
|
|
|
echo "Entry ${ENTRY} does not exist, adding now"
|
|
|
|
echo "${ENTRY}" >> /tmpRoot/etc/hosts
|
2024-08-31 22:36:41 +07:00
|
|
|
fi
|
2024-09-01 00:55:49 +07:00
|
|
|
fi
|
2024-09-01 01:13:18 +07:00
|
|
|
if [ -f "/tmpRoot/etc.defaults/hosts" ]; then
|
2024-09-01 00:55:49 +07:00
|
|
|
if grep -Fxq "${ENTRY}" /tmpRoot/etc.defaults/hosts; then
|
2024-09-01 01:13:18 +07:00
|
|
|
echo "Entry ${ENTRY} already exists"
|
2024-09-01 00:55:49 +07:00
|
|
|
else
|
2024-09-01 01:13:18 +07:00
|
|
|
echo "Entry ${ENTRY} does not exist, adding now"
|
|
|
|
echo "${ENTRY}" >> /tmpRoot/etc.defaults/hosts
|
2024-08-31 22:36:41 +07:00
|
|
|
fi
|
|
|
|
fi
|
2024-09-01 00:55:49 +07:00
|
|
|
done
|
|
|
|
|
|
|
|
# Check Sha256sum for Patch
|
|
|
|
if [ "$(sha256sum ${SSPATH}/lib/libssutils.so | cut -d' ' -f1)" = "b0fafefe820aa8ecd577313dff2ae22cf41a6ddf44051f01670c3b92ee04224d" ]; then
|
|
|
|
tar -zxf "${INPUTPATH}/sspatch.tgz" -C "${ADDONSPATH}/"
|
2024-09-01 01:17:54 +07:00
|
|
|
copy_file ${SSPATH}/lib libssutils.so ${ADDONSPATH} 0644
|
|
|
|
copy_file ${SSPATH}/sbin sscmshostd ${ADDONSPATH} 0755
|
|
|
|
copy_file ${SSPATH}/sbin sscored ${ADDONSPATH} 0755
|
|
|
|
copy_file ${SSPATH}/sbin ssdaemonmonitord ${ADDONSPATH} 0755
|
|
|
|
copy_file ${SSPATH}/sbin ssexechelperd ${ADDONSPATH} 0755
|
|
|
|
copy_file ${SSPATH}/sbin ssroutined ${ADDONSPATH} 0755
|
|
|
|
copy_file ${SSPATH}/sbin ssrtmpclientd ${ADDONSPATH} 0755
|
2024-09-01 00:55:49 +07:00
|
|
|
fi
|
2024-08-31 22:36:41 +07:00
|
|
|
fi
|
2024-08-18 02:13:35 +07:00
|
|
|
elif [ "${1}" = "uninstall" ]; then
|
|
|
|
echo "Installing addon sspatch - ${1}"
|
|
|
|
# To-Do
|
|
|
|
fi
|