Saturday, May 26, 2007

Snom Updates: A custom ASP firmware script

Update: This script is outdated, see http://texhex.blogspot.com/2008/01/new-snom-auto-update-script.html


I really like the VoIP phones from Snom. They are of good quality, not expensive and they have an excellent Wiki that describes all settings quite good. However, when it comes to Firmware updates, you only get the basic information and some PHP examples but not really a detailed description.

Especially about one issue with firmware updates: If you define a firmware configuration file the phone will restart ALWAYS, even if the firmware provided is not newer than the one installed - even if the Snom is currently being used!

To solve this issue, I did the following:

Inside the normal configuration file (called snom.cnf in our case) I defined the following settings for the firmware:


# Updates
firmware_status$: http://update-slinger.local/snom/snom-firmware.asp
update_policy: auto_update
# Check every three hours
firmware_interval$: 180


Inside the folder /snom I placed all current firmware BIN files from Snom and the ASP Script snom-firmware.asp.

This script (see below) simply checks the user agent to make sure that the right phone gets the right firmware. Also, it will ONLY set the "firmware" tag with the URL if it's between 23:00 (11 PM) and 04:00 (4 AM). That way, a Snom that checks for a new firmware during the day will not get the firmware tag and thus does not restart because there is nothing to install.

As we have set the firmware_interval to three hours inside snom.cnf, we have made sure that every telephone will check at least once between 11 PM and 4 AM so a new firmware is deployed to all telephones in one night.

<html>
<pre>

# Auto Update Skript

<%
'Snom Simple Update ASP Script 1.3
'Coypright (C) 2007 by TeX HeX
'http://www.texhex.info


'Definition of download URLs
s300="http://update-slinger.local/snom/snom300-6.5.10-SIP-j.bin"
s320="http://update-slinger.local/snom/snom320-6.5.10-SIP-j.bin"
s360="http://update-slinger.local/snom/snom360-6.5.10-SIP-j.bin"



Dim sUA
sUA=Request.ServerVariables("HTTP_USER_AGENT")

'Debug output, just for reference
Response.Write("# Found USER AGENT --> " + sUA)
Response.Write(chr(13) + chr(10))


'Only write out "firmware:"" tag if it's in the night (23:00 = 11 PM, 04:00 = 4 AM)
if ( hour(now())>=23 or hour(now())<=4 ) then Dim sURL pos=InStr(sUA,"snom300-SIP") if pos>0 then
sURL=s300
end if

pos=InStr(sUA,"snom320-SIP")
if pos>0 then
sURL=s320
end if

pos=InStr(sUA,"snom360-SIP")
if pos>0 then
sURL=s360
end if


Response.Write("firmware: " + sURL)
Response.Write(chr(13) + chr(10))

else

'Debug output, I don't think Snoms can actually undestand this :)
Response.Write("# You did not received a firmware because it's not in the night. We have now: " + cstr(now()) )
Response.Write(chr(13) + chr(10))

end if


%>

</pre>
</html>

No comments:

Post a Comment