diff --git a/amepatch/all/usr/bin/amepatch.sh b/amepatch/all/usr/bin/amepatch.sh index 1e91016..7ccd24f 100755 --- a/amepatch/all/usr/bin/amepatch.sh +++ b/amepatch/all/usr/bin/amepatch.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright (C) 2023 AuxXxilium +# Copyright (C) 2024 AuxXxilium # # This is free software, licensed under the MIT License. # See /LICENSE for more information. @@ -18,6 +18,17 @@ if [ -d "/var/packages/CodecPack" ]; then so_backup="$ame_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" + lic_patched="/usr/arc/ame_license.patched" + + if [ -f "$lic_patched" ]; then + if "$ame_path/bin/synoame-bin-auto-install-needed-codec"; then + echo -e "AME Patch: Already patched! -> Codec downloaded!" + exit 0 + else + echo -e "AME Patch: Already patched! -> Codec download failed!" + exit 1 + fi + fi if [ ! -f "$so_backup" ]; then cp -p "$so" "$so_backup" @@ -38,7 +49,8 @@ if [ -d "/var/packages/CodecPack" ]; 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!" + echo -e "AME Patch: Unsupported version!" + exit 1 fi for ((i = 0; i < ${#hex_values[@]}; i++)); do @@ -57,11 +69,12 @@ if [ -d "/var/packages/CodecPack" ]; then if "$ame_path/bin/synoame-bin-check-license"; then echo -e "AME Patch: Downloading Codec!" + echo "true" >"${lic_patched}" if "$ame_path/bin/synoame-bin-auto-install-needed-codec"; then echo -e "AME Patch: Successful!" exit 0 else - echo -e "AME Patch: Unsuccessful!" + echo -e "AME Patch: Failed!" exit 1 fi else @@ -71,10 +84,12 @@ if [ -d "/var/packages/CodecPack" ]; then if [ -f "$lic_backup" ]; then mv -f "$lic_backup" "$lic" fi + rm -f "$lic_patched" echo -e "AME Patch: Backup restored!" exit 1 fi else echo -e "AME Patch: CodecPack not found!" + rm -f "$lic_patched" exit 1 fi \ No newline at end of file diff --git a/amepatch/install.sh b/amepatch/install.sh index 2cf10a5..2179386 100755 --- a/amepatch/install.sh +++ b/amepatch/install.sh @@ -1,6 +1,6 @@ #!/usr/bin/env ash # -# Copyright (C) 2023 AuxXxilium +# Copyright (C) 2024 AuxXxilium # # This is free software, licensed under the MIT License. # See /LICENSE for more information. @@ -17,12 +17,13 @@ if [ "${1}" = "late" ]; then cat <${DEST} [Unit] Description=addon amepatch -Wants=smpkg-custom-install.service -After=smpkg-custom-install.service +After=multi-user.target [Service] -Type=oneshot -RemainAfterExit=yes +User=root +Type=simple +Restart=on-failure +RestartSec=5 ExecStart=/usr/bin/amepatch.sh [Install] diff --git a/sspatch/all/usr/bin/sspatch.sh b/sspatch/all/usr/bin/sspatch.sh index 8b93165..77b06de 100755 --- a/sspatch/all/usr/bin/sspatch.sh +++ b/sspatch/all/usr/bin/sspatch.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright (C) 2023 AuxXxilium +# Copyright (C) 2024 AuxXxilium # # This is free software, licensed under the MIT License. # See /LICENSE for more information. @@ -18,12 +18,20 @@ function copy_file() { chown SurveillanceStation:SurveillanceStation "${target}/${file}" chmod "${mode}" "${target}/${file}" else - echo "sspatch: ${file} not found" + if [ "${file}" == "ssrtmpclientd" ]; then + echo "sspatch: ${file} not found, skipping" + return 0 + else + rm -f "${ss_lic_patched}" + echo "sspatch: ${file} not found, aborting" + exit 1 + fi fi } SSPATH="/var/packages/SurveillanceStation/target" PATCHPATH="/usr/arc" +ss_lic_patched="${PATCHPATH}/ss_license.patched" if [ -d "${SSPATH}" ]; then echo "sspatch: SurveillanceStation found" @@ -50,6 +58,11 @@ if [ -d "${SSPATH}" ]; then fi done + if [ -f "${ss_lic_patched}" ]; then + echo "sspatch: SurveillanceStation already patched" + exit 0 + fi + /usr/syno/bin/synopkg stop SurveillanceStation sleep 5 @@ -71,21 +84,25 @@ if [ -d "${SSPATH}" ]; then SSPATCH="true" else echo "sspatch: SurveillanceStation Version not supported" - exit 1 + exit 0 fi -if [ "${SSPATCH}" == "true" ]; then - copy_file ${SSPATH}/lib libssutils.so ${PATCHPATH} 0644 - copy_file ${SSPATH}/sbin sscmshostd ${PATCHPATH} 0755 - copy_file ${SSPATH}/sbin sscored ${PATCHPATH} 0755 - copy_file ${SSPATH}/sbin ssdaemonmonitord ${PATCHPATH} 0755 - copy_file ${SSPATH}/sbin ssexechelperd ${PATCHPATH} 0755 - copy_file ${SSPATH}/sbin ssroutined ${PATCHPATH} 0755 - copy_file ${SSPATH}/sbin ssmessaged ${PATCHPATH} 0755 -fi + if [ "${SSPATCH}" == "true" ]; then + copy_file ${SSPATH}/lib libssutils.so ${PATCHPATH} 0644 + copy_file ${SSPATH}/sbin sscmshostd ${PATCHPATH} 0755 + copy_file ${SSPATH}/sbin sscored ${PATCHPATH} 0755 + copy_file ${SSPATH}/sbin ssdaemonmonitord ${PATCHPATH} 0755 + copy_file ${SSPATH}/sbin ssexechelperd ${PATCHPATH} 0755 + copy_file ${SSPATH}/sbin ssroutined ${PATCHPATH} 0755 + copy_file ${SSPATH}/sbin ssmessaged ${PATCHPATH} 0755 + copy_file ${SSPATH}/sbin ssrtmpclientd ${PATCHPATH} 0755 + echo "true" >"${ss_lic_patched}" + fi sleep 5 /usr/syno/bin/synopkg start SurveillanceStation +else + rm -f "${ss_lic_patched}" fi exit 0 \ No newline at end of file diff --git a/sspatch/install.sh b/sspatch/install.sh index 95aec81..a320b79 100755 --- a/sspatch/install.sh +++ b/sspatch/install.sh @@ -1,6 +1,6 @@ #!/usr/bin/env ash # -# Copyright (C) 2023 AuxXxilium +# Copyright (C) 2024 AuxXxilium # # This is free software, licensed under the MIT License. # See /LICENSE for more information. @@ -21,19 +21,18 @@ if [ "${1}" = "late" ]; then cat <${DEST} [Unit] Description=addon sspatch -Wants=smpkg-custom-install.service -After=smpkg-custom-install.service +After=multi-user.target +After=amepatch.service [Service] -Type=oneshot -RemainAfterExit=yes +User=root +Type=simple +Restart=on-failure +RestartSec=5 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