#!/bin/bash
cd /var/www/html/dates || exit 1

LAST="/tmp/dates_priority_catlists.md5"
CUR="$(php -r '$s=json_decode(file_get_contents("/var/www/html/dates/data/settings.json"),true); echo md5($s["priority_catlists"] ?? "");')"

if [ ! -f "$LAST" ]; then
  echo "$CUR" > "$LAST"
  exit 0
fi

OLD="$(cat "$LAST")"

if [ "$CUR" != "$OLD" ]; then
  echo "$CUR" > "$LAST"
  /var/www/html/dates/auto_update_channels.sh
fi
