From b39aee32fcc51ad595756a04a13ca6f53d0ae2f0 Mon Sep 17 00:00:00 2001 From: kx1t <15090643+kx1t@users.noreply.github.com> Date: Sat, 16 Dec 2023 07:30:10 -0500 Subject: [PATCH] Add REFRESHRATE support --- rootfs/scripts/update-plugins | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/rootfs/scripts/update-plugins b/rootfs/scripts/update-plugins index f33de9f..a411fbd 100755 --- a/rootfs/scripts/update-plugins +++ b/rootfs/scripts/update-plugins @@ -64,7 +64,7 @@ then for file in /tmp/AIS-catcher/plugins/* do file="${file##*/}" - if [[ -f /data/plugins/${file} ]] && ! diff "${file}" "/data/plugins/${file}" >/dev/null 2>&1 + if [[ f /data/plugins/${file} ]] && ! diff "${file}" "/data/plugins/${file}" >/dev/null 2>&1 then # Copy plugin file if it's newer but leave a backup in place cp --backup=numbered -u "/tmp/AIS-catcher/plugins/${file}" "/data/plugins/${file}" @@ -76,6 +76,17 @@ else cp -n /tmp/AIS-catcher/plugins/* /data/plugins/ >/dev/null 2>&1 fi +# update or create the refreshrate.pjs plugin if needed +if [[ -n "${REFRESHRATE}" ]]; then + if [[ -f /data/plugins/refreshrate.pjs ]]; then + sed -i "s/^\s*#*\s*refreshIntervalMs.*\$/refreshIntervalMs = $REFRESHRATE/Ig" /data/plugins/refreshrate.pjs + else + echo "refreshIntervalMs = $REFRESHRATE/Ig" > /data/plugins/refreshrate.pjs + fi +else + rm -f /data/plugins/refreshrate.pjs +fi + # remove any plugin backups older than BACKUP_RETENTION_TIME (or 30 days if undefined) find /data/plugins -name '*.~*~' -mtime +"${BACKUP_RETENTION_TIME:-30}" -exec rm {} \;