3 if [ -n "$VERBOSE" ]; then
7 # Configure the two things below for your MUA and the host being run.
8 IMAPHOST=$( awk -F= '/remotehost/{print $2}' ~/.offlineimaprc | head -n 1 )
11 # Don't check mail if ~/.nocheck exists and we're not running
13 if [ -z "$CRON" ] && [ -e ~/.nocheck ]; then
17 if [ -z "$HOSTNAME" ]; then
18 HOSTNAME="$(hostname)"
22 if which ionice >/dev/null 2>&1; then
26 # if we are running under cron
27 if [ -n "$CRON" ]; then
28 # and there is no MUA open, exit
29 if ! kill -0 `pgrep -U $(id -u) -x $MUA` 2>/dev/null; then
32 # if there is not a working ssh master, exit.
33 if ! ssh -O check $IMAPHOST 2>&1|grep -q running; then
38 # source the ssh info if it exists
39 if [ -e ~/.ssh/"ssh_agent_info_$HOSTNAME" ]; then
40 . ~/.ssh/"ssh_agent_info_$HOSTNAME" > /dev/null;
43 PID="$(pgrep -U $(id -u) offlineimap)";
44 if [ -n "$PID" ]; then
45 # if offlineimap has been running for more than 20 minutes
46 if [ $(( $(date +'%s') - $(stat -c '%Y' /proc/$PID/cmdline) )) -gt 1200 ]; then
47 kill "$PID" >/dev/null 2>&1 || true;
49 kill -0 "$PID" >/dev/null 2>&1 && kill -9 "$PID" >/dev/null 2>&1;
50 PID="$(pgrep -U $(id -u) offlineimap)";
54 if [ -z "$PID" ]; then
55 nice -n 19 ${IONICE} offlineimap -o -u basic 2>&1 |grep validity| \
56 perl -ne 'my ($account,$list) = /UID validity problem for folder ([\w-]+)\.([\w-]+)/;
57 next unless defined $account and length $account;
58 qx(/home/don/bin/deletemailbox -a Inbox $account.$list > /dev/null);';
59 if which notmuch >/dev/null 2>&1; then
60 nice -n 19 ${IONICE} notmuch new >/dev/null 2>&1;