Polycom reboot hardphone script

A short PHP script to reboot extensions attached to an Asterisk PBX can be downloaded here. Some more detail about how it works can be found here. This script relies on the instructions below for configuring the sip-notify options in Asterisk, however these have been config defaults in most cases for several years now.

https://gist.github.com/andrewyager/f901714b9f6e5b0d4edd8eded057fa3c
https://andrewyager.com/2016/07/28/performing-batch-upgrades-on-polycom-handsets

The following links for the perl script are dead (July 2016).

You can download the perl script here:

http://www.freedomphones.net/polycom/files/PolyReboot.pl-script

See here for revised version.

With an IP address as a single argument, this script will reboot the Polycom
500 or 600 phone with that IP address.

You must have a cfg file in the Polycom style, i.e., 00ab00cd00ef.cfg - all
lower case. Further, you need to use ftp for your remote cfg loading,
because with ftp synchronization, the phones check the ctimes of the cfg
files against what's in their cache when receiving a check-sync in order to
determine if rebooting is necessary. With tftp synchronization, this script
won't work.

I tested this script. It works on my Polycoms. I have the latest bootrom
and the SIP 1.1.0 software version.

As written this script must be executed on the FTP server.

CVS-HEAD-03/08/05 and Polycom SIP version 1.5.2


I'm not sure when they were interduced, but the above are the versions I'm using and tested.
In your sip.cfg make sure that:

voIpProt.SIP.specialEvent.checkSync.alwaysReboot="1" is set to 1 (0 will only reboot if files on the FTP server have
changed)

In your /etc/asterisk/sip_notify.conf make sure you have:

[polycom-check-cfg]
Event=>check-sync
Content-Length=>0

now on the CLI you can enter:
sip notify polycom-check-cfg xxxx
where xxx is the sip account in sip.conf

This will work even if you don't use an FTP server with the Polycom phones.

Rebooting Polycom Phones from within a dialplan


You can use this from within a dailplan as well. Make sure to pick a password that is very secure. Seems silly to have to call asterisk from itself inorder to do this but it works. I have 200 polycom phones with extensions from 3000 to 3199. This loops through and tells them all to reboot. On an opteron system this takes about 30 seconds to send all the messages out. This is very useful if you have a bunch of phones and are rolling out new features. I either do this late at night or page everyone and let them know an hour before hand.

; Extension RESETPHONES (73738746637) - resets all polycom phones from 3000 - 3199
exten => 73738746637,1,Answer()
exten => 73738746637,2,Authenticate(65) ;get the password
exten => 73738746637,3,Playback(queue-holdtime) ;let them know it will take a while
exten => 73738746637,4,Playback(digits/30)
exten => 73738746637,5,Playback(queue-seconds)
exten => 73738746637,6,Set(COUNT=0) ;start counting
exten => 73738746637,7,GotoIf($["${COUNT}" = "${CALLERID(num):1}"]?9) ;dont reboot the caller... yet
exten => 73738746637,8,System(/usr/sbin/asterisk -rx "sip notify polycom-check-cfg 3${COUNT}") ;reboot a phone
exten => 73738746637,9,Set(COUNT=${MATH(${COUNT}+1,i)}) ;increment the count
exten => 73738746637,10,GotoIf($["${COUNT}" != "200"]?7) ;check if we have rebooted the 200 phones
exten => 73738746637,11,Playback(tt-weasels) ;let them know something happened
exten => 73738746637,12,Playback(queue-thankyou)
exten => 73738746637,13,System(/usr/sbin/asterisk -rx "sip notify polycom-check-cfg ${CALLERID(num)}") ;reboot the caller
exten => 73738746637,14,Hangup()

This would be much cleaner and probably faster if there was a command that you could pass an notify event and a phone and would send it out. Something like SipNotify(). At present this has to make a socket connection to asterisk for each phone which takes some time. If you have maybe 20 - 30 phones the "sip notify" command in the CLI can take mulitple peers but you cannot pass an argument longer than 256 characters to it.

*** NOTE *** Yea, I tried this script and it doesn't really work as stated. There seems to be an issue with step 8. At the end of step 8, it is only going to send reset commands to extension 30 - 3199, not 3000 - 3199. I tried to use this on my system. My extension numbers are 500-599, so I simply copy and pasted this script, replaced the 3 with a 5, and replaced 200 with 100, expecting that it would restart 500 - 599. Well it didn't work as expected. Phones 510 - 599 rebooted, but 501 - 509 didn't reboot. I was a little confused looking at this script to find out where the extra 0 would come into place for counts 1 - 9. There is no hidden miracle. Count is a literal count, it does not pad count numbers based on the number of extensions you are going to reset. - 12/14/2010 - gmalsack

I made a few changes to make the dialplan method more generic. You just set EXTBASE and RANGE. So the extensions you use should be arbitrary. I tested it and it worked, but I do not have more than 100 extensions.

; Extension RESETPHONES (73738746637) - resets all polycom phones from from the EXTBASE number to the end of the RANGE
exten => 73738746637,1,Answer()
exten => 73738746637,2,Authenticate(65) ;get the password
exten => 73738746637,3,Playback(queue-holdtime) ;let them know it will take a while
exten => 73738746637,4,Playback(digits/30)
exten => 73738746637,5,Playback(queue-seconds)
exten => 73738746637,6,Set(COUNT=0) ;start counting
exten => 73738746637,7,Set(EXTBASE=1500) ;set start of extension range.
exten => 73738746637,8,Set(RANGE=200) ;set range of extensions to reboot.
exten => 73738746637,9,GotoIf($["${COUNT}" = "${CALLERID(num):1}"]?12) ;dont reboot the caller... yet
exten => 73738746637,10,Set(EXT=${MATH(${EXTBASE}+${COUNT},i)}) ;increment the extension number
exten => 73738746637,11,System(/usr/sbin/asterisk -rx "sip notify polycom-check-cfg ${EXT}") ;reboot a phone
exten => 73738746637,12,Set(COUNT=${MATH(${COUNT}+1,i)}) ;increment the count
exten => 73738746637,13,GotoIf($["${COUNT}" != "${RANGE}"]?9) ;check if we have rebooted the range of phones
exten => 73738746637,14,Playback(tt-weasels) ;let them know something happened
exten => 73738746637,15,Playback(queue-thankyou)
exten => 73738746637,16,System(/usr/sbin/asterisk -rx "sip notify polycom-check-cfg ${CALLERID(num)}") ;reboot the caller
exten => 73738746637,17,Hangup()
3/15/2011--lafong

You can also reboot individual phones like so:

;Extension RESET30XX (7373830XX) - resets a particular phone in the range 3000 - 3099
exten => _7373830XX,1,Answer()
exten => _7373830XX,n,Authenticate(45376)
exten => _7373830XX,n,System(/usr/sbin/asterisk -rx "sip notify polycom-check-cfg ${EXTEN:5}")
exten => _7373830XX,n,Hangup()

;Extension RESET31XX (7373831XX) - resets a particular phone in the range 3100 - 3199
exten => _7373831XX,1,Answer()
exten => _7373831XX,n,Authenticate(45376)
exten => _7373831XX,n,System(/usr/sbin/asterisk -rx "sip notify polycom-check-cfg ${EXTEN:5}")
exten => _7373831XX,n,Hangup()

This is useful if need to change some settings on a phone, for instance when a new employee comes. You can make the changes on the provisioning server, then reboot the phone without having to go to a remote office.

If you want the phones to always reboot make sure to set

voIpProt.SIP.specialEvent.checkSync.alwaysReboot="1"

in the sip.cfg file, otherwise set

voIpProt.SIP.specialEvent.checkSync.alwaysReboot="0"

and they will only reboot when the config files change on your provisioning server.

Rebooting Polycom phones from a closed Asterisk PBX


For those people who do not have access to the Asterisk CLI (ie Switchvox) the following script will give you the ability to still reboot your Polycom phones, as long as they are provisioned. This script MUST be executed on your provisioning server. If you use this script, remember to change the 3 variables towards the top to reflect your setup.

Image


The above script assumes that you're using firmware 2.0.*
Simply touching the cfg file is no longer enough for the phone to reboot, as the phone will checksum all the cfg files before it reboots.


Polycom Phones

