sspatch: back to old file structure

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium 2024-08-31 15:21:38 -04:00
parent 2f49650814
commit d8bd17a0fe
4 changed files with 100 additions and 43 deletions

75
sspatch/all/usr/bin/sspatch.sh Executable file
View File

@ -0,0 +1,75 @@
#!/usr/bin/env bash
#
# 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 -vf "${target}/${file}" "${target}/${file}".bak
cp -vf "${input}/${file}" "${target}/${file}"
chown SurveillanceStation:SurveillanceStation "${target}/${file}"
chmod "${mode}" "${target}/${file}"
}
SSPATH="/var/packages/SurveillanceStation/target"
ADDONSPATH="/usr/arc/addons"
if [ -d "${SSPATH}" ]; then
# Define the hosts entries to be added
ENTRIES=("0.0.0.0 synosurveillance.synology.com")
for ENTRY in "${ENTRIES[@]}"
do
if [ -f "/tmpRoot/etc/hosts" ]; then
# Check if the entry is already in the file
if grep -Fxq "${ENTRY}" /tmpRoot/etc/hosts; then
echo "sspatch: Entry ${ENTRY} already exists"
else
echo "sspatch: Entry ${ENTRY} does not exist, adding now"
echo "${ENTRY}" >> /tmpRoot/etc/hosts
fi
fi
if [ -f "/tmpRoot/etc.defaults/hosts" ]; then
if grep -Fxq "${ENTRY}" /tmpRoot/etc.defaults/hosts; then
echo "sspatch: Entry ${ENTRY} already exists"
else
echo "sspatch: Entry ${ENTRY} does not exist, adding now"
echo "${ENTRY}" >> /tmpRoot/etc.defaults/hosts
fi
fi
done
echo "sspatch: SurveillanceStation found"
# Check Sha256sum for Patch
CHECKSUM="$(sha256sum ${SSPATH}/lib/libssutils.so | cut -d' ' -f1)"
if [ "${CHECKSUM}" == "b0fafefe820aa8ecd577313dff2ae22cf41a6ddf44051f01670c3b92ee04224d" ]; then
echo "sspatch: SurveillanceStation 9.2.0-11289"
tar -zxf "${ADDONSPATH}/sspatch.tgz" -C "${ADDONSPATH}/"
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
elif [ "${CHECKSUM}" == "92a8c8c75446daa7328a34acc67172e1f9f3af8229558766dbe5804a86c08a5e" ]; then
echo "sspatch: SurveillanceStation Openvino 9.2.0-11289"
tar -zxf "${ADDONSPATH}/sspatch-openvino.tgz" -C "${ADDONSPATH}/"
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
else
echo "sspatch: SurveillanceStation version not supported"
fi
fi
exit 0

View File

View File

@ -6,54 +6,36 @@
# See /LICENSE for more information. # See /LICENSE for more information.
# #
function copy_file() {
local target="${1}"
local file="${2}"
local input="${3}"
local mode="${4}"
mv -vf "${target}/${file}" "${target}/${file}".bak
cp -vf "${input}/${file}" "${target}/${file}"
chown SurveillanceStation:SurveillanceStation "${target}/${file}"
chmod "${mode}" "${target}/${file}"
}
if [ "${1}" = "late" ]; then if [ "${1}" = "late" ]; then
echo "Installing addon sspatch - ${1}" echo "Installing addon sspatch - ${1}"
mkdir -p "/tmpRoot/usr/arc/addons/" mkdir -p "/tmpRoot/usr/arc/addons/"
cp -vf "${0}" "/tmpRoot/usr/arc/addons/" cp -vf "${0}" "/tmpRoot/usr/arc/addons/"
SSPATH="/tmpRoot/var/packages/SurveillanceStation/target" cp -vf "/usr/bin/sspatch.sh" "/tmpRoot/usr/bin/sspatch.sh"
INPUTPATH="/usr/arc/addons" cp -vf "/usr/lib/sspatch.tgz" "/tmpRoot/usr/arc/sspatch.tgz"
ADDONSPATH="/tmpRoot/usr/arc/addons" cp -vf "/usr/lib/sspatch-openvino.tgz" "/tmpRoot/usr/arc/sspatch-openvino.tgz"
if [ -d "${SSPATH}" ]; then
echo "sspatch: SurveillanceStation found" mkdir -p "/tmpRoot/usr/lib/systemd/system"
# Check Sha256sum for Patch DEST="/tmpRoot/usr/lib/systemd/system/sspatch.service"
CHECKSUM="$(sha256sum ${SSPATH}/lib/libssutils.so | cut -d' ' -f1)" cat > ${DEST} <<EOF
if [ "${CHECKSUM}" == "b0fafefe820aa8ecd577313dff2ae22cf41a6ddf44051f01670c3b92ee04224d" ]; then [Unit]
echo "sspatch: SurveillanceStation 9.2.0-11289" Description=addon sspatch
tar -zxf "${INPUTPATH}/sspatch.tgz" -C "${ADDONSPATH}/" After=multi-user.target
copy_file ${SSPATH}/lib libssutils.so ${ADDONSPATH} 0644
copy_file ${SSPATH}/sbin sscmshostd ${ADDONSPATH} 0755 [Service]
copy_file ${SSPATH}/sbin sscored ${ADDONSPATH} 0755 User=root
copy_file ${SSPATH}/sbin ssdaemonmonitord ${ADDONSPATH} 0755 Type=oneshot
copy_file ${SSPATH}/sbin ssexechelperd ${ADDONSPATH} 0755 RemainAfterExit=yes
copy_file ${SSPATH}/sbin ssroutined ${ADDONSPATH} 0755 ExecStart=/usr/bin/sspatch.sh
copy_file ${SSPATH}/sbin ssrtmpclientd ${ADDONSPATH} 0755
elif [ "${CHECKSUM}" == "92a8c8c75446daa7328a34acc67172e1f9f3af8229558766dbe5804a86c08a5e" ]; then [Install]
echo "sspatch: SurveillanceStation Openvino 9.2.0-11289" WantedBy=multi-user.target
tar -zxf "${INPUTPATH}/sspatch-openvino.tgz" -C "${ADDONSPATH}/"
copy_file ${SSPATH}/lib libssutils.so ${ADDONSPATH} 0644 [X-Synology]
copy_file ${SSPATH}/sbin sscmshostd ${ADDONSPATH} 0755 Author=Virtualization Team
copy_file ${SSPATH}/sbin sscored ${ADDONSPATH} 0755 EOF
copy_file ${SSPATH}/sbin ssdaemonmonitord ${ADDONSPATH} 0755 mkdir -vp /tmpRoot/usr/lib/systemd/system/multi-user.target.wants
copy_file ${SSPATH}/sbin ssexechelperd ${ADDONSPATH} 0755 ln -vsf /usr/lib/systemd/system/sspatch.service /tmpRoot/usr/lib/systemd/system/multi-user.target.wants/sspatch.service
copy_file ${SSPATH}/sbin ssroutined ${ADDONSPATH} 0755
copy_file ${SSPATH}/sbin ssrtmpclientd ${ADDONSPATH} 0755
else
echo "sspatch: SurveillanceStation version not supported"
fi
fi
elif [ "${1}" = "uninstall" ]; then elif [ "${1}" = "uninstall" ]; then
echo "Installing addon sspatch - ${1}" echo "Installing addon sspatch - ${1}"
# To-Do # To-Do