.titleBar { margin-bottom: 5px!important; }

Help with a script

Dieses Thema im Forum "FRITZ!Box Fon: Modifikationen" wurde erstellt von zooster, 14 Feb. 2006.

  1. zooster

    zooster Mitglied

    Registriert seit:
    4 Jan. 2006
    Beiträge:
    218
    Zustimmungen:
    0
    Punkte für Erfolge:
    0
    Thanks to this thread, I could make the dyndns work, but I'm not done yet.
    I've added to debug.cfg this string:
    But I would also make it update only when the ip changes.
    gandalf94305(not answering anymore) suggested to use this command:
    But how to use it, where??
    Shall I use f.e.:
    ??
     
  2. danisahne

    danisahne Aktives Mitglied

    Registriert seit:
    30 Juli 2005
    Beiträge:
    1,493
    Zustimmungen:
    0
    Punkte für Erfolge:
    0
    Beruf:
    Informatik Studium
    Ort:
    Marktoberdorf
    Try this instead of your wget ... in debug.cfg:
    Code:
    # create date script
    cat > /var/tmp/onlinechanged << 'EOF'
    #!/bin/sh
    case "$1" in
     online)
      wget -O - "http://USER:PASSWORD@members.dyndns.org/nic/update?hostname=HOST.dyndns.org" | cat
      ;;
     offline)
      ;;
    esac
    EOF
    chmod +x /var/tmp/onlinechanged
    
    # restart multid with new onlinechanged script
    multid -s
    multid -S /var/tmp/onlinechanged
    It's really necessary, that you teach yourself some Linux skills first.

    Mfg,
    danisahne
     
  3. zooster

    zooster Mitglied

    Registriert seit:
    4 Jan. 2006
    Beiträge:
    218
    Zustimmungen:
    0
    Punkte für Erfolge:
    0
    Thanks. Then this script let the box connect to DynDNS only when the ip changes...
     
  4. zooster

    zooster Mitglied

    Registriert seit:
    4 Jan. 2006
    Beiträge:
    218
    Zustimmungen:
    0
    Punkte für Erfolge:
    0
    Man, I've insterted that line at the beginning of the debug.cfg, this is my debug.cfg:
    Code:
    #!/bin/sh
    
    
    # create date script
    cat > /var/tmp/onlinechanged << 'EOF'
    #!/bin/sh
    case "$1" in
     online)
       wget -O - "http://my user:my [email]pass@members.dyndns.org[/email]/nic/update?hostname=my host" | cat
         ;;
          offline)
            ;;
            esac
            EOF
            chmod +x /var/tmp/onlinechanged
    
            # restart multid with new onlinechanged script
            multid -s
            multid -S /var/tmp/onlinechanged
    
    
    # start telnet deamon with password of web gui
    /usr/sbin/telnetd -l /sbin/ar7login
    
    # enable WDS
    sed "s/isWlanWds/showWlan/g" /usr/www/all/html/de/menus/menu2_wlan.html >/var/tmp/menu2_wlan.html
    chmod 444 /var/tmp/menu2_wlan.html
    mount -o bind /var/tmp/menu2_wlan.html /usr/www/all/html/de/menus/menu2_wlan.html
    
    # enable international settings
    sed "s/LKZ 0/LKZ 1/g" /usr/www/all/html/de/fon/sip1.js > /var/tmp/sip1.js
    chmod 444 /var/tmp/sip1.js
    mount -o bind /var/tmp/sip1.js /usr/www/all/html/de/fon/sip1.js
    
    # enable ENUM
    sed "s/avme/avm/g" /usr/www/all/html/de/fon/sipoptionen.html > /var/tmp/sipoptionen.html
    sed "s/avme/avm/g" /usr/www/all/html/de/fon/sipoptionen.js > /var/tmp/sipoptionen.js
    chmod 444 /var/tmp/sipoptionen.html
    chmod 444 /var/tmp/sipoptionen.js
    mount -o bind /var/tmp/sipoptionen.html /usr/www/all/html/de/fon/sipoptionen.html
    mount -o bind /var/tmp/sipoptionen.js /usr/www/all/html/de/fon/sipoptionen.js
    
    # write contact list
    echo ":anonymous;" > /var/tmp/contacts
    
    # write lines list
    echo ":anonymous;" > /var/tmp/lines
    
    # write send script to file
    cat > /var/tmp/callmessage.sh << 'ENDCALLMESSAGE'
    #!/bin/sh
    
    # init var name
    name=""
    
    # read params
    caller=$2
    called=$1
    
    #read contact list
    while read contact
    do
      case ${contact} in
        ${caller}*)
          name=${contact#*:}
          name=${name%%\;*}
          break
        ;;
      esac
    done < /var/tmp/contacts
    
    # name not found?
    if [ -z "${name}" ]
    then
      name=${caller}
    fi
    httpname=`echo "${name}" | sed -e 's/ /%20/g'`
    
    #init var theline
    theline=""
    
    #read lines list
    while read thelines
    do
      case ${thelines} in
        ${called}*)
          theline=${thelines#*:}
          theline=${theline%%\;*}
          break
        ;;
      esac
    done < /var/tmp/lines
    
    # line not found?
    if [ -z "${theline}" ]
    then
      theline=${called}
    fi
    httptheline=`echo "${theline}" | sed -e 's/ /%20/g'`
    
    # send information to PCs
    wget -O /dev/null "http://10.0.0.6:23232/?caller=${caller}&called=${called}&name=${name}&line=${theline}" >/dev/null 2>&1 &
    
    ENDCALLMESSAGE
    
    # make it executable
    chmod +x /var/tmp/callmessage.sh
    
    # write dummy WakeOnCall script
    echo > /var/tmp/woc.sh
    make it executable
    chmod +x /var/tmp/woc.sh
    
    # write parse_telefon script to file
    cat > /var/tmp/parse_telefon.sh << 'ENDPARSETEL'
    #!/bin/sh
    
    prefix=
    caller=""
    called=""
    
    # stdin: output of telefon daemon expected
    while read line
    do
      case ${line} in
        *IncomingCall:*)
          caller=${line#*caller: \"}
          caller=${caller%%\"*}
          called=${line#*called: \"}
          called=${called%%\"*}
          # normalize caller
          case ${caller} in
            0049*)
              caller=0${caller#*0049}
            ;;
            49????????*)
              caller=0${caller#*49}
            ;;
            [1-9]*)
              caller=${prefix}${caller}
            ;;
          esac
          # exec woc.sh
          /var/tmp/woc.sh ${called} ${caller} &
          # exec callmessage.sh
           /var/tmp/callmessage.sh ${called} ${caller} &
        ;;
      esac
    done
    
    ENDPARSETEL
    
    # make it executable
    chmod +x /var/tmp/parse_telefon.sh
    
    # wait
    sleep 3
    # restart telefon daemon piping its output into telefon_parse.sh
    if [ -x /var/tmp/parse_telefon.sh ]
    then
      # stop telefon daemon safely
      killall -15 telefon
      sleep 3
      killall -9 telefon
      rm -f /var/run/telefon.pid
      sleep 3
      telefon 1 a127.0.0.1 | /var/tmp/parse_telefon.sh &
    fi
    But after I've insterted your script, I don't have ENUM, WDS, International settings, and callmessage.
    Did I mistake anything?


    Edit wichard: Quote-Tags durch Code-Tags ersetzt
     
  5. olistudent

    olistudent IPPF-Urgestein

    Registriert seit:
    19 Okt. 2004
    Beiträge:
    14,756
    Zustimmungen:
    1
    Punkte für Erfolge:
    0
    Beruf:
    Softwareentwickler
    Ort:
    Kaiserslautern
    Why do you need this line?
    Code:
    #!/bin/sh
    Greets, Oliver
     
  6. zooster

    zooster Mitglied

    Registriert seit:
    4 Jan. 2006
    Beiträge:
    218
    Zustimmungen:
    0
    Punkte für Erfolge:
    0
    Nope, I've deleted the first line (#!/bin/sh) but still the enum+wds+international+callmessage don't work.
     
  7. olistudent

    olistudent IPPF-Urgestein

    Registriert seit:
    19 Okt. 2004
    Beiträge:
    14,756
    Zustimmungen:
    1
    Punkte für Erfolge:
    0
    Beruf:
    Softwareentwickler
    Ort:
    Kaiserslautern
    Are you sure that there is no error in the script?
    Ist the script executet?
    Check the output of ps and mount.

    Greets, Oliver
     
  8. zooster

    zooster Mitglied

    Registriert seit:
    4 Jan. 2006
    Beiträge:
    218
    Zustimmungen:
    0
    Punkte für Erfolge:
    0
    I don't know how to check what you suggested. I just noticed that the debug.cfg(only enum, wds, international, callmessage) without the script suggested by danisahne does work. With that script, it doesn't.
     
  9. olistudent

    olistudent IPPF-Urgestein

    Registriert seit:
    19 Okt. 2004
    Beiträge:
    14,756
    Zustimmungen:
    1
    Punkte für Erfolge:
    0
    Beruf:
    Softwareentwickler
    Ort:
    Kaiserslautern
    Okay, I've found an error.
    Code:
    # create date script
    cat > /var/tmp/onlinechanged << 'EOF'
    #!/bin/sh
    case "$1" in
     online)
    wget -O - "http://my user:my [EMAIL="pass@members.dyndns.org"]pass@members.dyndns.org[/EMAIL]/nic/update?hostname=my host" | cat
    ;;
    offline)
    ;;
    esac
    [SIZE=4][COLOR=red][B]EOF[/B][/COLOR][/SIZE]
    chmod +x /var/tmp/onlinechanged
     
    # restart multid with new onlinechanged script
    multid -s
    multid -S /var/tmp/onlinechanged
    There musst not be spaces before EOF.

    Greets, Oliver
     
  10. zooster

    zooster Mitglied

    Registriert seit:
    4 Jan. 2006
    Beiträge:
    218
    Zustimmungen:
    0
    Punkte für Erfolge:
    0
    Thx, I've attached that script at the end of the debug.cfg, and without space before EOF. The previous patches are there and working, but I have to understand if the connection to DynDNS does work now :)
     
  11. zooster

    zooster Mitglied

    Registriert seit:
    4 Jan. 2006
    Beiträge:
    218
    Zustimmungen:
    0
    Punkte für Erfolge:
    0
    Nope, connection to dyndns doesn't work, here is my actual debug.cfg:
    Code:
    #!/bin/sh
    
    # start telnet deamon with password of web gui
    /usr/sbin/telnetd -l /sbin/ar7login
    
    # enable WDS
    sed "s/isWlanWds/showWlan/g" /usr/www/all/html/de/menus/menu2_wlan.html >/var/tmp/menu2_wlan.html
    chmod 444 /var/tmp/menu2_wlan.html
    mount -o bind /var/tmp/menu2_wlan.html /usr/www/all/html/de/menus/menu2_wlan.html
    
    # enable international settings
    sed "s/LKZ 0/LKZ 1/g" /usr/www/all/html/de/fon/sip1.js > /var/tmp/sip1.js
    chmod 444 /var/tmp/sip1.js
    mount -o bind /var/tmp/sip1.js /usr/www/all/html/de/fon/sip1.js
    
    # enable ENUM
    sed "s/avme/avm/g" /usr/www/all/html/de/fon/sipoptionen.html > /var/tmp/sipoptionen.html
    sed "s/avme/avm/g" /usr/www/all/html/de/fon/sipoptionen.js > /var/tmp/sipoptionen.js
    chmod 444 /var/tmp/sipoptionen.html
    chmod 444 /var/tmp/sipoptionen.js
    mount -o bind /var/tmp/sipoptionen.html /usr/www/all/html/de/fon/sipoptionen.html
    mount -o bind /var/tmp/sipoptionen.js /usr/www/all/html/de/fon/sipoptionen.js
    
    # write contact list
    echo ":anonymous;" > /var/tmp/contacts
    
    # write lines list
    echo ":anonymous;" > /var/tmp/lines
    
    # write send script to file
    cat > /var/tmp/callmessage.sh << 'ENDCALLMESSAGE'
    #!/bin/sh
    
    # init var name
    name=""
    
    # read params
    caller=$2
    called=$1
    
    #read contact list
    while read contact
    do
      case ${contact} in
        ${caller}*)
          name=${contact#*:}
          name=${name%%\;*}
          break
        ;;
      esac
    done < /var/tmp/contacts
    
    # name not found?
    if [ -z "${name}" ]
    then
      name=${caller}
    fi
    httpname=`echo "${name}" | sed -e 's/ /%20/g'`
    
    #init var theline
    theline=""
    
    #read lines list
    while read thelines
    do
      case ${thelines} in
        ${called}*)
          theline=${thelines#*:}
          theline=${theline%%\;*}
          break
        ;;
      esac
    done < /var/tmp/lines
    
    # line not found?
    if [ -z "${theline}" ]
    then
      theline=${called}
    fi
    httptheline=`echo "${theline}" | sed -e 's/ /%20/g'`
    
    # send information to PCs
    wget -O /dev/null "http://10.0.0.6:23232/?caller=${caller}&called=${called}&name=${name}&line=${theline}" >/dev/null 2>&1 &
    
    ENDCALLMESSAGE
    
    # make it executable
    chmod +x /var/tmp/callmessage.sh
    
    # write dummy WakeOnCall script
    echo > /var/tmp/woc.sh
    make it executable
    chmod +x /var/tmp/woc.sh
    
    # write parse_telefon script to file
    cat > /var/tmp/parse_telefon.sh << 'ENDPARSETEL'
    #!/bin/sh
    
    prefix=
    caller=""
    called=""
    
    # stdin: output of telefon daemon expected
    while read line
    do
      case ${line} in
        *IncomingCall:*)
          caller=${line#*caller: \"}
          caller=${caller%%\"*}
          called=${line#*called: \"}
          called=${called%%\"*}
          # normalize caller
          case ${caller} in
            0049*)
              caller=0${caller#*0049}
            ;;
            49????????*)
              caller=0${caller#*49}
            ;;
            [1-9]*)
              caller=${prefix}${caller}
            ;;
          esac
          # exec woc.sh
          /var/tmp/woc.sh ${called} ${caller} &
          # exec callmessage.sh
           /var/tmp/callmessage.sh ${called} ${caller} &
        ;;
      esac
    done
    
    ENDPARSETEL
    
    # make it executable
    chmod +x /var/tmp/parse_telefon.sh
    
    # wait
    sleep 3
    # restart telefon daemon piping its output into telefon_parse.sh
    if [ -x /var/tmp/parse_telefon.sh ]
    then
      # stop telefon daemon safely
      killall -15 telefon
      sleep 3
      killall -9 telefon
      rm -f /var/run/telefon.pid
      sleep 3
      telefon 1 a127.0.0.1 | /var/tmp/parse_telefon.sh &
    fi
    
    
    # create date script
    cat > /var/tmp/onlinechanged << 'EOF'
    #!/bin/sh
    case "$1" in
     online)
      wget -O - "http://myuser:mypass@members.dyndns.org/nic/update?hostname=mydns" | cat
      ;;
     offline)
      ;;
    esac
    EOF
    chmod +x /var/tmp/onlinechanged
    
    # restart multid with new onlinechanged script
    multid -s
    multid -S /var/tmp/onlinechanged 
     
  12. danisahne

    danisahne Aktives Mitglied

    Registriert seit:
    30 Juli 2005
    Beiträge:
    1,493
    Zustimmungen:
    0
    Punkte für Erfolge:
    0
    Beruf:
    Informatik Studium
    Ort:
    Marktoberdorf
    Does dyndns update your ip if you call
    Code:
    /var/tmp/onlinechanged online
    Btw: Dont do this unnecessarily (if ip is already up-to-date) or dyndns will lock your account. Is your account still working?
     
  13. zooster

    zooster Mitglied

    Registriert seit:
    4 Jan. 2006
    Beiträge:
    218
    Zustimmungen:
    0
    Punkte für Erfolge:
    0
    The ip cannot update, neither if I reboot the box. Something doesn't work in that script...
     
  14. danisahne

    danisahne Aktives Mitglied

    Registriert seit:
    30 Juli 2005
    Beiträge:
    1,493
    Zustimmungen:
    0
    Punkte für Erfolge:
    0
    Beruf:
    Informatik Studium
    Ort:
    Marktoberdorf
    Have you tried `/var/tmp/onlinechanged online' manually? Is myuser and mypass set according to your dyndns account?
    Code:
    myuser:mypass@members.dyndns.org
     
  15. zooster

    zooster Mitglied

    Registriert seit:
    4 Jan. 2006
    Beiträge:
    218
    Zustimmungen:
    0
    Punkte für Erfolge:
    0
    Omg! I thought I wrote the right user, but it was wrong for just one similar digit!!! I can't believe... Sorry.
    Anyway I tried to do manually `/var/tmp/onlinechanged online' and it replied with an authorization error, so I checked better my user and it was barely wrong.
    Thank you very much man :D
     
  16. zooster

    zooster Mitglied

    Registriert seit:
    4 Jan. 2006
    Beiträge:
    218
    Zustimmungen:
    0
    Punkte für Erfolge:
    0
    Just the last thing. In insert mode, how can I delete digits and words? When I press backspace it types other things without deleting anything.
     
  17. zooster

    zooster Mitglied

    Registriert seit:
    4 Jan. 2006
    Beiträge:
    218
    Zustimmungen:
    0
    Punkte für Erfolge:
    0
    Man, it didn't update itself again, I had to do /var/tmp/onlinechanged online, it replied: good ipnumber. After I checked the dyndns and it was updated so it is no automatically...
     
  18. zooster

    zooster Mitglied

    Registriert seit:
    4 Jan. 2006
    Beiträge:
    218
    Zustimmungen:
    0
    Punkte für Erfolge:
    0
    Nope, I retried again and it doesn't update itself. The ip is updated on dyndns only if I do "/var/tmp/onlinechanged online" or I reboot the box... Somethign ain't work in that script.
    But I just remark that my 7050 is in ATA mode only, behind a modem-router.
    Help plz.
     
  19. danisahne

    danisahne Aktives Mitglied

    Registriert seit:
    30 Juli 2005
    Beiträge:
    1,493
    Zustimmungen:
    0
    Punkte für Erfolge:
    0
    Beruf:
    Informatik Studium
    Ort:
    Marktoberdorf
    #19 danisahne, 18 Feb. 2006
    Zuletzt bearbeitet: 18 Feb. 2006
    The onlinechanged script cannot work in ATA mode. How do you think your box should recognize, that the dsl line disconnected?

    EDIT:
    First solution: Your modem-router is able to update your dyndns account
    Second solution: You have to poll (lets say every 5 minutes) the IP youraccount.dyndns.org resolves to and compare it with your current IP. Then use your script, when your account is not up-to-date. Not a good solution to me.
     
  20. zooster

    zooster Mitglied

    Registriert seit:
    4 Jan. 2006
    Beiträge:
    218
    Zustimmungen:
    0
    Punkte für Erfolge:
    0
    My modem-router is an alcatel speedtouch pro, I don't think it can do something like that.
    Why the second solution is not good for you?