Filter mail with imapfilter

As I’m reading my mails from different devices, I often wondered if there is a better way to filter mails than copying filter settings around and try keeping them consistent.
After a brief search I ended up with mailfilter which runs as a cron job on a server and connects my mail account where it sorts the mails.

The setup is easy and straight forward:

Install imapfilter:
aptitude install imapfilter

edit the config file user.This must be located in the homedirectory of the user who runs the cronjob
vi ~/.imapfilter/config.lua

and configure your mail account

options.timeout = 120
options.subscribe = true

account1 = IMAP {
server = 'mail.example.com',
username = 'your-mail@example.com',
password = 'super_secret_password',
ssl = 'ssl3'
}

Now it is time to configure our first rule

msgs = account1.INBOX:contain_from('mailings@gmxnet.de')
account1.INBOX:move_messages(account1['GMX'], msgs)

This example checks for newsletters of a forwarding GMX account and move them to the folder ‘GMX’.

As the configuration file contains our clear-text credentials we are good restricting the file access.
chmod 600 ~/.imapfilter/config.lua

As last step we create a cronjob running every 5 minutes. It’s a good idea to keep the interval short to prevent unnecessary mail notifications.

crontab -e

*/5 * * * * /usr/bin/imapfilter > /dev/null

After setting up all my filters I finally can remove them from my clients.

Verfication of SSH public keys

This post is mainly a reminder to myself. The administration of a Gitolite requires me to regularly handle SSH keys provided by others. These keys tend to get mutilated by copy-pasted actions and such. To make sure the key is valid, its integrity can be easily checked with ssh-keygen -l $KEY_FILE. For a valid key, the fingerprint of the key is displayed. An error message indicates that the key got mutilated.

Sync Firefox OS calendar with egroupware

In Order to sync your Firefox OS mobile with egroupware you need to add a new calendar and choose CalDav.
Enter your password and username.
As Server we use:
https://YOUR-EGROUPWARE-INSATLLATION/webdav.php/principals/users/USERAME/calendar

When using SSL (which is a pretty good idea) you need a valid certificate (Not self signed)
As far as I use CAcert, which is not an acceptable authority for Mozilla, I had to add it to FFOS according to this post: http://www.pending.io/add-cacert-root-certificate-to-firefox-os/

Asterisk Realtime with Postgres and Asterisk 11

Install Postgres:

aptitude intsall postgresql

For compiling asterisk with Postgres support we’ll need some headers:

aptitude install postgresql-server-dev-9.1

Now it’s time to allow users access to postgres:

Edit pg_hba.conf
vi /etc/postgresql/9.1/main/pg_hba.conf

And change/add the following lines

# Database administrative login by Unix domain socket
local all postgres md5
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5

switch to user postgres and start psql cli
su postgres #must be done as user postgres
psql
CREATE USER asterisk WITH ENCRYPTED PASSWORD 'secretpw';

After setting up postgres an creating a user for asterisk it’s time for creating our new realtime db.
The sheme can be found (and modified) under
your-asterisk-sources/contrib/realtime/postgrsql

So we create an Database

CREATE DATABASE ast_rt

And fill it with our tables structure
psql -Uadmin -W -d ast_rt -f your-asterisk-sources/contrib/realtime/postgresql/realtime.sql

Asterisk 11 on Debian

In order to use a current Asterisk version on Debian Systems which have very long release cycle we need to get the sources and compile it for ourselves.

Therefor we need to prepare our system and install some dependencies. The following example is for a basic Asterisk-system with MySQL support. Maybe you need to adept this in line to match your needs.

$aptitude update
$ aptitude install  build-essential linux-headers  libncurses5-dev libxml2-dev libssl-dev mysql-server mysql-client libmysql++-dev  libsqlite3-dev uuid uuid-dev

Now it’s time to get the sources.
$ cd /usr/local/src
$ svn co http://svn.asterisk.org/asterisk/branches/11

If you want to have support for mp3-media format, you have to call a script and get the files which aren’t shipped with asterisk due to some strange licensing issues

$ cd 11
$ contrib/scripts/get_mp3_source.sh

Next we are ready to compile asterisk and install it into /usr/local.

./configure --prefix=/usr/local
make menuselect
make
make install

No grab some coffee and watch your asterisk compiling.

The last thing we need are some config files and an init script:

$ make config
$make samples

Now you can adapt the sample config files according to your needs.