3 if [ -n "$VERBOSE" ]; then
8 if which "$1" >/dev/null 2>&1; then
15 # Configure the two things below for your MUA and the host being run.
16 IMAPHOST=$( awk -F= '/remotehost/{print $2}' ~/.offlineimaprc | head -n 1 )
17 MUAS="neomutt mutt mutt-ng"
19 # Don't check mail if ~/.nocheck exists and we're not running
21 if [ -z "$CRON" ] && [ -e ~/.nocheck ]; then
25 if [ -z "$HOSTNAME" ]; then
26 HOSTNAME="$(hostname)"
30 if cmd_exists "ionice"; then
34 # if we are running under cron and there is no running MUA, exit
35 if [ -n "$CRON" ]; then
38 if kill -0 `pgrep -U $(id -u) -x $MUA` 2>/dev/null; then
43 if [ "x$RUNNING_MUA" = "x0" ]; then
48 # source the ssh info if it exists
49 if [ -e ~/.ssh/"ssh_agent_info_$HOSTNAME" ]; then
50 . ~/.ssh/"ssh_agent_info_$HOSTNAME" > /dev/null;
53 PID="$(pgrep -U $(id -u) offlineimap)";
54 if [ -n "$PID" ]; then
55 # if offlineimap has been running for more than 20 minutes
56 if [ $(( $(date +'%s') - $(stat -c '%Y' /proc/$PID/cmdline) )) -gt 1200 ]; then
57 kill "$PID" >/dev/null 2>&1 || true;
59 kill -0 "$PID" >/dev/null 2>&1 && kill -9 "$PID" >/dev/null 2>&1;
60 PID="$(pgrep -U $(id -u) offlineimap)";
64 if [ -z "$PID" ]; then
65 nice -n 19 ${IONICE} offlineimap -o -u basic 2>&1 |grep validity| \
66 perl -ne 'my ($account,$list) = /UID validity problem for folder ([\w-]+)\.([\w-]+)/;
67 next unless defined $account and length $account;
68 qx(/home/don/bin/deletemailbox -a Inbox $account.$list > /dev/null);';
69 if cmd_exists "notmuch"; then
70 nice -n 19 ${IONICE} notmuch new >/dev/null 2>&1;