[Asterisk-Users] Hint: how to include dialplan files from remote systems

John Todd jtodd at loligo.com
Fri Dec 2 11:06:26 MST 2005


>On Thu, Dec 01, 2005 at 06:51:54PM -0800, John Todd wrote:
>
>>  #exec /usr/bin/curl -s 
>>http://webserver.domain.com/privatefiles/username-to-numbers > 
>>/etc/asterisk/username-to-numbers
>>  #include username-to-numbers
>
>Nice. However, what happens if curl takes longer than expected? your
>reload waits for it.
>
>And what if you get a broken copy? I figure you should generally fetch
>to a temporary file and only replace the working copy if the download
>was successful.
>
>Something like (untested):
>
>   filename=`mktemp`
>   destination=/etc/asterisk/username-to-numbers
>   wget -q -O$filename && cp $filename $destination
>   rm $filename
>
>This still won't report errors up, and won't do any single sanity
>check, but you get my point.
>
>--
>Tzafrir Cohen         | tzafrir at jbr.cohens.org.il | VIM is
>http://tzafrir.org.il |                           | a Mutt's 
>tzafrir at cohens.org.il |                           |  best
>ICQ# 16849755         |                           | friend


Yes, I didn't put extensive error-checking into the example so other 
curl options like MaxTime and ConnectTimeout were not used.  Some 
fiddling with curl's options can start to significantly limit the 
threats due to timeout/delay errors.

As for corrupted files, there is a whole different parsing 
requirement there that I think is outside of an easy scope.  Another 
whole shell script/perl program would probably be required to check 
the integrity of the file to ensure it was "proper" Asterisk format. 
Bah - too much work.  :-)

Additionally, you use "wget" in your follow-up code.  I originally 
used wget in my example, but hit a wall when testing it.  For some 
inexplicable reason, it is the case that on RH9 and Astlinux 
installations that wget and Asterisk #exec don't mix.  It simply 
doesn't work, even when called from inside a shell script.  It 
doesn't make any sense, but that is what happened.  I even had a bug 
open on it - http://bugs.digium.com/view.php?id=5833  I have _no_ 
idea why this is the case, but I'm assuming it has something to do 
with environment values.  Use "curl" with #exec to fetch files, or if 
someone can figure out why wget doesn't work I'd be interested in 
hearing about it.

JT




More information about the asterisk-users mailing list