From 6f325dc8d47ab88a4ef0dccc3fbaf295ba47e2d8 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Mon, 25 May 2020 12:02:05 +0100 Subject: [PATCH] Adds check-emails script --- bin/.bin/emails/check-emails | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 bin/.bin/emails/check-emails diff --git a/bin/.bin/emails/check-emails b/bin/.bin/emails/check-emails new file mode 100755 index 00000000..99d52a8f --- /dev/null +++ b/bin/.bin/emails/check-emails @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# This shell script checks my emails +# It first checks that I am connected to the internet by attempting to ping cloudflaire's dns server +# Then checks that davmail is running +# Then syncs emails +# Then updates notmuch + +die(){ + echo "$1" + exit 1 +} + +# Ping 1.1.1.1 to confirm that we are on the internet +ping -c 1 "1.1.1.1" > /dev/null 2> /dev/null || die "Need to be connected to the internet" + +# Check that davmail is running +ps -aux | grep -v grep | grep -q davmail || die "Need to start davmail" + +# Sync maildir with exchange +mbsync -c "$HOME/.config/isync/mbsyncrc.secret" work + +# Update notmuch database +notmuch new