It's very simple, it queries the Asterisk running process for all extension numbers, then uses the SIP NOTIFY method to send a reboot to the phones.
I've tested this on GXP1620 handsets so far and it works great, the phone reboots almost immediately. I've added a 25 second sleep in between each phone reboot, the idea is not to reboot your entire estate at the same time, leaving no phones available. Change that as required. My plan is to schedule this on a cron job overnight anyway, but still spacing reboots out seems to be more sensible.
Caveats: The script simply grabs all extensions and iterates through them all, so it'll try extensions that aren't Grandstream, or aren't phones (e.g. trunks) but those will just get ignored anyway.
It's very simple and rough but will do the job!#!/bin/bashEXTENSION_LIST=`asterisk -rx "sip show peers" | cut -d "/" -f 1 |cut -d " " -f 1 | grep -o '[0-9]*'`while read -r line; doecho "Rebooting extension: $line ..."asterisk -rx "sip notify spa-reboot $line"echo "(sleep)"sleep 25done <<< "$EXTENSION_LIST"