A short PHP script to reboot extensions attached to an Asterisk PBX can be downloaded here. Some more detail about how it works can be found here. This script relies on the instructions below for configuring the sip-notify options in Asterisk, however these have been config defaults in most cases for several years now.

https://gist.github.com/andrewyager/f901714b9f6e5b0d4edd8eded057fa3c
https://andrewyager.com/2016/07/28/performing-batch-upgrades-on-polycom-handsets

The following links for the perl script are dead (July 2016).

You can download the perl script here:

http://www.freedomphones.net/polycom/files/PolyReboot.pl-script

See here for revised version.

With an IP address as a single argument, this script will reboot the Polycom
500 or 600 phone with that IP address.

You must have a cfg file in the Polycom style, i.e., 00ab00cd00ef.cfg - all
lower case. Further, you need to use ftp for your remote cfg loading,
because with ftp synchronization, the phones check the ctimes of the cfg
files against what's in their cache when receiving a check-sync in order to
determine if rebooting is necessary. With tftp synchronization, this script
won't work.

I tested this script. It works on my Polycoms. I have the latest bootrom
and the SIP 1.1.0 software version.

As written this script must be executed on the FTP server.

CVS-HEAD-03/08/05 and Polycom SIP version 1.5.2


I'm not sure when they were interduced, but the above are the versions I'm using and tested.
In your sip.cfg make sure that:

voIpProt.SIP.specialEvent.checkSync.alwaysReboot="1" is set to 1 (0 will only reboot if files on the FTP server have
changed)

In your /etc/asterisk/sip_notify.conf make sure you have:

[polycom-check-cfg]
Event=>check-sync
Content-Length=>0

now on the CLI you can enter:
sip notify polycom-check-cfg xxxx
where xxx is the sip account in sip.conf

This will work even if you don't use an FTP server with the Polycom phones.

Rebooting Polycom Phones from within a dialplan


You can use this from within a dailplan as well. Make sure to pick a password that is very secure. Seems silly to have to call asterisk from itself inorder to do this but it works. I have 200 polycom phones with extensions from 3000 to 3199. This loops through and tells them all to reboot. On an opteron system this takes about 30 seconds to send all the messages out. This is very useful if you have a bunch of phones and are rolling out new features. I either do this late at night or page everyone and let them know an hour before hand.

; Extension RESETPHONES (73738746637) - resets all polycom phones from 3000 - 3199
exten => 73738746637,1,Answer()
exten => 73738746637,2,Authenticate(65) ;get the password
exten => 73738746637,3,Playback(queue-holdtime) ;let them know it will take a while
exten => 73738746637,4,Playback(digits/30)
exten => 73738746637,5,Playback(queue-seconds)
exten => 73738746637,6,Set(COUNT=0) ;start counting
exten => 73738746637,7,GotoIf($["${COUNT}" = "${CALLERID(num):1}"]?9) ;dont reboot the caller... yet
exten => 73738746637,8,System(/usr/sbin/asterisk -rx "sip notify polycom-check-cfg 3${COUNT}") ;reboot a phone
exten => 73738746637,9,Set(COUNT=${MATH(${COUNT}+1,i)}) ;increment the count
exten => 73738746637,10,GotoIf($["${COUNT}" != "200"]?7) ;check if we have rebooted the 200 phones
exten => 73738746637,11,Playback(tt-weasels) ;let them know something happened
exten => 73738746637,12,Playback(queue-thankyou)
exten => 73738746637,13,System(/usr/sbin/asterisk -rx "sip notify polycom-check-cfg ${CALLERID(num)}") ;reboot the caller
exten => 73738746637,14,Hangup()

This would be much cleaner and probably faster if there was a command that you could pass an notify event and a phone and would send it out. Something like SipNotify(). At present this has to make a socket connection to asterisk for each phone which takes some time. If you have maybe 20 - 30 phones the "sip notify" command in the CLI can take mulitple peers but you cannot pass an argument longer than 256 characters to it.

