1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice

Welcome To SNBForums

SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.

If you'd like to post a question, simply register and have at it!

While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!

First script, will it work? Cru command

Discussion in 'Asuswrt-Merlin' started by Matt-One, Jan 17, 2020.

  1. Matt-One

    Matt-One Occasional Visitor

    Joined:
    Jan 2, 2020
    Messages:
    14
    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"
     
  2. ColinTaylor

    ColinTaylor Part of the Furniture

    Joined:
    Mar 31, 2014
    Messages:
    10,683
    Location:
    UK
    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.
     
  3. Matt-One

    Matt-One Occasional Visitor

    Joined:
    Jan 2, 2020
    Messages:
    14
    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: Jan 17, 2020
  4. Matt-One

    Matt-One Occasional Visitor

    Joined:
    Jan 2, 2020
    Messages:
    14
    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
     
  5. SomeWhereOverTheRainBow

    SomeWhereOverTheRainBow Very Senior Member

    Joined:
    Jun 4, 2019
    Messages:
    663
    dont forget nvram commit.
     
    Matt-One likes this.
  6. Matt-One

    Matt-One Occasional Visitor

    Joined:
    Jan 2, 2020
    Messages:
    14
    Can u explain me what to do please ?
    Do u mean nvram commit at the end of the script?

    Thx u :)

    Inviato dal mio SM-N975F utilizzando Tapatalk
     
    Last edited: Jan 17, 2020
  7. SomeWhereOverTheRainBow

    SomeWhereOverTheRainBow Very Senior Member

    Joined:
    Jun 4, 2019
    Messages:
    663
    Nvram commit

    At end but before service restart
     
  8. Matt-One

    Matt-One Occasional Visitor

    Joined:
    Jan 2, 2020
    Messages:
    14
    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
     
  9. SomeWhereOverTheRainBow

    SomeWhereOverTheRainBow Very Senior Member

    Joined:
    Jun 4, 2019
    Messages:
    663
    service "restart_wrs;restart_firewall;restart_httpd"
     
  10. ColinTaylor

    ColinTaylor Part of the Furniture

    Joined:
    Mar 31, 2014
    Messages:
    10,683
    Location:
    UK
    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?
     
  11. Matt-One

    Matt-One Occasional Visitor

    Joined:
    Jan 2, 2020
    Messages:
    14
    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
     
  12. Matt-One

    Matt-One Occasional Visitor

    Joined:
    Jan 2, 2020
    Messages:
    14
    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 :)