What's new

First script, will it work? Cru command

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Matt-One

Occasional Visitor
Hello, i created my first script, but i would like to be sure that will not brick or making some other problems to my modem heheeh :)
I just copy/paste some codes that i find here and modified the timing of cru command.
Is it correct? Will it work?
Can i upload this 3 files through WinSCP?

THANK YOU :)

services-start
#!/bin/sh
cru a filtering-on "30 15-17 * * 0-6 /jffs/scripts/aiprot-on.sh"
cru a filtering-on "31 17 * * 0-6 /jffs/scripts/aiprot-off.sh"

aiprot-on.sh
#!/bin/sh
nvram set wrs_app_enabled=1
nvram set wrs_enable=1
service "restart_wrs;restart_firewall"

aiprot-off.sh"
#!/bin/sh
nvram set wrs_app_enabled=0
nvram set wrs_enable=0
service "restart_wrs;restart_firewall"
 
You should really have added this to end of your existing thread rather than creating a duplicate post.

There is one typo in services-start:

#!/bin/sh
cru a filtering-on "30 15-17 * * 0-6 /jffs/scripts/aiprot-on.sh"
cru a filtering-off "31 17 * * 0-6 /jffs/scripts/aiprot-off.sh"


Other than that it should run OK. I can't say whether it'll do want you want because I don't use AiProtection myself. But it won't "break" anything.

Yes you can use WinSCP, just make sure that the files have Unix-type line endings and not DOS/Windows line endings.
 
You should really have added this to end of your existing thread rather than creating a duplicate post.

There is one typo in services-start:

#!/bin/sh
cru a filtering-on "30 15-17 * * 0-6 /jffs/scripts/aiprot-on.sh"
cru a filtering-off "31 17 * * 0-6 /jffs/scripts/aiprot-off.sh"


Other than that it should run OK. I can't say whether it'll do want you want because I don't use AiProtection myself. But it won't "break" anything.

Yes you can use WinSCP, just make sure that the files have Unix-type line endings and not DOS/Windows line endings.

Yes, you are right and i am really sorry for the double post, but, i wrote the same thing (more or less) in the other post and nobody reply to me, for this i decided to make a new one hoping for more views...

However it should disable and enable AiProtection in that hours, so i can have my nephew off of youtube when they have to study :)
About the file i'm using Notepad++ so it should be fine

Thank you for your reply, and exscuse me again :)
 
Last edited:
You should really have added this to end of your existing thread rather than creating a duplicate post.

There is one typo in services-start:

#!/bin/sh
cru a filtering-on "30 15-17 * * 0-6 /jffs/scripts/aiprot-on.sh"
cru a filtering-off "31 17 * * 0-6 /jffs/scripts/aiprot-off.sh"


Other than that it should run OK. I can't say whether it'll do want you want because I don't use AiProtection myself. But it won't "break" anything.

Yes you can use WinSCP, just make sure that the files have Unix-type line endings and not DOS/Windows line endings.

I find through nvram show command that
nvram set wrs_app_enabled=1
is incorrect and it is
nvram set wrs_app_enable=1 (without the d at the end)

anyway the script doesn't seem to work, i don't know why, but i always see the ON/OFF switch of AI PROTECTION at ON or OFF (if i move it manually and then restart the router)

i also see the cru online using cru l command list
 
Hello, i created my first script, but i would like to be sure that will not brick or making some other problems to my modem heheeh :)
I just copy/paste some codes that i find here and modified the timing of cru command.
Is it correct? Will it work?
Can i upload this 3 files through WinSCP?

THANK YOU :)

services-start
#!/bin/sh
cru a filtering-on "30 15-17 * * 0-6 /jffs/scripts/aiprot-on.sh"
cru a filtering-on "31 17 * * 0-6 /jffs/scripts/aiprot-off.sh"

aiprot-on.sh
#!/bin/sh
nvram set wrs_app_enabled=1
nvram set wrs_enable=1
service "restart_wrs;restart_firewall"

aiprot-off.sh"
#!/bin/sh
nvram set wrs_app_enabled=0
nvram set wrs_enable=0
service "restart_wrs;restart_firewall"

dont forget nvram commit.
 
Nvram commit

At end but before service restart

Nothing, it doesn't work, i see the cru list (with my last cru) but it don't work

/jffs/scripts$ cru l
30 15-17 * * 0-6 /jffs/scripts/aiprot-on.sh #filtering-on#
31 17 * * 0-6 /jffs/scripts/aiprot-off.sh #filtering-off#
42 17 */7 * * service restart_letsencrypt #LetsEncrypt#

The ON/OFF switch in AiProtection Web&App filter doesn't change to On or Off.

SysLog:
Jan 17 22:41:44 crond[261]: time disparity of 896676 minutes detected
 
Nothing, it doesn't work, i see the cru list (with my last cru) but it don't work

/jffs/scripts$ cru l
30 15-17 * * 0-6 /jffs/scripts/aiprot-on.sh #filtering-on#
31 17 * * 0-6 /jffs/scripts/aiprot-off.sh #filtering-off#
42 17 */7 * * service restart_letsencrypt #LetsEncrypt#

The ON/OFF switch in AiProtection Web&App filter doesn't change to On or Off.
service "restart_wrs;restart_firewall;restart_httpd"
 
Have you waited for the scheduled time to arrive? At the moment the "on" script only runs at 15:30, 16:30 and 17:30. Then the "off" script runs once at 17:31.

Have you enabled the running of customised scripts in the router's GUI?
 
Have you waited for the scheduled time to arrive? At the moment the "on" script only runs at 15:30, 16:30 and 17:30. Then the "off" script runs once at 17:31.

Have you enabled the running of customised scripts in the router's GUI?

No i haven't, but i forced the switch to ON manually, then i restarted the router (at this time the switch should stay set to OFF), but it is always to ON.
Yes, the customizied scripts are enabled
 
Well, i changed the time of the OFF string to see if it work, and it worked, the manual test didn't work :)

Thank you both for the help :)
 
dont forget nvram commit.
Hi, I'm trying something similar because my parental controls toggle keeps switching back to OFF for some reason. to find out which nvram setting i needed to tweak, I did an "nvram show" when time scheduling was enabled and when it was disabled. I captured both to separate files and then did a diff to see which parameter(s) changed. Weird thing: none did. They did when i tried the same with the web & app filtering, I could see wrs_enable and wrs_app_enable going from 0 to 1. What nvram setting controls the "Time Scheduling" toggle? Thanks!
 
Hi, I'm trying something similar because my parental controls toggle keeps switching back to OFF for some reason. to find out which nvram setting i needed to tweak, I did an "nvram show" when time scheduling was enabled and when it was disabled. I captured both to separate files and then did a diff to see which parameter(s) changed. Weird thing: none did. They did when i tried the same with the web & app filtering, I could see wrs_enable and wrs_app_enable going from 0 to 1. What nvram setting controls the "Time Scheduling" toggle? Thanks!
Look at the MULTIFILTER nvram variables.
 

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