Search This Blog

Showing posts with label asterisk. Show all posts
Showing posts with label asterisk. Show all posts

Tuesday, June 01, 2021

Digium phone stuck on Contacting sip:proxy@IP:5060


Any normal/softphone works perfectly, but Sangoma (Digium) phones uses an SSL certificate to encrypt phone configuration messages. That certificate expired on May 28th, 2021. The certificate is embedded in the DPMA blob, so it can't be renewed.

Basically  this is the cost of putting binary blobs on your server :(

The solution is to download a new binary blob from digium and to replace the existing one in /usr/lib/asterisk/modules

check https://my.digium.com/en/docs/DPMA/dpma-download for the right DPMA module.


# cd /root
# wget http://downloads.digium.com/pub/telephony/res_digium_phone/asterisk-13.0/x86-32/

res_digium_phone-13.0_current-x86_32.tar.gz
# tar
res_digium_phone-13.0_current-x86_32.tar.gz        

# cp /root/res_digium_phone-13.0_current-x86_32/res_digium_phone.so /usr/lib/asterisk/modules


 # asterisk -rx "module reload res_digium_phone.so"

 

 

Thursday, February 13, 2020

Asterisk PAGE say time every hour

Digium D6x phones and CyberData SIP Speakers  are used to page.
The phones are also used as intercoms (bidirectional page).

To start, we need accounts for the phones/speakers added to sip.conf:



[phone1] ; Phone
type=friend
host=dynamic
context=my-context
secret=5678
mailbox=319

[speaker1]; Speaker
type=friend 
host=dynamic
context=my-context
secret=1234
mailbox=329
record_out=Adhoc
record_in=Adhoc
qualify=no


Then in extensions.conf, in the [my-context] context, add:

; Paging extensions
exten => 3319,1,GotoIf($[ ${CALLERID(number)} = 319 ]?skipself)
exten => 3319,1,SIPAddHeader(Alert-Info: info=<intercom>) ; Digium D6x require this to enable paging - search documentation for different phone models!
exten => 3319,n,Dial(SIP/phone1) ; this is the phone1 defined in sip.conf
exten => 3319,n(skipself),Noop(Not paging originator)

exten => 3329,1,GotoIf($[ ${CALLERID(number)} = 329 ]?skipself)
exten => 3329,n,Dial(SIP/speaker1,50) ; this is the speaker1 defined in sip.conf
exten => 3329,n(skipself),Noop(Not paging originator)

exten => 398,1,Page(LOCAL/3319@my-context&LOCAL/3329@my-context,di,120) ; Bidirectional PAGE - that's what the "d" does.
exten => 398,n,Hangup()

With this, we can dial 398 and the PAGE should work.

Now, in order to say the time automatically, we need a .call file, let's create /var/lib/asterisk/third-party/say-time.call

Channel: LOCAL/398@my-context
MaxRetries: 10
RetryTime: 5
WaitTime: 20
Context: page-say-time
Extension: 3310

Of course, we need to create the [page-say-time] context in extensions.conf:

[page-say-time]
exten => 3310,1,Answer()
exten => 3310,n,Wait(1)
exten => 3310,n,Playback(at-tone-time-exactly) ; this sound file is already in asterisk sounds
exten => 3310,n,Wait(1)
exten => 3310,n,SayUnixTime(,EST,IMp)
exten => 3310,n,Wait(1)
exten => 3310,n,Playback(beep) ; this sound file is already in asterisk sounds
exten => 3310,n,Wait(2)
exten => 3310,n,Hangup()

and the last step, create a crontab that copies the say-time.call to the astersk outgoing at every fix hour:

0  * *  *  * /bin/cp /var/lib/asterisk/third-party/say-time.call /var/spool/asterisk/outgoing/


Friday, June 02, 2017

Phone extension that rings multiple external numbers (CCME Asterisk)

Skip to end of metadata
In this example we want to ring all the external numbers of a few people only by dialing extension 3331.
1: Connect to CCME and create a new dial-peer:
dial-peer voice 3331 voip
 description External Emergency Responders
 destination-pattern 3331$
 session protocol sipv2
 session target ipv4:192.168.0.XXX #(the Asterisk box)
 dtmf-relay rtp-nte cisco-rtp
 codec g711ulaw
 no vad
2: Connect to the asterisk server and add the extension in the default [incoming_context] in /etc/asterisk/extensions.conf: (192.168.0.YYY is the outgoing trunk)
exten => 3331,1,Dial(SIP/5145555555@192.168.0.YYY&SIP/51455555519@192.168.0.YYY&SIP/5145555552@192.168.0.YYY&SIP/5145555553@192.168.0.YYY&SIP/5145555554@192.168.0.YYY&SIP/5145555555@192.168.0.YYY)
exten => 3331,n,Hangup
3: Reload asterisk config and test the extension (smile)

Friday, April 06, 2012

Cyclic paging script

Let's say that we have an emergency voicemail box where our clients can leave us messages if they have a contract for extended hours or a limited response time contract. Let's also suppose that we have a shitty mobile phone provider, whose signal does no goes higher that 3000ft and is not available too far in wilderness, but we still have those old pagers, able to receive the signal even on top of mount Everest. And let's say that we have a bunch of unfortunate enough bastards on call that are supposed to respond to those calls. Now, every week it's some other poor bastard turn to be on call, but just in case he's not available, we might be force to page the other unfortunates, even when it is not their week of duty. And we page them in order, one after another, until one of them login the web interface of our asterisk server or call the emergency mailbox and acknowledge the message.
This is the script that have to be run from cron every */10 minutes on the asterisk server:


#!/bin/bash
# A script that checks for new messages on emergency voicemail and send messages to pagers
# (c) 2012 sorin@xxxxxxxx.com under the terms of GNU GPL
#
# 2012/06/23 v0.5 neXt (sorin@xxxxxxxx.com) - Add names to email
# 2012/06/09 v0.4 neXt (sorin@xxxxxxxx.com) - Don't send pages during the night
# 2012/05/10 v0.3 neXt (sorin@xxxxxxxx.com) - Monday morning warn the user on duty
# 2012/04/09 v0.2 neXt (sorin@xxxxxxxx.com) - Verify if the cycle has been done today
# 2012/04/06 v0.1 neXt (sorin@xxxxxxxx.com) - Initial release


# Voicemail location
voicemail=/var/spool/asterisk/voicemail/default/911/INBOX/

# Paging provider
provider=paging.xxxxxxxx.com

# Working directory
working=/var/emergency
if [ ! -d $working ] ; then
 mkdir -p $working
fi

# Location of the file containing the pager numbers
pagers=$working/pager_numbers
if [ ! -f $pagers ] ; then
 # If the pager file does not exist define the defaults - We need a NEW-LINE at the end of the file!
 echo "5140000000 John Doe john@xxxxxxxx.com
5140000001 Jane Doe jane@xxxxxxxx.com
5140000002 Jack Doe jack@xxxxxxxx.com
" > $pagers
fi

# A temporary file containing a volatile data
runvars=$working/tmpvars
if [ ! -f $runvars ] ; then
 # If the variables file does not exist define some sane defaults
 echo "current=1" > $runvars
 echo "oldday=0" > $runvars
fi

# Cycle pager numbers every Monday, the first number will become the last
today=`date +%w`
day=`date +%d%m`
# read the variables
. $runvars 1>&2>/dev/null
# If today is Monday (weekday 1) and the numbers were not already cycled
if [ $today = 1 ] && [ ! $day = $oldday ]; then
 # copy pager numbers to a new file, deleting the first line of this file
 sed -n "2,\$ p;/^ *$/d" $pagers > $pagers.new
 # read the first line of the old file and put that line at the end of the new file
 head -1 $pagers >> $pagers.new
 # replace the old file with the new one
 mv -f $pagers.new $pagers
 # send an email with the name and number of the current guy on duty
 guy=`head -n1 $pagers | tail -n1
 recipients=`cat $pagers | sed 's/[^@]* \([a-zA-Z0-9.]*@[^ ]*\).*/\1/' | sed ':a;N;$!ba;s/\n/ /g'`
 echo "This week the main pager is $guy" | mail -s "Pager $guy" $recipients
 # page this new guy with a test message, but not in the middle of the night, 07:30AM seems like OK-ish...
 guynr=`echo "$guy" | cut -f1 -d" "`
 wrn="echo '00 10-86 00' | mail -s911 $guynr@$provider"
 echo $wrn | at 07:30
 # keep the today's date into variable oldday - used to see if we've already processed the cycle today
 sed -i "/oldday/d" $runvars
 echo "oldday=$day" >> $runvars
fi

# We DO NOT send paging messages between 10PM and 7AM - there are no contracts between those hours
if [ $((10#$(date +%H%M))) -gt 700 ] && [ $((10#$(date +%H%M))) -lt 2200 ]; then

 # Let's see if there are new messages in the emergency voicemail
 messages=`ls -l $voicemail | wc -l`
 if [ $messages -gt 1 ]; then
  # There is something in the voicemail, read the already defined variables to see to whom we have to send the page
. $runvars 1>&2>/dev/null
   # If we are aleady at the end of the paging list, we have to restart from the beginning and annoy everybody again
   max_current=`wc -l $pagers | cut -f1 -d" "`
   if [ $current -gt $max_current ]; then
    current=1
   fi
   # Hell, let's send a page to the sucker that is on duty today. Extract only the phone number from file.
   current_page=`head -n$current $pagers | tail -n1 | cut -f1 -d" "`
#  echo "msg=$messages max=$max_current cn=$current cur=$current_page" # This line is here for debugging
   echo "10-78 911" | mail -s911 $current_page@$provider
   # Now remember, we've already sent a page to this unfortunate, if he's not available, we'll have to move to the next in line
   current=`expr $current + 1`
   sed -i "/current/d" $runvars
   echo "current=$current" >> $runvars
 else
   # Cleanup the variables, some poor bastard took the message, we reset the counter
   sed -i "/current/d" $runvars
   echo "current=1" >> $runvars
 fi
fi

---------------------------------------------------------------------------------------------  Note: This is work in progress. I'll update changes during time.