Asterisk: forward if peer unreachable
- by Cedric H.
I would like to respond to incoming calls by checking is a specific peer is reachable, and dial the appropriate number accordingly.
Presently I did this:
exten => 1200,1,Answer()
same => n,Set(reachable=${SHELL(asterisk -rx "sip show peers" | grep ^cedrich-phone.*OK)})
same => n,GotoIf($["${LEN(${reachable})}" = "0"]?extoffline)
same => n,Dial(SIP/cedrich-phone,20)
same => n(extoffline),Dial(SIP/another-phone,20,tr)
same => n,Hangup()
Could you tell me if this is acceptable and if it can be improved ?