amepatch: rewrite service

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium 2024-06-28 19:33:13 +02:00
parent 92fa37759b
commit 688f7a24fd

View File

@ -12,22 +12,23 @@ if [ "${1}" = "late" ]; then
cp -vf "${0}" "/tmpRoot/usr/arc/addons/"
cp -vf /usr/bin/amepatch.sh /tmpRoot/usr/bin/amepatch.sh
if [ -f "/usr/bin/codecpatch.sh" ]; then
echo -e "AME Patch: Codecpatch found -> skipping"
else
mkdir -p "/tmpRoot/usr/lib/systemd/system"
DEST="/tmpRoot/usr/lib/systemd/system/amepatch.service"
echo "[Unit]" >${DEST}
echo "Description=addon amepatch" >>${DEST}
echo "After=multi-user.target" >>${DEST}
echo >>${DEST}
echo "[Service]" >>${DEST}
echo "Type=oneshot" >>${DEST}
echo "RemainAfterExit=yes" >>${DEST}
echo "ExecStart=/usr/bin/amepatch.sh" >>${DEST}
echo >>${DEST}
echo "[Install]" >>${DEST}
echo "WantedBy=multi-user.target" >>${DEST}
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/syno/bin/systemctl stop amepatch
[Install]
WantedBy=multi-user.target
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