New user's registration have been closed due to high spamming and low trafic on this forum. Please contact forum admins directly if you need an account. Thanks !

Easyfind update: script and cron job for automation

Got problems with your B2 or B3? Share and get helped!
Gordon
Posts: 1461
Joined: 10 Aug 2011, 03:18

Re: Easyfind update: script and cron job for automation

Post by Gordon »

No, wget will definitely be on the system

Sounds more like the script was saved using a Windows tool, adding invalid characters (^M) at the end of each line. Should be obvious by opening the file with nano, as it will display a line such as this at the bottom:

Code: Select all

 [ Read 11 lines (Converted from DOS format) ]
You'll need to correct the line endings. This should fix it:

Code: Select all

sed -i "s/\r//g" checkip.sh
OlivierC
Posts: 31
Joined: 21 Sep 2013, 08:01

Re: Easyfind update: script and cron job for automation

Post by OlivierC »

I double-checked it using Notepad++ option under
View->Show Symbol->Show All Characters

Windows programs end each line with two characters: <line-feed><carriage-return> \n\r or 0x0A0x0D (LFCR), whereas UNIX ends a line with only one character

each line of my script only ends with LF

wget is on the system
wget http://ef.excito.org/ip.json|
download and save ip.json output file in current dir with ip_address as content
OlivierC
Posts: 31
Joined: 21 Sep 2013, 08:01

Re: Easyfind update: script and cron job for automation

Post by OlivierC »

My IP address has changed on Sun., June 8, 2014 per ISP auto renewal every weekday 0 (Sunday)

I can no longer access my b3 by is username.myownb3.com DNS record

Code: Select all

grep '^ip' /etc/network/easyfind.conf | awk {'print $3'}
store my current IP address since yesterday

Code: Select all

http://ef.excito.org/ip.json
output today the same IP address

I've added a cronjob to run every weekday on Monday (day 1) at half past twelve (12:30)

Code: Select all

30 12 * * 1 /home/username/bin/checkip.sh >/dev/null 2>1

Code: Select all

tail -100 /var/log/syslog 
Jun 9 12:30:01 b3 /USR/SBIN/CRON[19713]: (username) CMD (/home/username/bin/checkip.sh >/dev/null 2>&1)
username.myownb3.com dynamic DNS name was not renewed.
when script was run today "$old_ip" EQUAL "$new_ip"

easyfind.conf updated on Sunday with my new IP address assigned by ISP

Code: Select all

ls -lh /etc/network/easyfind.conf
-rw-r--r-- 1 root root 57 Jun 8 12:29 /etc/network/easyfind.conf
but username.myownb3.com DNS record not updated (it's the issue i have from the start).

username is a placeholder to my real name

as reported by
Gordon wrote: What I found some time ago, and noted in that other topic, is that the update routine updates the local record of the easyfind address regardless of whether the update actually succeeds. The cron driven routine as shown by wm.bubba in this topic in fact appears to do the same.

If you decide to adopt that script to run in large intervals (i.e. 1 hour or more) I'd therefore suggest that you do not simply verify against a local record of the IP you think is associated with your easyfind name, but in fact do a host lookup. Preferably do that lookup directly at the Excito DNS servers, as it can take some time for updates to be rolled to other DNS servers on the internet.
How to apply the other suggested method (host lookup)?
OlivierC
Posts: 31
Joined: 21 Sep 2013, 08:01

Re: Easyfind update: script and cron job for automation

Post by OlivierC »

Bringing link down / up
Jun 9 15:32:16 b3 kernel: [4136588.652278] mv643xx_eth_port mv643xx_eth_port.0: eth0: link down
Jun 9 15:32:18 b3 ifplugd(eth0)[1153]: Link beat lost.
Jun 9 15:32:18 b3 kernel: [4136590.465394] mv643xx_eth_port mv643xx_eth_port.0: eth0: link up, 100 Mb/s, full duplex, flow control disabled
Jun 9 15:32:19 b3 ifplugd(eth0)[1153]: Link beat detected.
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] Unhandled Error
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] #011Traceback (most recent call last):
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] #011 File "/usr/lib/python2.6/dist-packages/twisted/web/_newclient.py", line 1034, in _bodyDataFinished_CONNECTED
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] #011 self._bodyProtocol.connectionLost(reason)
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] #011 File "/usr/share/bubba-backend/bubba-easyfind.tac", line 55, in connectionLost
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] #011 self.deferred.callback(self.string_io.getvalue())
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] #011 File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py", line 368, in callback
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] #011 self._startRunCallbacks(result)
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] #011 File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py", line 464, in _startRunCallbacks
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] #011 self._runCallbacks()
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] #011--- <exception caught here> ---
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] #011 File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py", line 551, in _runCallbacks
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] #011 current.result = callback(current.result, *args, **kw)
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] #011 File "/usr/share/bubba-backend/bubba-easyfind.tac", line 102, in easyfind_ip_changed
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] #011 decoded = json.loads(data)
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] #011 File "/usr/lib/python2.6/json/__init__.py", line 307, in loads
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] #011 return _default_decoder.decode(s)
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] #011 File "/usr/lib/python2.6/json/decoder.py", line 319, in decode
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] #011 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] #011 File "/usr/lib/python2.6/json/decoder.py", line 338, in raw_decode
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] #011 raise ValueError("No JSON object could be decoded")
Jun 9 15:33:08 b3 twisted: [HTTP11ClientProtocol,client] #011exceptions.ValueError: No JSON object could be decoded
Jun 9 15:34:08 b3 twisted: [HTTP11ClientProtocol,client] Got new IP '90.13.xx.xyz' which is not the same as the last one '81.51.xx.xyz'
Jun 9 15:34:09 b3 bubba-networkmanager: Starting up
Jun 9 15:35:01 b3 /USR/SBIN/CRON[20808]: (root) CMD (test -x /usr/bin/php && /usr/bin/php /usr/share/horde3/scripts/alarms.php)
Jun 9 15:35:01 b3 /USR/SBIN/CRON[20809]: (root) CMD (/etc/init.d/dovecot status >/dev/null 2>&1 || /etc/init.d/dovecot restart)
Jun 9 15:35:01 b3 /USR/SBIN/CRON[20810]: (root) CMD (test -x /usr/lib/web-admin/notify-dispatcher.pl && /usr/lib/web-admin/notify-dispatcher.pl)
Jun 9 15:35:08 b3 twisted: [HTTP11ClientProtocol,client] Got new IP '90.13.xx.xyz' which is the same as the last one '90.13.xx.xyz'
cat /etc/network/easyfind.conf
enable = True
ip = 90.13.xx.xyz
name = username.myownb3.com
Post Reply