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!

"services-start" starts too early or I put the file at wrong file?

Discussion in 'Asuswrt-Merlin' started by chncar, Sep 20, 2018.

  1. chncar

    chncar Occasional Visitor

    Joined:
    Apr 13, 2015
    Messages:
    16
    I’m now using RT-AC68U with Merlin LTS fork 34E3j9527. And the DNS over LTS enabled.


    I added bellowed command in services-start to connect IP address and the MAC.


    Arp -s 192.168.x.x AA:BB:CC:DD:DE


    It doesn’t work. The file is executed but nothing happened, IP is not connected with the MAC


    I added 25s delay in the file and it works.


    According to merlin wiki, the file services-start shall be executed after all system services.


    Is this a bug or I put the command in wrong file?
     
  2. Please support SNBForums! Just click on this link before you buy something from Amazon and we'll get a small commission on anything you buy. Thanks!
  3. M@rco

    [email protected] Very Senior Member

    Joined:
    Dec 23, 2017
    Messages:
    659
    Location:
    /opt
    I don't know whether the wiki for @RMerlin's build is fully applicable on @john9527's LTS fork. Did you try the helpful hint at the end of the wiki page to check? If you add a logger line you can also check syslog.
     
  4. Xentrk

    Xentrk Very Senior Member

    Joined:
    Jul 21, 2016
    Messages:
    1,630
    Location:
    The Land of Smiles
    Make sure script is executable. If not, type chmod 755 services-start

    First line must be a shebang: #!/bin/sh

    The arp command should be all lower case. Try running the services-start from the command line to see if it works without errors e.g. sh services.start

    @[email protected] has a good suggestion to add a system log entry at the script start and script end.

    logger -t "($(basename "$0"))" $$ "Script Starting"

    logger -t "($(basename "$0"))" $$ "Script Ending"
     
    skeal and [email protected] like this.
  5. RMerlin

    RMerlin Super Moderator

    Joined:
    Apr 14, 2012
    Messages:
    27,985
    Location:
    Canada
    Services-start runs fairly early, and starts a group of services, but not all of them. Quite a few services are tied to events rather than started by this section of the code.
     
  6. john9527

    john9527 Part of the Furniture

    Joined:
    Mar 28, 2014
    Messages:
    5,650
    Location:
    United States
    Should be the same on my fork. Not sure it's applicable in this case, but in the 'early' running scripts, init-start and services-start, you should always include the path in the command as the environment may not be fully set yet...i.e. /sbin/arp

    Also, it's arp, not Arp (case matters in linux)
     
    [email protected] likes this.
  7. chncar

    chncar Occasional Visitor

    Joined:
    Apr 13, 2015
    Messages:
    16
    Thanks for all your replies.

    Actually my services-start file contains command "arp -s IP MAC" now works fine. I just feel strange why I have to put 25s before the command to make it work.

    I tried full set command format like "/sbin/arp -s IP MAC" , but I still need to add delays before that command to make it work.

    I think Rmerlin is correct that services-start runs after most of system services but not all of them.
     
  8. CooCooCaChoo

    CooCooCaChoo Regular Contributor

    Joined:
    Sep 20, 2013
    Messages:
    183
    Might be because the interface hasn't been brought up yet. I have a script that changes the cwnd that, when executed without a sleep command, will fail because of that. So you might have the inject the 25s sleep command right before your command to give it time for the router to bring up that interface.
     
Please support SNBForums! Just click on this link before you buy something from Amazon and we'll get a small commission on anything you buy. Thanks!