sspatch: cleanup

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium 2024-08-31 17:36:41 +02:00
parent 174ddc9d0c
commit 6dce716f00
7 changed files with 57 additions and 116 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,81 +0,0 @@
#!/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.
#
if [ -d /var/packages/SurveillanceStation ]; then
# Define the entries to be added
ENTRIES=("0.0.0.0 synosurveillance.synology.com")
# Loop over each entry
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 "Entry $ENTRY already exists"
else
echo "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 "Entry $ENTRY already exists"
else
echo "Entry $ENTRY does not exist, adding now"
echo "$ENTRY" >> /tmpRoot/etc.defaults/hosts
fi
fi
done
SSPATH="/var/packages/SurveillanceStation"
SO_FILE="${SSPATH}/target/lib/libssutils.so"
ORG_FILE="${SSPATH}/target/lib/libssutils.org.so"
MITM_FILE="${SSPATH}/target/lib/libssutils.mitm.so"
JS_FILE="${SSPATH}/target/ui/sds.js"
if [ ! -f "${SO_FILE}" ]; then
echo "SSPatch: ${SO_FILE} does not exist"
exit 1
fi
/usr/syno/bin/synopkg stop SurveillanceStation
sleep 5
# Check Sha256sum (DVA 92a8c8c75446daa7328a34acc67172e1f9f3af8229558766dbe5804a86c08a5e)
if [ "$(sha256sum ${SO_FILE} | cut -d' ' -f1)" = "b0fafefe820aa8ecd577313dff2ae22cf41a6ddf44051f01670c3b92ee04224d" ]; then
mv -f "${SO_FILE}" "${ORG_FILE}"
cp -f "/usr/lib/libssutils.mitm.so" "${MITM_FILE}"
patchelf --add-needed ${ORG_FILE} ${MITM_FILE}
mv -f "${MITM_FILE}" "${SO_FILE}"
echo "SSPatch: ${SO_FILE} is patched"
else
if [ -f "${ORG_FILE}" ]; then
echo "SSPatch: ${SO_FILE} is already patched"
exit 0
else
echo "SSPatch: version not supported"
exit 1
fi
fi
# Change owner and permissions
chown SurveillanceStation:SurveillanceStation "${SO_FILE}"
chmod 0644 "${SO_FILE}"
echo -e "SSPatch: ${SO_FILE} permissions set"
# Remove warning message
#sed -i 's/SYNO.API.RedirectToDSMByErrorCode=function(c){alert(SYNO.API.getErrorString(c));/SYNO.API.RedirectToDSMByErrorCode = () => { };/g' ${JS_FILE}
#echo -e "SSPatch: sds.js patched"
sleep 5
/usr/syno/bin/synopkg start SurveillanceStation
echo -e "SSPatch: Successfull!"
exit 0
else
echo "SSPatch: SurveillanceStation not found"
exit 1
fi

View File

@ -1,45 +1,67 @@
#!/usr/bin/env ash
#
# 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}"
}
if [ "${1}" = "late" ]; then
echo "Installing addon sspatch - ${1}"
mkdir -p "/tmpRoot/usr/arc/addons/"
cp -vf "${0}" "/tmpRoot/usr/arc/addons/"
cp -vf /usr/bin/sspatch.sh /tmpRoot/usr/bin/sspatch.sh
cp -vf /usr/bin/patchelf /tmpRoot/usr/bin/patchelf
cp -vf /usr/lib/libssutils.mitm.so /tmpRoot/usr/lib/libssutils.mitm.so
SSPATH="/tmpRoot/var/packages/SurveillanceStation/target"
INPUTPATH="/usr/arc/addons"
ADDONSPATH="/tmpRoot/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 "Entry ${ENTRY} already exists"
else
echo "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 "Entry ${ENTRY} already exists"
else
echo "Entry ${ENTRY} does not exist, adding now"
echo "${ENTRY}" >> /tmpRoot/etc.defaults/hosts
fi
fi
done
SED_PATH='/tmpRoot/usr/bin/sed'
${SED_PATH} -i '/synopkg restart SurveillanceStation/d' /tmpRoot/etc/crontab
# Add line to crontab, execute each minute
echo "5 0 * * * root synopkg restart SurveillanceStation #arc sspatch addon" >>/tmpRoot/etc/crontab
mkdir -p "/tmpRoot/usr/lib/systemd/system"
DEST="/tmpRoot/usr/lib/systemd/system/sspatch.service"
cat << EOF > ${DEST}
[Unit]
Description=addon sspatch
DefaultDependencies=no
IgnoreOnIsolate=true
After=multi-user.target
[Service]
User=root
Type=simple
Restart=on-failure
RestartSec=5s
ExecStart=/usr/bin/sspatch.sh
[Install]
WantedBy=multi-user.target
[X-Synology]
Author=Virtualization Team
EOF
mkdir -vp /tmpRoot/usr/lib/systemd/system/multi-user.target.wants
ln -vsf /usr/lib/systemd/system/sspatch.service /tmpRoot/usr/lib/systemd/system/multi-user.target.wants/sspatch.service
fi
# Check Sha256sum for Patch
if [ "$(sha256sum ${SSPATH}/lib/libssutils.so | cut -d' ' -f1)" = "b0fafefe820aa8ecd577313dff2ae22cf41a6ddf44051f01670c3b92ee04224d" ]; then
tar -zxf "${INPUTPATH}/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
fi
fi
elif [ "${1}" = "uninstall" ]; then
echo "Installing addon sspatch - ${1}"
# To-Do

View File

@ -1,6 +1,6 @@
version: 1
name: sspatch
description: "Dynamic 50 License Patch for SS 9.2.0-11289 (Non DVA)"
description: "Dynamic License Patch for SS 9.2.0-11289 (Non DVA)"
system: false
beta: true
all: