summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-27 19:06:29 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-27 19:06:29 -0500
commit6ad5f1cfda26c41fb1b7d06030c1918c06a3aad2 (patch)
tree98297a53d3e8642dcc001c073f5b1d73590c58f0 /bin
parent579e180c033d102859fdb74495170a743cecc3a0 (diff)
downloadconf-6ad5f1cfda26c41fb1b7d06030c1918c06a3aad2.tar.gz
conf-6ad5f1cfda26c41fb1b7d06030c1918c06a3aad2.zip
switch from offlineimap to mbsync
Diffstat (limited to 'bin')
-rwxr-xr-xbin/hornet/update-mail11
-rwxr-xr-xbin/mbsyncloop42
2 files changed, 42 insertions, 11 deletions
diff --git a/bin/hornet/update-mail b/bin/hornet/update-mail
deleted file mode 100755
index 8149a8d..0000000
--- a/bin/hornet/update-mail
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-set -eu
-set -o pipefail
-
-stat=$(svstat "$HOME/.services/enabled/offlineimap")
-if echo "$stat" | grep -q "offlineimap: down"; then
- echo "no offlineimap process running" >&2
- exit 1
-fi
-pid=$(echo "$stat" | sed 's/.*offlineimap: up (pid \([[:digit:]]\+\)).*/\1/')
-kill -USR1 "$pid"
diff --git a/bin/mbsyncloop b/bin/mbsyncloop
new file mode 100755
index 0000000..3136c51
--- /dev/null
+++ b/bin/mbsyncloop
@@ -0,0 +1,42 @@
+#!/usr/bin/env perl
+use 5.016;
+use strict;
+use warnings;
+
+use POSIX 'mkfifo';
+
+my ($pw_pipe, $pid);
+
+sub cleanup {
+ unlink($pw_pipe) if $pw_pipe;
+ kill KILL => $pid if $pid;
+}
+
+$SIG{INT} = $SIG{TERM} = sub { cleanup; exit };
+END { cleanup }
+
+$pw_pipe = "/run/user/$>/mbsyncloop";
+mkfifo($pw_pipe, 0700) or die "couldn't create $pw_pipe";
+
+my $pw = `rbw get mail.tozt.net doy\@tozt.net`;
+
+$pid = fork;
+die unless defined $pid;
+if (!$pid) {
+ $SIG{PIPE} = sub {};
+ while (1) {
+ open my $fh, '>', $pw_pipe or die "couldn't open $pw_pipe";
+ $fh->print("$pw\n");
+ close $fh;
+ }
+ exit;
+}
+
+my $i = 0;
+while (1) {
+ my $channel = $i % 15 ? "priority" : "all";
+ system("mbsync -c ~/.mbsyncloop $channel") and last;
+ system("notmuch new") and last;
+ sleep 60;
+ $i++;
+}