Tomato - "Init" script in web-interface didn't do what i want

Discussion in 'Tomato Firmware' started by Lunchpack, May 16, 2018.

  1. Lunchpack

    Lunchpack New Member Member

    Hello together,

    i have a problem and need your help.

    i have a netgear wnr3500L with "Tomato Firmware 1.28.0000 MIPSR2-140 K26 USB miniVPN".
    Backround: The Router makes a wireless lan only for my amazon-dash-buttons which shall start a LED blinking on my raspberry pi.

    At first: if I start the script manually with telnet/ssh at the router it works great, but if i start it as an init-script its not working (complete).

    Init:
    Code:
    echo "LABEL=optware /opt ext3 defaults 1 1" >> /etc/fstab
    sleep 5
    /opt/bin/bash /opt/script/150518.sh &
    
    so after mount opt i want to start the script with the name 150518.sh.
    This script test permanently if someone push the dash-button and if yes it send a command with ssh to the raspberry pi to let blink the LED:

    150818.sh
    Code:
    #!/bin/sh
    while sleep 3
    do
    if "button pushed" >/dev/null
    then
    /opt/bin/bash /opt/script/sshtest.sh
    echo -n "001 - " >> /opt/script/button.log
    date +"%d-%m-%Y %H-%M-%S" >> /opt/script/button.log && sleep 10
    
    else
    echo "button is not in use" >/dev/null
    fi
    done
    
    sshtest.sh makes the connection to the raspberry:

    Code:
    #!/bin/bash
    ssh -i /root/.ssh/id_rsa root@192.168.1.110 "bash /opt/script/light_blink.sh"
    

    okay now the problem:
    as i said, if i start the script 150518.sh manually everything works great: i push the button, the raspberry starts blinking and the date with the "button-number" is written in the log.

    but if i start the script by init in the webif (administartion --> scripts) it checks if the button was pushed, it writes down in the log-file the date and the button-number but the led's didn't start blinking. but i have no idea why.

    do you have?


    Thanks so much :)
     
  2. eibgrad

    eibgrad Network Guru Member

    Just a guess, but it may be that when logged into a shell, your path is pointing to /opt/bin/bash, so it works. But when init is started, it doesn't have that path (/opt/bin), so the line "bash /opt/script/light_blink.sh" in sshtest.sh doesn't work.

    IOW, specify the full path to bash in the sshtest.sh script.
     
    Monk E. Boy and Lunchpack like this.
  3. Lunchpack

    Lunchpack New Member Member

    "bash /opt/script/light_blink.sh" is correct because its the command which is started at the raspberry, and the raspberry don't know /opt/bin/bash

    but i found the solution with your idea after days and days of searching for the solution.

    sshtest.sh needs:
    #!/bin/bash
    /opt/bin/ssh -i /root/.ssh/id_rsa root@192.168.1.110 "bash /opt/script/light_blink.sh"

    now its perfect. thank you :)
     
    Monk E. Boy likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice