parental-control: read urlbundle definition from json

This commit is contained in:
Vivek Kumar Dutta 2025-12-08 11:06:16 +05:30
parent d13040ed0e
commit e9b11c717b
No known key found for this signature in database
GPG key ID: 4E09F5AD8265FD4C
2 changed files with 20 additions and 8 deletions

View file

@ -11,7 +11,7 @@ LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1) ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/network/parental-control.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_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip PKG_MIRROR_HASH:=skip
endif endif

View file

@ -87,6 +87,7 @@ update_bundle_file_from_url() {
local success=0 local success=0
while [ $attempt -le 3 ]; do while [ $attempt -le 3 ]; do
if curl -s -o "$temp_file" "$download_url"; then if curl -s -o "$temp_file" "$download_url"; then
log_info "Download successful for $download_url"
success=1 success=1
break break
else else
@ -220,24 +221,33 @@ cleanup_bundle_files() {
# Collect all download_url entries using config_foreach # Collect all download_url entries using config_foreach
local urls="" local urls=""
get_download_url() { get_download_url() {
local section="$1" local enable url
config_get url "$section" download_url
config_get_bool enable "$1" enable 1 json_select "${2}"
json_get_var url url
json_get_var enable enable
enable="${enable:-1}"
if [ "${enable}" -eq 0 ]; then if [ "${enable}" -eq 0 ]; then
# bundle is disabled log_info "get_download_url: Skipping bundle ${name} not enabled"
json_select ..
return 0 return 0
fi fi
url="${url#file://}" url="${url#file://}"
url="${url#https://}" url="${url#https://}"
url="${url#http://}" url="${url#http://}"
url="${url##*/}" # Get everything after the last '/' url="${url##*/}" # Get everything after the last '/'
urls="$urls $url" urls="$urls $url"
json_select ..
} }
config_load parentalcontrol json_init
config_foreach get_download_url urlbundle json_load_file "${URLBUNDLE_JSON}"
json_for_each_item get_download_url "urlBundles"
# Loop through all files in the directory # Loop through all files in the directory
for file in "$dir"/*; do for file in "$dir"/*; do
@ -306,11 +316,13 @@ handle_filter_for_bundles() {
enable="${enable:-1}" enable="${enable:-1}"
if [ "${enable}" -eq 0 ]; then 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 return 0
fi fi
handle_download_url "${url}" "${name}" handle_download_url "${url}" "${name}"
json_select ..
} }
json_init json_init