Aug
25
2009
60

How to Query a Database from MySQL with Asterisk 1.6 ODBC

I’ve been administering Asterisk servers for many years and everyday I’m learning something new.  As the size of the projects have gotten bigger, so have the demands of my customers.  One common request is database integration.  In the past I’ve used external AGI scripts to run database queries to return values to Asterisk.  But more recently I’ve been avoiding AGI in favor of direct access SQL.  This is achieved by building ODBC modules into Asterisk at build time.  Let me tell you, it’s worth it!

Asterisk & ODBC provide the ability to easily update and retrieve data by defining SQL statements as special variables that can be called from the dial plan.  For instance, we could bill ‘long distance’, take credit cards and let Asterisk access other types of information.  In my tutorial we will configure Asterisk to dial a variable that represents a SQL statement.  This could also be done by calling an AGI script, but why do the extra work?

This ‘How to’ is specifically geared towards MySQL.  However, if you set the up the ODBC driver correctly you can use any SQL server you like.  Which leads me to my next thought, before you start, make sure ODBC is set up correctly.  Follow one of my previous tutorials:

configure Linux ODBC for MS-SQL

configure Linux ODBC for MYSQL

Once you do this we are ready to continue…

The goals of this post:

– create MySQL table with example data
– configure res_odbc.conf
– configure func_odbc.conf
– configure extensions.conf for query

(more…)

Aug
24
2009
2

Get rid of that ‘default keyring’ password bullshit when you login to GNOME

I haven’t gone on a good ol’ fashioned rant in a long time.  And you know what?  This one has been in the making for a while.  I’m not holding back… here I go…

Policykit sucks!!!  What’s with this excessive password crap?  By default for GNOME in Fedora 10/11 you have to use a password for everything!  You need a password to login to GNOME, then once inside GNOME your password will be required to unlock network-manager.  That doesn’t seem so bad…  I’ve only entered the same password three times(including the Linux login).

So I have access to the web and I’m happy for the moment until I decide to attach my USB thumb drive to copy some files for my neighbor…  …and guess what?  I need a password to mount my USB thumb drive.  So I decide to watch a TV show I have on a DVD-R.   By default mounting a DVD requires my password.

Installing programs from the ‘Add/Remove Software’ requires your regular keyring password to launch the app and the root password to install the actual software.  Now am I wrong in concluding this is a totally retarded way to handle desktop security?  Typing in the same password eight times in thirty minutes?  This is why 7 year old Windows XP is still a contender.  Even though Open Source GNU Linux is technically superior and far more secure.

Seven times GNOME keyring asked for a password.  That’s as bad as Vista.  No, it’s even worse.  Nobody loves Vista.  In fairness however, Microsoft’s Vista doesn’t require a password to attach a common USB pen drive.  Even using an SSH connection from the console requires keyring to intervene with GNOME!

Luckily, you can install ‘pam_keyring’ with yum.  This will use your Linux login for the default keyring at login, but you have to access the keyring-manager to adjust the rest.  Huge hassle.  It’s annoying shit like this that keeps the average bear off Desktop Linux.  My Mom is a smart woman, but she would never figure this out, and so she will continue to run Windows XP indefintely.

Pick through the options and see if you can find where to grant access to mount a DVD. This is not security, it's insanity.

Aug
04
2009
0

BASH script to remove files by time

This script removes every *.wav file older then one minute in the directory it is executed.  This script is very useful and can be used with the cron daemon for regular file removal.

#!/bin/bash
#
find ./*.wav -type f -mmin +1 -exec rm {} \;

Also we can adjust this for days rather than minutes by changing ‘-mmin +1’ to ‘-mtime +10’.  This would delete .wav files in the working directory that were older than 10 days.

#!/bin/bash
#
find ./*.wav -type f -mtime +10 -exec rm {} \;

One more example,  the script below will erase all MP3 files older than 10 days form Matt’s music directory.  I hope this is of use to someone out there.

#!/bin/bash
#
find /home/matt/music/*.mp3 -type f -mtime +10 -exec rm {} \;

Written by mattb in: Linux,Scripts | Tags: , , , , , ,