Here’s the whole thing, works great actually:
asterisk -rx "pjsip list endpoints" | grep -Ev "Unavailable|found|CID|=" | grep "\S" | cut -f 1 -d "/" | cut -b 13-16 > endpoints.txt
while read LINE; do asterisk -rx "pjsip send notify restart-yealink endpoint $LINE"; done < endpoints.txt
I have all Yealink phones so I had to add the following to sip_notify_custom.conf
[restart-yealink]
Event=>check-sync\;reboot=true