mirror of
https://github.com/AuxXxilium/arc-addons.git
synced 2024-11-23 21:50:52 +07:00
amepatch: readd modified version
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
parent
7c70ba5a98
commit
3f6a2a38b8
83
amepatch/all/usr/bin/amepatch.sh
Executable file
83
amepatch/all/usr/bin/amepatch.sh
Executable file
@ -0,0 +1,83 @@
|
|||||||
|
#!/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/CodecPack" ]; then
|
||||||
|
/usr/syno/etc/rc.sysv/apparmor.sh remove_packages_profile 0 CodecPack
|
||||||
|
|
||||||
|
cp_usr_path="/var/packages/CodecPack/target/usr"
|
||||||
|
values=('669066909066906690' 'B801000000' '30')
|
||||||
|
hex_values=('1F28' '48F5' '4921' '4953' '4975' '9AC8')
|
||||||
|
indices=(0 1 1 1 1 2)
|
||||||
|
so="$cp_usr_path/lib/libsynoame-license.so"
|
||||||
|
so_backup="$cp_usr_path/lib/libsynoame-license.so.orig"
|
||||||
|
lic="/usr/syno/etc/license/data/ame/offline_license.json"
|
||||||
|
lic_backup="/usr/syno/etc/license/data/ame/offline_license.json.orig"
|
||||||
|
licsig="/usr/syno/etc/license/data/ame/offline_license.sig"
|
||||||
|
licsig_backup="/usr/syno/etc/license/data/ame/offline_license.sig.orig"
|
||||||
|
|
||||||
|
if [ ! -f "$so_backup" ]; then
|
||||||
|
cp -p "$so" "$so_backup"
|
||||||
|
fi
|
||||||
|
if [ ! -f "$lic_backup" ]; then
|
||||||
|
cp -p "$lic" "$lic_backup"
|
||||||
|
fi
|
||||||
|
if [ ! -f "$licsig_backup" ]; then
|
||||||
|
cp -p "$licsig" "$licsig_backup"
|
||||||
|
fi
|
||||||
|
|
||||||
|
hash_to_check="$(md5sum -b "$so" | awk '{print $1}')"
|
||||||
|
|
||||||
|
if [ "$hash_to_check" = "fcc1084f4eadcf5855e6e8494fb79e23" ]; then
|
||||||
|
hex_values=('1F28' '48F5' '4921' '4953' '4975' '9AC8')
|
||||||
|
content='[{"appType": 14, "appName": "ame", "follow": ["device"], "server_time": 1666000000, "registered_at": 1651000000, "expireTime": 0, "status": "valid", "firstActTime": 1651000001, "extension_gid": null, "licenseCode": "0", "duration": 1576800000, "attribute": {"codec": "hevc", "type": "free"}, "licenseContent": 1}, {"appType": 14, "appName": "ame", "follow": ["device"], "server_time": 1666000000, "registered_at": 1651000000, "expireTime": 0, "status": "valid", "firstActTime": 1651000001, "extension_gid": null, "licenseCode": "0", "duration": 1576800000, "attribute": {"codec": "aac", "type": "free"}, "licenseContent": 1}]'
|
||||||
|
elif [ "$hash_to_check" = "923fd0d58e79b7dc0f6c377547545930" ]; then
|
||||||
|
hex_values=('1F28' '48F5' '4921' '4953' '4975' '9AC8')
|
||||||
|
content='[{"appType": 14, "appName": "ame", "follow": ["device"], "server_time": 1666000000, "registered_at": 1651000000, "expireTime": 0, "status": "valid", "firstActTime": 1651000001, "extension_gid": null, "licenseCode": "0", "duration": 1576800000, "attribute": {"codec": "hevc", "type": "free"}, "licenseContent": 1}, {"appType": 14, "appName": "ame", "follow": ["device"], "server_time": 1666000000, "registered_at": 1651000000, "expireTime": 0, "status": "valid", "firstActTime": 1651000001, "extension_gid": null, "licenseCode": "0", "duration": 1576800000, "attribute": {"codec": "aac", "type": "free"}, "licenseContent": 1}]'
|
||||||
|
elif [ "$hash_to_check" = "09e3adeafe85b353c9427d93ef0185e9" ]; then
|
||||||
|
hex_values=('3718' '60A5' '60D1' '6111' '6137' 'B5F0')
|
||||||
|
content='[{"attribute": {"codec": "hevc", "type": "free"}, "status": "valid", "extension_gid": null, "expireTime": 0, "appName": "ame", "follow": ["device"], "duration": 1576800000, "appType": 14, "licenseContent": 1, "registered_at": 1649315995, "server_time": 1685421618, "firstActTime": 1649315995, "licenseCode": "0"}, {"attribute": {"codec": "aac", "type": "free"}, "status": "valid", "extension_gid": null, "expireTime": 0, "appName": "ame", "follow": ["device"], "duration": 1576800000, "appType": 14, "licenseContent": 1, "registered_at": 1649315995, "server_time": 1685421618, "firstActTime": 1649315995, "licenseCode": "0"}]'
|
||||||
|
else
|
||||||
|
echo "MD5 mismatch - Already patched or unsupported version!"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
for ((i = 0; i < ${#hex_values[@]}; i++)); do
|
||||||
|
offset=$(( 0x${hex_values[i]} + 0x8000 ))
|
||||||
|
value=${values[indices[i]]}
|
||||||
|
printf '%s' "$value" | xxd -r -p | dd of="$so" bs=1 seek="$offset" conv=notrunc
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
echo -e "AME Patch: Error while writing to file!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
mkdir -p "$(dirname "${lic}")"
|
||||||
|
rm -f "${lic}"
|
||||||
|
echo "${content}" >"${lic}"
|
||||||
|
|
||||||
|
if "$cp_usr_path/bin/synoame-bin-check-license"; then
|
||||||
|
echo -e "AME Patch: Downloading Codec!"
|
||||||
|
if "$cp_usr_path/bin/synoame-bin-auto-install-needed-codec"; then
|
||||||
|
echo -e "AME Patch: Successful!"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo -e "AME Patch: Unsuccessful!"
|
||||||
|
if [ -f "$so_backup" ]; then
|
||||||
|
mv -f "$so_backup" "$so"
|
||||||
|
fi
|
||||||
|
if [ -f "$lic_backup" ]; then
|
||||||
|
mv -f "$lic_backup" "$lic"
|
||||||
|
fi
|
||||||
|
if [ -f "$licsig_backup" ]; then
|
||||||
|
mv -f "$licsig_backup" "$licsig"
|
||||||
|
fi
|
||||||
|
echo -e "AME Patch: Backup restored!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
exit 0
|
48
amepatch/install.sh
Executable file
48
amepatch/install.sh
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
#!/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.
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ "${1}" = "late" ]; then
|
||||||
|
echo "Installing addon amepatch - ${1}"
|
||||||
|
mkdir -p "/tmpRoot/usr/arc/addons/"
|
||||||
|
cp -vf "${0}" "/tmpRoot/usr/arc/addons/"
|
||||||
|
cp -vf /usr/bin/amepatch.sh /tmpRoot/usr/bin/amepatch.sh
|
||||||
|
|
||||||
|
mkdir -p "/tmpRoot/usr/lib/systemd/system"
|
||||||
|
DEST="/tmpRoot/usr/lib/systemd/system/amepatch.service"
|
||||||
|
cat > ${DEST} <<EOF
|
||||||
|
[Unit]
|
||||||
|
Description=addon amepatch
|
||||||
|
After=multi-user.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5s
|
||||||
|
RemainAfterExit=yes
|
||||||
|
ExecStartPre=/usr/bin/amepatch.sh
|
||||||
|
ExecStart=/usr/syno/bin/synopkg restart CodecPack
|
||||||
|
ExecStartPost=/usr/bin/systemctl stop amepatch
|
||||||
|
|
||||||
|
[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/amepatch.service /tmpRoot/usr/lib/systemd/system/multi-user.target.wants/amepatch.service
|
||||||
|
elif [ "${1}" = "uninstall" ]; then
|
||||||
|
echo "Installing addon amepatch - ${1}"
|
||||||
|
|
||||||
|
rm -f "/tmpRoot/usr/lib/systemd/system/multi-user.target.wants/amepatch.service"
|
||||||
|
rm -f "/tmpRoot/usr/lib/systemd/system/amepatch.service"
|
||||||
|
rm -f "/tmpRoot/usr/bin/amepatch.sh"
|
||||||
|
|
||||||
|
[ ! -f "/tmpRoot/usr/arc/revert.sh" ] && echo '#!/usr/bin/env bash' >/tmpRoot/usr/arc/revert.sh && chmod +x /tmpRoot/usr/arc/revert.sh
|
||||||
|
echo "rm -f /usr/bin/amepatch.sh" >>/tmpRoot/usr/arc/revert.sh
|
||||||
|
fi
|
19
amepatch/manifest.yml
Normal file
19
amepatch/manifest.yml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
version: 1
|
||||||
|
name: amepatch
|
||||||
|
description: "Dynamic Licensepatch for AME (depends on Arc Patch)"
|
||||||
|
system: false
|
||||||
|
beta: false
|
||||||
|
all:
|
||||||
|
install-script: "install.sh"
|
||||||
|
copy: "all"
|
||||||
|
apollolake: true
|
||||||
|
broadwell: true
|
||||||
|
broadwellnk: true
|
||||||
|
broadwellnkv2: true
|
||||||
|
broadwellntbap: true
|
||||||
|
denverton: true
|
||||||
|
geminilake: true
|
||||||
|
purley: true
|
||||||
|
v1000: true
|
||||||
|
r1000: true
|
||||||
|
epyc7002: true
|
143
sspatch/all/usr/bin/S82surveillance.sh
Executable file
143
sspatch/all/usr/bin/S82surveillance.sh
Executable file
@ -0,0 +1,143 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Copyright (c) 2014 Synology Inc. All rights reserved.
|
||||||
|
|
||||||
|
SURVEILLANCE_INC_SCRP=/var/packages/SurveillanceStation/scripts/SurveillanceStationCommon
|
||||||
|
. ${SURVEILLANCE_INC_SCRP}
|
||||||
|
|
||||||
|
SS_BIN_DIR="${SS_TARGET_DIR}/bin"
|
||||||
|
SSCTL="${SS_BIN_DIR}/ssctl"
|
||||||
|
SS_DBG_LOG_ROTATE_CONF="/usr/local/etc/logrotate.d/SurveillanceStation"
|
||||||
|
|
||||||
|
UpdateSSDbgLogRotateConf()
|
||||||
|
{
|
||||||
|
cat > $SS_DBG_LOG_ROTATE_CONF <<EOF
|
||||||
|
/var/log/surveillance/surveillance.log /var/log/surveillance/ssnotification.log
|
||||||
|
/var/log/surveillance/localdisplay.log /var/log/surveillance/ssrotate.log
|
||||||
|
/var/log/surveillance/ssdevice.log {
|
||||||
|
size 10M
|
||||||
|
rotate 4
|
||||||
|
missingok
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckPgsqlService()
|
||||||
|
{
|
||||||
|
if [ true == $(IsDSM7) ]; then
|
||||||
|
echo $(IsSystemdUnitActivated "pqsql")
|
||||||
|
else
|
||||||
|
${SYNO_SERVICE_TOOL} --is-enabled pgsql > /dev/null 2>&1
|
||||||
|
if [ $? -ne ${RET_SYNO_SERVICE_ENABLED} ]; then
|
||||||
|
echo false
|
||||||
|
else
|
||||||
|
echo true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
Start()
|
||||||
|
{
|
||||||
|
SSDebugLog "Start Surveillance [$SURVEILLANCE_PKG_VERSION] begin."
|
||||||
|
|
||||||
|
local Ret
|
||||||
|
|
||||||
|
UpdateSSDbgLogRotateConf
|
||||||
|
|
||||||
|
if [ true == $(IsNonRecordingMode) -a true == $(IsServiceDataLinkAlive) ]; then
|
||||||
|
rm -f ${SS_NON_RECORDING_FILE}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ false == $(IsNonRecordingMode) ]; then
|
||||||
|
CheckToCreateRecDB
|
||||||
|
Ret=$?
|
||||||
|
if [ 0 -ne ${Ret} ]; then
|
||||||
|
SSDebugLog "Failed to prepare share folder."
|
||||||
|
UpdateNonRecordingMode
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f ${SS_REC_DB} ]; then
|
||||||
|
SSDebugLog "Recording db not found."
|
||||||
|
UpdateNonRecordingMode
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ${USE_SQLITE} == false ]; then
|
||||||
|
if [ false == $(CheckPgsqlService) ]; then
|
||||||
|
SSDebugLog "PGSQL is not enabled"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ false == $(HasSSPgsqlData) ]; then
|
||||||
|
SSDebugLog "PGSQL db have not been created yet."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ ! -f ${SS_SYSTEM_DB} ]; then
|
||||||
|
SSDebugLog "System db not found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
${SSCTL} start
|
||||||
|
sh /var/packages/SurveillanceStation/target/scripts/license.sh > /dev/null 2>&1 & echo $!
|
||||||
|
|
||||||
|
SSDebugLog "Start Surveillance [$SURVEILLANCE_PKG_VERSION] end."
|
||||||
|
}
|
||||||
|
|
||||||
|
Stop()
|
||||||
|
{
|
||||||
|
SSDebugLog "Stop Surveillance [$SURVEILLANCE_PKG_VERSION] begin."
|
||||||
|
|
||||||
|
if [ ${USE_SQLITE} == false ]; then
|
||||||
|
if [ false == $(HasSSPgsqlData) ]; then
|
||||||
|
echo "Surveillance: DB is stopped before Surveillance stops"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ ! -f ${SS_SYSTEM_DB} ]; then
|
||||||
|
echo "Surveillance System DB not found."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
${SSCTL} stop
|
||||||
|
sudo pkill -9 -f /var/packages/SurveillanceStation/target/scripts/license.sh
|
||||||
|
|
||||||
|
SSDebugLog "Stop Surveillance [$SURVEILLANCE_PKG_VERSION] end"
|
||||||
|
}
|
||||||
|
|
||||||
|
Restart()
|
||||||
|
{
|
||||||
|
Stop
|
||||||
|
sleep 1
|
||||||
|
Start
|
||||||
|
}
|
||||||
|
|
||||||
|
TriggerSctrl()
|
||||||
|
{
|
||||||
|
${SSCTL} "$1" "$2" "$3"
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
PackageInfoGet
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
"start")
|
||||||
|
Start
|
||||||
|
;;
|
||||||
|
"stop")
|
||||||
|
Stop
|
||||||
|
;;
|
||||||
|
"restart")
|
||||||
|
Restart
|
||||||
|
;;
|
||||||
|
"trigger-ssctl")
|
||||||
|
TriggerSctrl "$2" "$3" "$4"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 start|stop|restart|share_folder"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
7
sspatch/all/usr/bin/license.sh
Executable file
7
sspatch/all/usr/bin/license.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
sleep 3600
|
||||||
|
/var/packages/SurveillanceStation/target/bin/ssctl restart
|
||||||
|
|
||||||
|
done
|
68
sspatch/install.sh
Executable file
68
sspatch/install.sh
Executable file
@ -0,0 +1,68 @@
|
|||||||
|
#!/usr/bin/env ash
|
||||||
|
|
||||||
|
if [ "${1}" = "late" ]; then
|
||||||
|
if [ -d /tmpRoot/var/packages/SurveillanceStation ]; then
|
||||||
|
echo "Installing addon sspatch - ${1}"
|
||||||
|
mkdir -p "/tmpRoot/usr/arc/addons/"
|
||||||
|
cp -vf "${0}" "/tmpRoot/usr/arc/addons/"
|
||||||
|
|
||||||
|
# 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
|
||||||
|
SO_FILE="/tmpRoot/usr/lib/libssutils.so"
|
||||||
|
[ ! -f "${SO_FILE}" ] && echo "SSPatch: libssutils.so does not exist" && exit 0
|
||||||
|
|
||||||
|
# Check Sha256sum
|
||||||
|
if [ "$(sha256sum "${SO_FILE}" | cut -d' ' -f1)" = "81b64d65f4a2a65626f9280ba43ea43f031a239af3152b859b79e1b5124cc6e3" ]; then
|
||||||
|
PATCH="8548ffffff41be43000000e93dffffff/8548ffffff41be7b000000e93dffffff"
|
||||||
|
cp -vf "${SO_FILE}" "${SO_FILE}.bak"
|
||||||
|
cp -f "${SO_FILE}" "${SO_FILE}.tmp"
|
||||||
|
xxd -c $(xxd -p "${SO_FILE}.tmp" 2>/dev/null | wc -c) -p "${SO_FILE}.tmp" 2>/dev/null |
|
||||||
|
sed "s/${PATCH}/" |
|
||||||
|
xxd -r -p >"${SO_FILE}" 2>/dev/null
|
||||||
|
rm -f "${SO_FILE}.tmp"
|
||||||
|
echo "SSPatch: libssutils.so is patched"
|
||||||
|
elif [ "$(sha256sum "${SO_FILE}" | cut -d' ' -f1)" = "6a9636880dde48c6d7f0dc6f6337f33960fa12df67a8ed3a97aa9ff6fe45ce7d" ]; then
|
||||||
|
PATCH="850b010000e8b684e5ff83f80141bc7b/850b010000e8b684e5ff83f80141bc43"
|
||||||
|
cp -vf "${SO_FILE}" "${SO_FILE}.bak"
|
||||||
|
cp -f "${SO_FILE}" "${SO_FILE}.tmp"
|
||||||
|
xxd -c $(xxd -p "${SO_FILE}.tmp" 2>/dev/null | wc -c) -p "${SO_FILE}.tmp" 2>/dev/null |
|
||||||
|
sed "s/${PATCH}/" |
|
||||||
|
xxd -r -p >"${SO_FILE}" 2>/dev/null
|
||||||
|
rm -f "${SO_FILE}.tmp"
|
||||||
|
echo "SSPatch: libssutils.so is patched"
|
||||||
|
else
|
||||||
|
if [ -f "${SO_FILE}.bak" ]; then
|
||||||
|
echo "SSPatch: libssutils.so is already patched"
|
||||||
|
else
|
||||||
|
echo "SSPatch: version not supported"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
cp -vf /usr/bin/license.sh /tmpRoot/usr/bin/license.sh
|
||||||
|
cp -vf /usr/bin/S82surveillance.sh /tmpRoot/usr/bin/S82surveillance.sh
|
||||||
|
fi
|
||||||
|
elif [ "${1}" = "uninstall" ]; then
|
||||||
|
echo "Installing addon sspatch - ${1}"
|
||||||
|
# To-Do
|
||||||
|
fi
|
19
sspatch/manifest.yml
Normal file
19
sspatch/manifest.yml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
version: 1
|
||||||
|
name: sspatch
|
||||||
|
description: "Dynamic License Patch for SS! (Not for DVA)"
|
||||||
|
system: false
|
||||||
|
beta: true
|
||||||
|
all:
|
||||||
|
install-script: "install.sh"
|
||||||
|
copy: "all"
|
||||||
|
apollolake: true
|
||||||
|
broadwell: true
|
||||||
|
broadwellnk: true
|
||||||
|
broadwellnkv2: true
|
||||||
|
broadwellntbap: true
|
||||||
|
denverton: true
|
||||||
|
geminilake: true
|
||||||
|
purley: true
|
||||||
|
v1000: true
|
||||||
|
r1000: true
|
||||||
|
epyc7002: true
|
Loading…
Reference in New Issue
Block a user