*** NOTE *** Yea, I tried this script and it doesn't really work as stated. There seems to be an issue with step 8. At the end of step 8, it is only going to send reset commands to extension 30 - 3199, not 3000 - 3199. I tried to use this on my system. My extension numbers are 500-599, so I simply copy and pasted this script, replaced the 3 with a 5, and replaced 200 with 100, expecting that it would restart 500 - 599. Well it didn't work as expected. Phones 510 - 599 rebooted, but 501 - 509 didn't reboot. I was a little confused looking at this script to find out where the extra 0 would come into place for counts 1 - 9. There is no hidden miracle. Count is a literal count, it does not pad count numbers based on the number of extensions you are going to reset. - 12/14/2010 - gmalsack

I made a few changes to make the dialplan method more generic. You just set EXTBASE and RANGE. So the extensions you use should be arbitrary. I tested it and it worked, but I do not have more than 100 extensions.

; Extension RESETPHONES (73738746637) - resets all polycom phones from from the EXTBASE number to the end of the RANGE
exten => 73738746637,1,Answer()
exten => 73738746637,2,Authenticate(65) ;get the password
exten => 73738746637,3,Playback(queue-holdtime) ;let them know it will take a while
exten => 73738746637,4,Playback(digits/30)
exten => 73738746637,5,Playback(queue-seconds)
exten => 73738746637,6,Set(COUNT=0) ;start counting
exten => 73738746637,7,Set(EXTBASE=1500) ;set start of extension range.
exten => 73738746637,8,Set(RANGE=200) ;set range of extensions to reboot.
exten => 73738746637,9,GotoIf($["${COUNT}" = "${CALLERID(num):1}"]?12) ;dont reboot the caller... yet
exten => 73738746637,10,Set(EXT=${MATH(${EXTBASE}+${COUNT},i)}) ;increment the extension number
exten => 73738746637,11,System(/usr/sbin/asterisk -rx "sip notify polycom-check-cfg ${EXT}") ;reboot a phone
exten => 73738746637,12,Set(COUNT=${MATH(${COUNT}+1,i)}) ;increment the count
exten => 73738746637,13,GotoIf($["${COUNT}" != "${RANGE}"]?9) ;check if we have rebooted the range of phones
exten => 73738746637,14,Playback(tt-weasels) ;let them know something happened
exten => 73738746637,15,Playback(queue-thankyou)
exten => 73738746637,16,System(/usr/sbin/asterisk -rx "sip notify polycom-check-cfg ${CALLERID(num)}") ;reboot the caller
exten => 73738746637,17,Hangup()
3/15/2011--lafong

You can also reboot individual phones like so:

;Extension RESET30XX (7373830XX) - resets a particular phone in the range 3000 - 3099
exten => _7373830XX,1,Answer()
exten => _7373830XX,n,Authenticate(45376)
exten => _7373830XX,n,System(/usr/sbin/asterisk -rx "sip notify polycom-check-cfg ${EXTEN:5}")
exten => _7373830XX,n,Hangup()

;Extension RESET31XX (7373831XX) - resets a particular phone in the range 3100 - 3199
exten => _7373831XX,1,Answer()
exten => _7373831XX,n,Authenticate(45376)
exten => _7373831XX,n,System(/usr/sbin/asterisk -rx "sip notify polycom-check-cfg ${EXTEN:5}")
exten => _7373831XX,n,Hangup()

This is useful if need to change some settings on a phone, for instance when a new employee comes. You can make the changes on the provisioning server, then reboot the phone without having to go to a remote office.

If you want the phones to always reboot make sure to set

voIpProt.SIP.specialEvent.checkSync.alwaysReboot="1"

in the sip.cfg file, otherwise set

voIpProt.SIP.specialEvent.checkSync.alwaysReboot="0"

and they will only reboot when the config files change on your provisioning server.

Rebooting Polycom phones from a closed Asterisk PBX


For those people who do not have access to the Asterisk CLI (ie Switchvox) the following script will give you the ability to still reboot your Polycom phones, as long as they are provisioned. This script MUST be executed on your provisioning server. If you use this script, remember to change the 3 variables towards the top to reflect your setup.

Image


The above script assumes that you're using firmware 2.0.*
Simply touching the cfg file is no longer enough for the phone to reboot, as the phone will checksum all the cfg files before it reboots.


Polycom Phones

Created by: mflorell, Last modification: Fri 29 of Jul, 2016 (07:37 UTC) by yogel
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+