Help with a script

zooster

Mitglied
Mitglied seit
4 Jan 2006
Beiträge
218
Punkte für Reaktionen
0
Punkte
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:
wget -O - "http://USER:p[email protected]/nic/update?hostname=HOST.dyndns.org" | cat
But I would also make it update only when the ip changes.
gandalf94305(not answering anymore) suggested to use this command:
~ # multid -?
usage: multid multid [options]
options:
-? - print this help
-f - run in forground. (NOTSET)
-s - stop daemon. (NOTSET)
-p STRING - Pidfile. ("/var/run/multid.pid")
-M STRING - memory debug output. (NULL)
-S STRING - script to call when onlinestatus changes. /bin/onlinechanged")
-t - disable simple NTP client. (NOTSET)
-D STRING - switch debug logs on. (NULL)
start server: multid
stop server : multid -s
But how to use it, where??
Shall I use f.e.:
wget -O - "http://USER:p[email protected]/nic/update?hostname=HOST.dyndns.org" | cat | multid multid -S "/bin/onlinechanged"
??
 
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:[email protected]/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
 
Thanks. Then this script let the box connect to DynDNS only when the ip changes...
 
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][email protected][/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
 
Why do you need this line?
Code:
#!/bin/sh
Greets, Oliver
 
Nope, I've deleted the first line (#!/bin/sh) but still the enum+wds+international+callmessage don't work.
 
Are you sure that there is no error in the script?
Ist the script executet?
Check the output of ps and mount.

Greets, Oliver
 
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.
 
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="[email protected]"][email protected][/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
 
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 :)
 
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:[email protected]/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
 
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?
 
The ip cannot update, neither if I reboot the box. Something doesn't work in that script...
 
Have you tried `/var/tmp/onlinechanged online' manually? Is myuser and mypass set according to your dyndns account?
Code:
 
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
 
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.
 
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...
 
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.
 
zooster schrieb:
But I just remark that my 7050 is in ATA mode only, behind a modem-router.
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.
 
Zuletzt bearbeitet:
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?
 
Holen Sie sich 3CX - völlig kostenlos!
Verbinden Sie Ihr Team und Ihre Kunden Telefonie Livechat Videokonferenzen

Gehostet oder selbst-verwaltet. Für bis zu 10 Nutzer dauerhaft kostenlos. Keine Kreditkartendetails erforderlich. Ohne Risiko testen.

3CX
Für diese E-Mail-Adresse besteht bereits ein 3CX-Konto. Sie werden zum Kundenportal weitergeleitet, wo Sie sich anmelden oder Ihr Passwort zurücksetzen können, falls Sie dieses vergessen haben.