| Subcribe via RSS

Openfire/Jabber/FreePBX integration #2

January 6th, 2010 | No Comments | Posted in Asterisk, FreePBX, Openfire, VoIP

Having played some more I’ve come up with the following solution – I’m not overly happy with it but it allows me to get what I wanted.
All of the following occurs in extensions_override_freepbx.conf
NOTE: This assumes you have gotten the Openfire Asterisk-IM plugin working and that you have jabber.conf configured correctly to talk to your openfire server.

Asterisk obeying Openfire Status

eg. When you mark yourself as away/DND inbound calls will be directed to Voicemail.

This inserts itself into the standard FreePBX call queue for internal calls. I haven’t got an inbound link setup yet so I haven’t figured out how to get that bit working.

The jabber-notify block must contain every extension in the system this is to work on. It could be altered to return to the normal call path if a desired extension isn’t in the list – but I haven’t implemented that.

Basically a call to an extension picks up the appropriate jabber information and runs the macro “reach_user_with_presence”. There is probably some way to hook this into a db/ldap server so you don’t have to enter everyone in manually.

This then checks the users jabber status and if they are not available it jumps to their voicemail. Else it returns to the normal call path.

[from-internal]
include => jabber-notify

[jabber-notify]
;include => macro-reach_user_with_presence
exten => 10,1,Macro(reach_user_with_presence,user10@jabber.kayosdesign.com,${EXTEN})
exten => 11,1,Macro(reach_user_with_presence,user20@jabber.kayosdesign.com,${EXTEN})
exten => 12,1,Macro(reach_user_with_presence,user30@jabber.kayosdesign.com,${EXTEN})
exten => 13,1,Macro(reach_user_with_presence,user40@jabber.kayosdesign.com,${EXTEN})

[from-internal-original]
include => from-internal-xfer
include => bad-number

[macro-reach_user_with_presence]
; ${ARG1} is a jabber address such as test@jabber.server
; ${ARG2} is the voicemail box of the user

exten => s,1,jabberstatus(asterisk,${ARG1},STATUS)
;presence in will be 1-6.
;In order : Online, Chatty, Away, XAway, DND, Offline
;If not in roster variable will = 7
exten => s,n,gotoif($[$[${STATUS}]<3]?available:unavailable) ;GotoIf(condition?label_if_true:label_if_false) ;exten => s,n(available),jabbersend(asterisk,${ARG2},"Call from ${CALLERID(name)} at number ${CALLERID(num)} on ${STRFTIME(,GMT-1,%A %B %d %G at %l:%M:%S %p)}")
exten => s,n(available),Goto(from-internal-original,${ARG2},1)
exten => s,n(unavailable),VoiceMail(${ARG2},u)
exten => s,1,Goto(from-internal-original,s,1)
exten => h,1,Macro(hangupcall)

Call groups being notified by jabber for inbound calls.

We utilise the Counterpath Bria softphone. It’s a bit stupid and does not follow ALERT notifications such as  different ring tones.  As such there is no way for a user to know if an inbound call is implicitely for them or if it is coming in on the call group.

As such I hooked Asterisk into jabber to broadcast a message to all people in the call group. I don’t particularly like this as you cannot create call groups dynamically using the FreePBX interface. If you do create one you MUST rebuild this section appropriately. Basically all it does is override the default settings and sends out an IM to everyone listed (you have to add each individual in the group to the ext-group section), after that it returns to the setup created by FreePBX.

[ext-group]
exten => 330,1,jabbersend(asterisk,user10@jabber.kayosdesign.com,"Group call")
exten => 330,n,jabbersend(asterisk,user20@jabber.kayosdesign.com,"Group call")

exten => 330,n,Goto(ext-group-original,330,1)

[ext-group-original]
exten => 330,1,Macro(user-callerid,)
exten => 330,n,GotoIf($["foo${BLKVM_OVERRIDE}" = "foo"]?skipdb)
exten => 330,n,GotoIf($["${DB(${BLKVM_OVERRIDE})}" = "TRUE"]?skipov)
exten => 330,n(skipdb),Set(__NODEST=)
exten => 330,n,Set(__BLKVM_OVERRIDE=BLKVM/${EXTEN}/${CHANNEL})
exten => 330,n,Set(__BLKVM_BASE=${EXTEN})
exten => 330,n,Set(DB(${BLKVM_OVERRIDE})=TRUE)
exten => 330,n(skipov),Set(RRNODEST=${NODEST})
exten => 330,n(skipvmblk),Set(__NODEST=${EXTEN})
exten => 330,n,Set(RecordMethod=Group)
exten => 330,n,Macro(record-enable,11-13,${RecordMethod})
exten => 330,n,Set(RingGroupMethod=ringall)
exten => 330,n,Set(__ALERT_INFO='\\;info=ring_two')

exten => 330,n(DIALGRP),Macro(dial,20,${DIAL_OPTIONS},11-13)
exten => 330,n,Set(RingGroupMethod=)
exten => 330,n,GotoIf($["foo${RRNODEST}" != "foo"]?nodest)
exten => 330,n,Set(__NODEST=)
exten => 330,n,dbDel(${BLKVM_OVERRIDE})
exten => 330,n,Hangup
exten => 330,n(nodest),Noop(SKIPPING DEST, CALL CAME FROM Q/RG: ${RRNODEST})

OpenLDAP & Ubuntu Karmic for an LDAP Addressbook

January 6th, 2010 | No Comments | Posted in Karmic Koala, OpenLDAP

With the advent of Ubuntu Karmic setting up OpenLDAP has gotten stupid and difficult.

Below are the steps I used to get OpenLDAP working as an LDAP addressbook.

NOTE: Change the domain to something appropriate for you.

NOTE: This is not a step by step instruction manual. It’s for my edification so I can figure it out again later without perusing 30 odd different sites. It will require some thought and intelligence to use.


First start off by installing OpenLDAP

apt-get install slapd ldap-utils

This results in a basic setup of OpenLDAP with bugger all configured, even the old school slapd.conf is missing. You need to install all the extra schemas and set up passwords yourself as the installer does nothing at all.

Next install some schemas

ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/cosine.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/inetorgperson.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/nis.ldif

NIS can be left out if you don’t intend on using the LDAP server for authentication.

The following ldif contains all the configuration to get a new database up and running, stash it in a file somewhere.

If you are not using NIS then leave out the shadowLastChange attribute. Also set the passwords to whatever you want using the slappasswd tool, or you can probably type a password in cleartext.

###########################################################
# DATABASE SETUP
###########################################################
# Load modules for database type
dn: cn=module{0},cn=config
objectClass: olcModuleList
cn: module{0}
olcModulePath: /usr/lib/ldap
olcModuleLoad: {0}back_hdb

# Create directory database
dn: olcDatabase=hdb,cn=config
objectClass: olcDatabaseConfig
objectClass: olcHdbConfig
olcDatabase: hdb
olcDbDirectory: /var/lib/ldap
olcSuffix: dc=kayosdesign,dc=com
olcRootDN: cn=admin,dc=kayosdesign,dc=com
olcRootPW: {SSHA}8QDckoodrIsXgv/BG43Hf5WAbgmzZYEf
olcAccess: {0}to attrs=userPassword,shadowLastChange by dn="cn=admin,dc=kayosdesign,dc=com" write by anonymous auth by self write by * none
olcAccess: {1}to dn.base="" by * read
olcAccess: {2}to * by dn="cn=admin,dc=kayosdesign,dc=com" write by * read
olcLastMod: TRUE
olcDbCheckpoint: 512 30
olcDbConfig: {0}set_cachesize 0 2097152 0
olcDbConfig: {1}set_lk_max_objects 1500
olcDbConfig: {2}set_lk_max_locks 1500
olcDbConfig: {3}set_lk_max_lockers 1500
olcDbIndex: uid pres,eq
olcDbIndex: cn,sn,mail pres,eq,approx,sub
olcDbIndex: objectClass eq

##########################################################
# DEFAULTS MODIFICATION
###########################################################
# Some of the defaults need to be modified in order to allow
# remote access to the LDAP config. Otherwise only root
# will have administrative access.
dn: cn=config
changetype: modify
delete: olcAuthzRegexp

dn: olcDatabase={-1}frontend,cn=config
changetype: modify
delete: olcAccess

dn: olcDatabase={0}config,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA}8QDckoodrIsXgv/BG43Hf5WAbgmzZYEf

dn: olcDatabase={0}config,cn=config
changetype: modify
delete: olcAccess

Install this by using

ldapadd -Y EXTERNAL -H ldapi:/// -f /root/db.ldif

Now create an ldif for an admin user

# Root of the LDAP tree
dn: dc=kayosdesign,dc=com
objectClass: dcObject
objectClass: organization
o: kayosdesign.com
dc: kayosdesign
description: Tree Root

#LDAP admin
dn: cn=admin,dc=kayosdesign,dc=com
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: admin
userPassword: {SSHA}8QDckoodrIsXgv/BG43Hf5WAbgmzZYEf
description: LDAP administrator account

Insert this into the directory with the following

ldapadd -x -D cn=admin,dc=home,dc=com -W -f /root/base.ldif

You should now be able to search the directory

ldapsearch -xLLL -b cn=config -D cn=admin,cn=config -W
ldapsearch -xLLL -b cn=config -D cn=admin,cn=config -W olcDatabase={1}hdb
ldapsearch -xLLL -b dc=home,dc=com

Once the above is working you can now move on to creating the Addressbook.

Create yet another ldif file with data such as

# Addressbook branch
dn: ou=addressbook,dc=kayosdesign,dc=com
objectClass: organizationalUnit
ou: addressbook
description: LDAP Addressbook

# Addressbook entry
dn: cn=Test Account+mail=test@kayosdesign.com,ou=addressbook,dc=kayosdesign,dc=com
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
givenName: Test
sn: Account
cn: Test Account
mail: test@kayosdesign.com
homePhone: 1234567
telephoneNumber: 76543421
fax: 01928374
mobile: 44556677
street: 1 Street
l: MyTown
st: MyState
postalCode: 666
title: Grand Poo Bah
o: Snorks Anonymous

Insert the entry into the directory with the following

ldapadd -x -D cn=admin,dc=kayosdesign,dc=com -W -f /root/addressbook.ldif

You can now hook whatever addressbook system you want into the LDAP server using the BaseDN

ou=addressbook,dc=kayosdesign,dc=com

Torchlight Gems

January 5th, 2010 | No Comments | Posted in Uncategorized

I spent too much time playing Torchlight

Below is a table showing all the different socketable gems that can be upgraded.

Deep Flow Pure Life Eyeball Core Fire Cold Skull
Cracked 1 Armor Degraded/+2 Dexterity +3 Electric Damage/+2 Electrical Resistance +4 Damage/+3 Armor +3 Poison Damage/+2 Poison Resistance 2 Mana Stolen/+2 Magic 2 Health per Second/+2 Strength +3 Fire Damage/+3 Fire Resistance +3 Ice Damage/+3 Ice Resistance 1 Health Stolen/+2 Defense
Dull 3 Armor Degraded/+3 Dexterity +6 Electric Damage/+4 Electrical Resistance +9 Damage/+5 Armor +6 Poison Damage/+4 Poison Resistance 3 Mana Stolen/+3 Magic 4 Health per Second/+3 Strength +6 Fire Damage/+4 Fire Resistance +6 Ice Damage/+4 Ice Resistance 5 Health Stolen/+3 Defense
Discoloured 6 Armor Degraded/+4 Dexterity +9 Electric Damage/+7 Electrical Resistance +14 Damage/+9 Armor +9 Poison Damage/+7 Poison Resistance 5 Mana Stolen/+4 Magic 6 Health per Second/+4 Strength +9 Fire Damage/+7 Fire Resistance +9 Ice Damage/+7 Ice Resistance 10 Health Stolen/+4 Defense
- 10 Armor Degraded/+5 Dexterity +12 Electric Damage/+10 Electrical Resistance +18 Damage/+12 Armor +12 Poison Damage/+10 Poison Resistance 6 Mana Stolen/+5 Magic 8 Health per Second/+5 Strength +12 Fire Damage/+10 Fire Resistance +12 Ice Damage/+10 Ice Resistance 14 Health Stolen/+5 Defense
Cut 14 Armor Degraded/+6 Dexterity +16 Electric Damage/+13 Electrical Resistance +24 Damage/+16 Armor +16 Poison Damage/+13 Poison Resistance 8 Mana Stolen/+6 Magic 10 Health per Second/+6 Strength +16 Fire Damage/+13 Fire Resistance +16 Ice Damage/+13 Ice Resistance 19 Health Stolen/+6 Defense
Polished 19 Armor Degraded/+7 Dexterity +19 Electric Damage/+15 Electrical Resistance +28 Damage/+19 Armor +19 Poison Damage/+15 Poison Resistance 9 Mana Stolen/+7 Magic 11 Health per Second/+7 Strength +19 Fire Damage/+15 Fire Resistance +19 Ice Damage/+15 Ice Resistance 23 Health Stolen/+7 Defense
Star 25 Armor Degraded/+9 Dexterity +22 Electric Damage/+19 Electrical Resistance +33 Damage/+23 Armor +22 Poison Damage/+19 Poison Resistance 11 Mana Stolen/+9 Magic 13 Health per Second/+9 Strength +22 Fire Damage/+19 Fire Resistance +22 Ice Damage/+19 Ice Resistance 28 Health Stolen/+9 Defense
Flawless 31 Armor Degraded/+10 Dexterity +25 Electric Damage/+21 Electrical Resistance +38 Damage/+26 Armor +25 Poison Damage/+21 Poison Resistance 12 Mana Stolen/+10 Magic 15 Health per Second/+10 Strength +25 Fire Damage/+21 Fire Resistance +25 Ice Damage/+21 Ice Resistance 32 Health Stolen/+10 Defense
Perfected 39 Armor Degraded/+11 Dexterity +29 Electric Damage/+24 Electrical Resistance +43 Damage/+30 Armor +29 Poison Damage/+24 Poison Resistance 14 Mana Stolen/+11 Magic 17 Health per Second/+11 Strength +29 Fire Damage/+24 Fire Resistance +29 Ice Damage/+24 Ice Resistance 37 Health Stolen/+11 Defense
Named 48 Armor Degraded/+12 Dexterity +33 Electric Damage/+28 Electrical Resistance +49 Damage/+34 Armor +33 Poison Damage/+28 Poison Resistance 15 Mana Stolen/+12 Magic 19 Health per Second/+12 Strength +33 Fire Damage/+28 Fire Resistance +33 Ice Damage/+28 Ice Resistance 42 Health Stolen/+12 Defense
The Grand Depths Ember Shard The Eternal Flow-Ember Shard The Infinite Pure Ember Shard The Spire City Life Ember Shard Etlitch’s Eyeball The Sea Kings Core Ember Shard The Fire Queen Fire Ember Shard The Earthstar Cold Ember Shard The Pirates Skull

Asterisk – Jabber integration

December 31st, 2009 | No Comments | Posted in Asterisk, FreePBX, Openfire, VoIP

I have a test server running Asterisk & Openfire. Integrating Openfire to Asterisk was pretty simple using the Asterisk-IM plugin.

It is configured and working using the documentation provided by Openfire. No when someone receives/makes a call Openfire updates their IM status to “On the phone”.

However, it does not appear to be bi-directional eg. Setting jabber status to DND does not tell Asterisk to send your calls to voicemail.

Having played with the config I now have bi directional communication between asterisk/openfire working within the FreePBX framework.

The code below will check extensions to see what their status is in jabber before passing the call on to them.

If they are flagged as available, the server will send them an IM telling them about the incoming call & then pass the call through.

If they are not available, the server will direct the incoming call to voicemail.

editing extensions_custom.conf you need the following

