Compare commits

...

2 Commits

Author SHA1 Message Date
Mohd Husaam Mehdi
078d7f237c parental-control: use apps partition to store bundle related files 2025-08-13 21:32:09 +05:30
Mohd Husaam Mehdi
1337ba6d57 parental-control: fix bug in firewall script 2025-08-13 21:31:39 +05:30
5 changed files with 19 additions and 17 deletions

View File

@@ -5,19 +5,19 @@
enabled="$(uci -q get parentalcontrol.globals.enable)"
urlfilter="$(uci -q get parentalcontrol.globals.urlfilter)"
# if parentalcontrol is enabled, add the rules, else remove them
# if parentalcontrol is enabled, add the rules, else remove them
if [ "${enabled}" -eq "1" ]; then
# this is for internet_access and profile_bedtime_schedule sections
add_internet_schedule_rules
# this is for urlfilter daemon
add_iptables_nfqueue_rules
if [ "${urlfilter}" -eq "1" ]; then
# this for internet_access and profile_bedtime_schedule sections
add_internet_schedule_rules
add_iptables_nfqueue_rules
fi
else
# remove internet_access and profile_bedtime_schedule rules
remove_internet_schedule_rules
# remove urlfilter daemon rules
remove_iptables_nfqueue_rules
if [ "${urlfilter}" -eq "1" ]; then
# remove internet_access and profile_bedtime_schedule rules
remove_internet_schedule_rules
remove_iptables_nfqueue_rules
fi
fi

View File

@@ -83,14 +83,13 @@ start_service() {
config_load parentalcontrol
validate_global_section
[ -n "${bundle_path}" ] && mkdir -p ${bundle_path}
# add default bundles
process_default_bundles
# add firewall rules
configure_fw_rules
if [ "${urlfilter}" -eq "1" ]; then
if [ "${urlfilter}" -eq "1" ] && [ -d "/apps" ]; then
# add default bundles
[ -n "${bundle_path}" ] && mkdir -p ${bundle_path}
process_default_bundles
enable_urlfilter_dm
else
disable_urlfilter_dm
@@ -100,7 +99,7 @@ start_service() {
# then /tmp/dhcp.leases will be empty until clients try to get a lease,
# in that case, hostnames will not be processed by the daemon,
# for this we copy /tmp/dhcp.leases to /etc/parentalcontrol/dhcp.leases
# which will be persistent acrros reboots and upgrade where settings are kept
# which will be persistent across reboots and upgrade (with keep settings)
# and will be used as a backup in case /tmp/dhcp.leases is empty
copy_dhcp_leases

View File

@@ -1,5 +1,8 @@
#!/bin/sh
# if /apps partition is not present then we don't support urlfiltering
[ -d "/apps" ] || exit 0
COUNT=1
add_urlbundle()

View File

@@ -13,7 +13,7 @@ IP_RULE=""
ACL_FILE=""
parentalcontrol_ipv4_forward=""
parentalcontrol_ipv6_forward=""
default_bundle_dir="/tmp/parentalcontrol/default/"
default_bundle_dir="/apps/parentalcontrol/default/"
bundle_archive="/etc/parentalcontrol/urlbundles.tar.xz"
log() {

View File

@@ -8,7 +8,7 @@ LOCKFILE="/tmp/sync_bundles.lock"
# if its a remote file, then it would be downloaded and placed in bundle_dir
bundle_path="$(uci -q get parentalcontrol.globals.bundle_path)"
if [ -z "${bundle_path}" ]; then
bundle_path="/tmp/parentalcontrol"
bundle_path="/apps/parentalcontrol"
fi
stringstore_dir="${bundle_path}/stringstore"
@@ -227,8 +227,8 @@ handle_filter_for_bundles() {
local urlfilter
urlfilter="$(uci -q get parentalcontrol.globals.urlfilter)"
if [ "${urlfilter}" -ne "1" ]; then
logger -p info "urlbundle not supported"
# if urlfilter is not enabled or apps partition is not present, then return
if [ "${urlfilter}" -ne "1" ] || [ ! -d "/apps" ]; then
return
fi