This is a script to extract data from vCard files and insert it into Asterisk in a format that Asterisk can use to re-write Caller-ID information for incoming calls. It should work with vCards from any source, but it’s tested with vCards from ab2vcard, a tool I wrote for extracting vCards from OS X’s Address Book via cron.
This tool is written in Ruby. It’s been tested with both Ruby 1.6.8 and Ruby 1.8.1.
Just copy the ‘vcardcid.rb’ file to somewhere in your path.
By default, vcardcid will look for .vcf files in the current directory and print caller ID database lines to standard out. The current version of vcardcid only works when there is only one vCard per .vcf file; its behavior with multiple-card files is untested.
vcardcid takes 5 options:
To extract all vCards from the ‘Home CallerID’ group and automatically insert them into Asterisk, using the Subversion tree in ~/svn/addresses, do this:
# vcardcid --directory=~/svn/addresses --group='Home CallerID' \
--subversion --asterisk
To extract vCards and insert them into the ‘blacklist’ database for use with the LookupBlacklist application:
# vcardcid --directory=~/svn/addresses --group='Home Blacklist' \
--subversion --database=blacklist --asterisk
To print all numbers from all cards in the current directory:
# vcardcid
Things to do:
The author’s Subversion tree for this project is available at http://svn.scottstuff.net/public/asterisk-vcard-cid/trunk. Tarballs for specific releases can be found at http://svn.scottstuff.net/public/asterisk-vcard-cid/download/.
Here’s what’s happened over time: