Parental control the SH way

  • ATTENTION! As of November 1, 2020, you are not able to reply to threads 6 months after the thread is opened if there are more than 500 posts in the thread.
    Threads will not be locked, so posts may still be edited by their authors.
    Just start a new thread on the topic to post if you get an error message when trying to reply to a thread.

itpp20

Regular Contributor
My own confoxtal the easy way (at least for me);

#!/bin/sh

# /jffs/scripts/services-start

cru a blockdev "30 22 * * sun,mon,tue,wed,thu sh /jffs/scripts/blockdev.sh"
cru a relall "0 7 * * * sh /jffs/scripts/relall.sh"
cru a relallwk "28 0 * * sun,sat sh /jffs/scripts/relall.sh"
cru a blockdevwk "30 0 * * sun,sat sh /jffs/scripts/blockdev.sh"


Control script:

#!/bin/bash

# /jffs/scripts/blockdev.sh

echo "#!/bin/bash">/jffs/scripts/relall.sh
echo "">>/jffs/scripts/relall.sh
chmod a+rx /jffs/scripts/relall.sh

# copy below block for other devices, copy MAC address from dhcp list from GUI asus

# Samsung(android)_My_Son
mmac=AA:BB:7B:C6:55:44
vmac=$(echo "$mmac" | awk '{print tolower($0)}')
kmmac=$(cat /var/lib/misc/dnsmasq.leases | grep "$vmac" | cut -d" " -f3)
if ! [ -z "${kmmac}" ]; then iptables -I FORWARD -s $kmmac -j DROP; fi
if ! [ -z "${kmmac}" ]; then conntrack -D --src=$kmmac; fi
if ! [ -z "${kmmac}" ]; then echo iptables -D FORWARD -s $kmmac -j DROP>>/jffs/scripts/relall.sh; fi


On school days cut off internet at 22:30, on weekends at 00:30, release all days at 07:00

# Example of Cron job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed

Have fun and be amazed your son/daughter wants to go to bed at 22:31 :cool:
 

ColinTaylor

Part of the Furniture
The router's firmware doesn't have /bin/bash.
 

eibgrad

Very Senior Member
The router's firmware doesn't have /bin/bash.
Correct, but as it happens, it doesn't matter. The OP is calling sh and passing the script(s) as an argument, so it works. If only for reasons of clarity, the references to /bin/bash should probably be changed to /bin/sh.

Regardless, thanks for the script.
 
Last edited:

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top