Saturday, June 11, 2011

Time machine and crontab

Time machine backups of OS X is nice, especially since you can restore your full system from them. What is not so nice is that they run all the time, and they transfer a huge amount of files, so you don't want it to run very often.

Recognize the problem? Add it to crontab instead! Just edit your crontab (crontab -e) and add something like this:

25 3-7 * * * /System/Library/CoreServices/backupd.bundle/Contents/Resources/backupd-helper &

This means that backupd-helper will run between 25 minutes past 03 to 07 (3-7 AM) everyday. backupd-helper is the same thing that is run if you would press "backup now" in the Time Machine preferences.

Oh, in time machine prefs, set it to NOT run (since the point is to run it by crontab). And no, backups will not be taken if you computer is asleep (since cron would be asleep as well..)

Thursday, April 28, 2011

Use a specific proxy connection with Chrome Web Browser in OSX

I travel a little bit now and then so I use a few different wireless or fixed networks that I'm a guest at. I tend to use Firefox a lot, and in FF i have set FF to always browse via my proxy server at home (tinyproxy). The handy thing with FF is that the proxy setting is only for FF, and that is a feature I've been missing in Chrome which I tend to use more often these days.

In OSX, there is a setting to use a proxy in System Preferences, but then that setting will be applied to all programs (except FF in my case), which is not what I want. So today I googled if there were any new addons for Chrome that could do that, and lo and behold, here is the solution (but not from a addon...)

Type the following in a (or iTerm2, which is awesome)

open -a /Applications/Google\ --args --proxy-server=proxy.home.over.vpn:8888
I saved that string as an alias in .bashrc for reuse.

Taken from

Wednesday, March 16, 2011

Exim4, dovecot with sqlite authentication

As I am moving away from courier to dovecot I also wanted to move away from the old courierauth DB and use something newer and slicker: sqlite3. Having all my SMTP and IMAP users in sqlite3 is nice, since you don't need them to have a actual system user.

Creating the sqlite3 db is easy, just "sqlite3 /etc/dovecot/authdb.sqlite". I used the SQL query from the dovecot page:

userid VARCHAR(128) NOT NULL,
domain VARCHAR(128) NOT NULL,
password VARCHAR(64) NOT NULL,

The next step was to edit the /etc/dovecot/dovecot.conf and /etc/dovecot/dovecot-sql.conf. I just created the entries in the sqlite db manually (my courierdb is small)

insert into users values ('jolt', '','oldcryptedpw', '/home/courier/jolt','104','105');

where all of the values are directly from the /etc/courier/userdb.

Now the fun part: get exim4 to play well with sqlite. ( I leave out the Exim dovecot config, since I used the exact same one from courier (i.e. it's the same path. Read the Dovecot-courier migration document for config details).

In exim I commented out my existing login: and plain: sections and replaced it with this:

driver = plaintext
public_name = PLAIN
server_prompts = :

server_condition = "${if and { \
{!eq{$2}{}} \
{!eq{$3}{}} \
{crypteq{$3}{${lookup sqlite{/etc/dovecot/authdb.sqlite SELECT password FROM users WHERE ( domain = \
'${domain:$2}' \
AND userid = '${local_part:$2}') OR userid='$2' }{$value}fail}} }} {yes}{no}}"
server_set_id = $2

driver = plaintext
public_name = LOGIN
server_prompts = "Username:: : Password::"
server_condition = "${if and { \
{!eq{$1}{}} \
{!eq{$2}{}} \
{crypteq{$3}{${lookup sqlite{/etc/dovecot/authdb.sqlite SELECT password FROM users WHERE ( domain = \
'${domain:$2}' \
AND userid = '${local_part:$2}') OR userid='$2' }{$value}fail}} }} {yes}{no}}"
server_set_id = $1

The above lines are just a modified version of the MySQL authentication example at the Exim wiki.

Now I tried exim4 and and after changing the select clause a bit it actually worked!

Now back to dovecot. Dovecot needs to be configured (in /etc/dovecot/dovecot.conf) to use both passdb sql and fetch userdb info at the same time (enable userdb prefetch). I missed that myself, of course, so be warned:

# SQL database
passdb sql {
# Path for SQL configuration file
args = /etc/dovecot/dovecot-sql.conf

userdb prefetch {

And dont forget to disable PAM (just comment it out, don't forget the }).

Then I needed to change the default crypt method to CRYPT (thats what my courierdb used, remember?). Here is the /etc/dovecot/dovecot-sql.conf config file for your reading pleasure:

# Database driver: mysql, pgsql, sqlite
driver = sqlite
connect = /etc/dovecot/authdb.sqlite

# Default password scheme.
# List of supported schemes is in
#default_pass_scheme = PLAIN-MD5
default_pass_scheme = CRYPT

# and enable the last line for user and pw prefetch:
password_query = SELECT userid as user, password, home as userdb_home, uid as userdb_uid, gid as userdb_gid FROM users WHERE userid = '%u'

I think that's pretty much it, so good luck!