Recently I had to update 30 Grandstream GXP1625 VoIP phones to use a new SIP server, as a result of some fallout from the great VoIP meltdown of Fall 2021. Specifically, I had to update these phones from to

In this particular environment, the phones were manually provisioned using a config file, rather than via a provisioning server.

To rapidly edit them all, I wrote the following bash script, which others may find useful.

Security, error handling, and other edge cases are left as an exercise to the reader based on your specific environment.

Invoke the script as follows, specifying the local admin password, the new server URL, and the IP address / hostname of the phone in question.

./ adminpassword

A successful result wil look like this:

./ adminpassword
LOGIN: { "response": "success", "body": { "sid": "806732311e1633476268", "role": "admin", "defaultAuth": false } }
UPDATE: { "response": "success", "body": { "status": "right" } }
COMMIT: { "response": "success", "body": true }

The script is as follows:

#!/usr/bin/env bash

login=$(curl -k -s -c /tmp/cookies.txt -H "Referer: http://${3}/" \
-d"username=admin&password=${1}" http://${3}/cgi-bin/dologin)
echo "LOGIN: ${login}"
update=$(curl -k -s -b /tmp/cookies.txt \
-d"P47=${2}" http://${3}/cgi-bin/
echo "UPDATE: ${update}"
commit=$(curl -k -s -b /tmp/cookies.txt \
-d"cmd=extend" http://${3}/cgi-bin/api-phone_operation)
echo "COMMIT: ${commit}"