#!/bin/sh
# vim:se tw=78 sts=4:
# Copyright (C) Osamu Aoki <osamu@debian.org>, GPL2+
set -e
UID_BY_ID=$(id -u)
PID_GETMAILS=$(pgrep -U $UID_BY_ID '^getmails$')
if [ "x$PID_GETMAILS" != "x$$" ]; then
	echo "The getmails script is already running as PID=\"$PID_GETMAILS\" ." >&2
	exit 1
fi
if [ -f $HOME/.getmail/stop ]; then
	echo "Do not run getmail ... (if not, remove $HOME/.getmail/stop)" >&2
	exit 1
fi
rcfiles="/usr/bin/getmail"
for file in $HOME/.getmail/config/* ; do
	rcfiles="$rcfiles --rcfile \"$file\""
done
eval "$rcfiles $@"

