sspatch: finalize dynamic patch

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium 2024-08-21 23:35:12 +02:00
parent f180619154
commit 4b64ba15ac

View File

@ -38,8 +38,8 @@ if [ -d /var/packages/SurveillanceStation ]; then
ORG_FILE="${SSPATH}/target/lib/libssutils.so" ORG_FILE="${SSPATH}/target/lib/libssutils.so"
MITM_FILE="${SSPATH}/target/lib/libssutils.mitm.so" MITM_FILE="${SSPATH}/target/lib/libssutils.mitm.so"
JS_FILE="${SSPATH}/target/ui/sds.js" JS_FILE="${SSPATH}/target/ui/sds.js"
if [ ! -f "${SO_FILE}.so" ]; then if [ ! -f "${SO_FILE}" ]; then
echo "SSPatch: libssutils.so does not exist" echo "SSPatch: ${SO_FILE} does not exist"
exit 1 exit 1
fi fi
@ -47,15 +47,15 @@ if [ -d /var/packages/SurveillanceStation ]; then
sleep 5 sleep 5
# Check Sha256sum (DVA 92a8c8c75446daa7328a34acc67172e1f9f3af8229558766dbe5804a86c08a5e) # Check Sha256sum (DVA 92a8c8c75446daa7328a34acc67172e1f9f3af8229558766dbe5804a86c08a5e)
if [ "$(sha256sum "${SO_FILE}" | cut -d' ' -f1)" = "b0fafefe820aa8ecd577313dff2ae22cf41a6ddf44051f01670c3b92ee04224d" ]; then if [ "$(sha256sum ${SO_FILE} | cut -d' ' -f1)" = "b0fafefe820aa8ecd577313dff2ae22cf41a6ddf44051f01670c3b92ee04224d" ]; then
mv -f "${SO_FILE}" "${ORG_FILE}" mv -f "${SO_FILE}" "${ORG_FILE}"
cp -f "/usr/lib/libssutils.mitm.so" "${MITM_FILE}" cp -f "/usr/lib/libssutils.mitm.so" "${MITM_FILE}"
patchelf --add-needed ${ORG_FILE} ${MITM_FILE} patchelf --add-needed ${ORG_FILE} ${MITM_FILE}
mv -f "${MITM_FILE}" "${SO_FILE}" mv -f "${MITM_FILE}" "${SO_FILE}"
echo "SSPatch: libssutils.so is patched" echo "SSPatch: ${SO_FILE} is patched"
else else
if [ -f "${ORG_FILE}" ]; then if [ -f "${ORG_FILE}" ]; then
echo "SSPatch: libssutils.so is already patched" echo "SSPatch: ${SO_FILE} is already patched"
exit 0 exit 0
else else
echo "SSPatch: version not supported" echo "SSPatch: version not supported"
@ -65,7 +65,7 @@ if [ -d /var/packages/SurveillanceStation ]; then
# Change owner and permissions # Change owner and permissions
chown SurveillanceStation:SurveillanceStation "${SO_FILE}" chown SurveillanceStation:SurveillanceStation "${SO_FILE}"
chmod 0644 "${SO_FILE}" chmod 0644 "${SO_FILE}"
echo -e "SSPatch: libssutils.so permissions set" echo -e "SSPatch: ${SO_FILE} permissions set"
# Remove warning message # Remove warning message
sed -i 's/SYNO.API.RedirectToDSMByErrorCode=function(c){alert(SYNO.API.getErrorString(c));/SYNO.API.RedirectToDSMByErrorCode = () => { };/g' ${JS_FILE} sed -i 's/SYNO.API.RedirectToDSMByErrorCode=function(c){alert(SYNO.API.getErrorString(c));/SYNO.API.RedirectToDSMByErrorCode = () => { };/g' ${JS_FILE}