From e9b11c717bc4f3bc38e97f38d4c92527a0e6e140 Mon Sep 17 00:00:00 2001 From: Vivek Kumar Dutta Date: Mon, 8 Dec 2025 11:06:16 +0530 Subject: [PATCH] parental-control: read urlbundle definition from json --- parental-control/Makefile | 2 +- .../files/lib/parentalcontrol/sync_bundles.sh | 26 ++++++++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/parental-control/Makefile b/parental-control/Makefile index 121f91956..9c18b03eb 100644 --- a/parental-control/Makefile +++ b/parental-control/Makefile @@ -11,7 +11,7 @@ LOCAL_DEV:=0 ifneq ($(LOCAL_DEV),1) PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://dev.iopsys.eu/network/parental-control.git -PKG_SOURCE_VERSION:=0aa48d99ff0e45111bc27f78df35159252164a78 +PKG_SOURCE_VERSION:=11777ff069888fc543c2501110313b654bbbfbc9 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz PKG_MIRROR_HASH:=skip endif diff --git a/parental-control/files/lib/parentalcontrol/sync_bundles.sh b/parental-control/files/lib/parentalcontrol/sync_bundles.sh index 03562e4c6..b9d0e13fa 100644 --- a/parental-control/files/lib/parentalcontrol/sync_bundles.sh +++ b/parental-control/files/lib/parentalcontrol/sync_bundles.sh @@ -87,6 +87,7 @@ update_bundle_file_from_url() { local success=0 while [ $attempt -le 3 ]; do if curl -s -o "$temp_file" "$download_url"; then + log_info "Download successful for $download_url" success=1 break else @@ -220,24 +221,33 @@ cleanup_bundle_files() { # Collect all download_url entries using config_foreach local urls="" get_download_url() { - local section="$1" - config_get url "$section" download_url - config_get_bool enable "$1" enable 1 + local enable url + + json_select "${2}" + + json_get_var url url + json_get_var enable enable + enable="${enable:-1}" if [ "${enable}" -eq 0 ]; then - # bundle is disabled + log_info "get_download_url: Skipping bundle ${name} not enabled" + json_select .. return 0 fi + url="${url#file://}" url="${url#https://}" url="${url#http://}" url="${url##*/}" # Get everything after the last '/' urls="$urls $url" + json_select .. } - config_load parentalcontrol - config_foreach get_download_url urlbundle + json_init + json_load_file "${URLBUNDLE_JSON}" + + json_for_each_item get_download_url "urlBundles" # Loop through all files in the directory for file in "$dir"/*; do @@ -306,11 +316,13 @@ handle_filter_for_bundles() { enable="${enable:-1}" if [ "${enable}" -eq 0 ]; then - log_info "Skipping bundle ${name} not enabled" + log_info "check_bundle_exists: Skipping bundle ${name} not enabled" + json_select .. return 0 fi handle_download_url "${url}" "${name}" + json_select .. } json_init