Skip to content

Instantly share code, notes, and snippets.

@calanor
Last active January 29, 2025 16:35
Show Gist options
  • Save calanor/5cf5b51e7655f3c81e27c654aedec9a5 to your computer and use it in GitHub Desktop.
Save calanor/5cf5b51e7655f3c81e27c654aedec9a5 to your computer and use it in GitHub Desktop.
Asterisk. Remove unavailable contacts script
#!/bin/bash
contacts="$(asterisk -rx 'database show registrar/contact')"
while read -r line ; do
dbline=$(echo "$contacts" | grep ${line} | awk '{ print $1 }' | cut -d/ -f4 | cut -d: -f1)
echo Remove stuck contact: ${dbline}
asterisk -rx "database deltree registrar/contact ${dbline}"
done < <(asterisk -rx 'pjsip show contacts' | grep Unavail | awk '{ print $3}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment