Ah ok, yea sounds like you want something with a little more customization. Would be interested in seeing your script once your finished. I have kids that I would love to use this on now that school has started.
I've use the time schedule to make sure the oldest doesn't continue to watch tv or play games late at night.
Hi Quicksilver,
I've got something rough working:
##########################################
admin@RT-AC86U:/jffs/scripts/xbox# cat xboxcheck.sh
#!/bin/sh
#default state is xbox is blocked. Add this to init-start script
#4am cron to clear xbox flag
#see /jffs/scripts/init-start
maxtime=7300
#If daily flag set. No more checking.
if [ -f /jffs/scripts/xbox/xboxdailyflag ]
then
exit
fi
#Tiime of Day Restrictions
#dow = day of week. 1=Monday - 7=Sunday
dow=`date +%u`
#hod = hour of day.
hod=`date +%k`
if [ $dow -le 5 ]
then
#Weekday
maxtime=3700
if [ $hod -lt 15 ]
then
#Quit out if before 16:00. Not going to continue running, so no xbox
exit
fi
if [ $hod -ge 20 ]
then
#End of the day. Block the xbox
/jffs/scripts/xbox/xboxstop.sh
touch /jffs/scripts/xbox/xboxdailyflag
fi
fi
if [ `wl -i eth5 assoclist | grep "C0:33:5E
3:17:54" | wc -l` -eq 1 ]
then
#If XBOX ON, increment seconds counter (in a file). Reset file to 0 each night.
#read previous time, and add 5 mins (cron job runs every 5 mins)
prevtime=`cat /jffs/scripts/xbox/xboxison`
totaltime=`expr $prevtime + 300`
echo $totaltime > /jffs/scripts/xbox/xboxison
logger XBOX On $totaltime of $maxtime
#if prevtime == 0 then xbox just turned on. Unblock it.
if [ $prevtime -eq 0 ]
then
/jffs/scripts/xbox/xboxstart.sh
fi
#If $totaltime > Maxtime then block xbox
if [ $totaltime -gt $maxtime ]
then
/jffs/scripts/xbox/xboxstop.sh
touch /jffs/scripts/xbox/xboxdailyflag
fi
fi
##########################################
admin@RT-AC86U:/jffs/scripts/xbox# cat xboxstop.sh
#!/bin/sh
logger XBOX blocked
#/usr/sbin/iptables -C FORWARD -m mac --mac-source C0:33:5E
3:17:54 -j DROP
if [ `iptables -L FORWARD | grep C0:33:5E
3:17:54 | wc -l` -eq 0 ]
then
logger XBOX Adding iptables
/usr/sbin/iptables -I FORWARD -m mac --mac-source C0:33:5E
3:17:54 -j DROP
#nvram set MULTIFILTER_MAC=`nvram get MULTIFILTER_MAC`\>C0\:33\:5E\
3\:17\:54
#nvram set MULTIFILTER_DEVICENAME="`nvram get MULTIFILTER_DEVICENAME`>XboxOne"
#nvram set MULTIFILTER_ENABLE=`nvram get MULTIFILTER_ENABLE`\>2
#nvram commit
fi
##########################################
admin@RT-AC86U:/jffs/scripts/xbox# cat xboxstart.sh
#!/bin/sh
logger XBOX Unblocked
#/usr/sbin/iptables -C FORWARD -m mac --mac-source C0:33:5E
3:17:54 -j DROP
if [ `iptables -L FORWARD | grep C0:33:5E
3:17:54 | wc -l` -eq 1 ]
then
logger XBOX Deleting IPTables Entry
#The below command is dodgy AF
#/usr/sbin/iptables -D FORWARD -m mac --mac-source C0:33:5E
3:17:54 -j DROP
/usr/sbin/iptables -D FORWARD `iptables -L FORWARD --line-numbers | grep "C0:33:5E
3:17:54" | awk '{print $1}'`
#nvram set MULTIFILTER_MAC=`nvram get MULTIFILTER_MAC | sed 's/>C0:33:5E
3:17:54//g'`
#nvram set MULTIFILTER_DEVICENAME="`nvram get MULTIFILTER_DEVICENAME | sed 's/>XboxOne//g'`"
#nvram set MULTIFILTER_ENABLE=`nvram get MULTIFILTER_ENABLE | sed 's/>2//'`
#nvram commit
fi
##########################################
admin@RT-AC86U:/jffs/scripts/xbox# cat xboxreset.sh
#!/bin/sh
#Zero the counter file, clear the daily flag and block the xbox
logger xbox reset
echo 0 > /jffs/scripts/xbox/xboxison
rm -f /jffs/scripts/xbox/xboxdailyflag
/jffs/scripts/xbox/xboxstop.sh
##########################################
Append these to /jffs/scripts/init-start
#Reset the xbox timer
/usr/sbin/cru a resetxbox "30 4 * * * /jffs/scripts/xbox/xboxreset.sh"
#Check XBox every 5 mins
/usr/sbin/cru a checkxbox "*/5 * * * * /jffs/scripts/xbox/xboxcheck.sh"
Not sure you'll make sense of it!!??
Essentially, I have a 1 script to block the xbox, another to unblock, another to check every 5 mins, and a 4th to reset everything in the middle of the night.
If we wish the xbox to to be allowed on the network after it's been blocked for the day, we can use the router GUI (or the app) to block and then unblock the device, because the above scripts do not get reflected in the GUI. The commented out "MULTIFILTER" nvram variables control the blocking and time scheduling from the GUI, and I don't want to go there just yet as we tend to manually block and unblock other devices randomly, so don't want to break this, but it looks like it's do-able.
Hope this works for you - it appears to work for me right now.
Cheers!