[from-internal-custom]
include => macro-reach_user_with_presence
exten => 10,1,Macro(reach_user_with_presence,SIP/10,test@jabber.server,${EXTEN})
[macro-reach_user_with_presence]
; ${ARG1} is a destination such as SIP/10
; ${ARG2} is a jabber address such as test@jabber.server
; ${ARG3} is the voicemail box of the user

exten => s,1,jabberstatus(asterisk,${ARG2},STATUS)
;presence in will be 1-6.
;In order : Online, Chatty, Away, XAway, DND, Offline
;If not in roster variable will = 7
exten => s,n,gotoif($[$[${STATUS}]<3]?available:unavailable)
;GotoIf(condition?label_if_true:label_if_false)
exten => s,n(available),jabbersend(asterisk,${ARG2},"Call from ${CALLERID(name)} at number ${CALLERID(num)} on ${STRFTIME(,GMT-1,%A %B %d %G at %l:%M:%S %p)}")
exten => s,n,Goto(from-trunk,${ARG3},1)
exten => s,n(unavailable),VoiceMail(${ARG3},u)

Integrating Jabber into Asterisk with FreePBX

December 31st, 2009 | No Comments | Posted in Asterisk, FreePBX

I was poking around with Asterisk trying to hook it into an Openfire XMPP server and get Asterisk to send IMs when various events happen.

I have Asterisk set up as a Jabber client by setting the following in jabber.conf

[asterisk]
type=client
serverhost=jabber.server
username=asterisk@jabber.server/AsteriskServer
secret=password
port=5222
usetls=yes
usesasl=yes
statusmessage="Asterisk Test Server"

The more interesting part came when trying to get Asterisk to send messages to Jabber clients for incoming calls. I found a lot of information on the web on how to do it, but not where to put the config when you’re using FreePBX.  It turned out to be fairly simple in the end.

Editing the extensions_custom.conf put int he following code.

[from-internal-custom]
exten => 10,1,jabbersend(asterisk,user@jabber.server,"Call from ${CALLERID(name)} at number ${CALLERID(num)} on ${STRFTIME(,GMT-1,%A %B %d %G at %l:%M:%S %p)}")
exten => _X!,n,Goto(from-trunk,${EXTEN},1)

This sends an IM to user@jabber.server whenever they get an incoming call.

It could probably be improved to look up the appropriate user for the extension with a DB lookup (which means you’d only need one bit of code for all extensions) but I wouldn’t have a clue how to go about it.

The next step is to identify when an incoming call is for that extension in particular or if it’s a ring group.

MySQL ErrorNo 121

December 29th, 2009 | No Comments | Posted in MySQL, Web Development

MySQL has a helpful error “Can’t create table (errno: 121)” which doesn’t seem to be documented anywhere except in forums.

Turns out this error is caused by InnoDB tables throwing an error when it detects duplicate foreign key names.

Basically, every foreign key has to have a unique name for InnoDB to function correctly.

Badger Badger Badger

December 9th, 2009 | No Comments | Posted in Uncategorized

It’s A SNAAAAKKKKEEE!!!

Palm snake

A neighbour knocked on the door and told us that there was a snake on our roof. By the time we found it it had changed from a roof snake to a palm snake.

Palm Snake 2

Tree Snake 1

Tree Snake 2

Close up

Breakfast

Breakfast was tasty.

Longish, but not too long

Spot the Python

Spot the Python.

Digesting breakfast


Skin

This skin may be from the same python. But it looks too long for it to me. We have had bigger pythons in the back yard in the past.


Drawing Development

December 2nd, 2009 | No Comments | Posted in Uncategorized

I have no idea how kids are supposed to develop but in the past 6 months Liam has gone from potatoes with arms to full stick figures.

Liam the potatoe

12th Nov

Liam playing golf

30th Nov

Beer

December 2nd, 2009 | No Comments | Posted in Uncategorized

A client recently sent me some of my own branded beer.

The bottle

The label

Apparently I’m fantastic enough to get my  own beer.

Yum! Paint!

October 18th, 2009 | No Comments | Posted in Uncategorized

Emily and paint

Emily after a painting session.

Apparently she missed a spot

She missed a spot.