config

OpenBSD system configuration
git clone git://jacobedwards.org/config
Log | Files | Refs | README

commit f551238d5e110064459a9a43247ac1f7f17f6bd2
parent 25503c85158d3edf61a96eca7e03de0866155ad3
Author: Jacob R. Edwards <n/a>
Date:   Tue,  1 Mar 2022 19:39:26 -0800

Add ssh mail syncing scripts

Diffstat:
Alocal/bin/bin/incmail | 25+++++++++++++++++++++++++
Alocal/bin/bin/sendmaildir | 21+++++++++++++++++++++
Mlocal/ssh/.ssh/config | 5+++++
3 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/local/bin/bin/incmail b/local/bin/bin/incmail @@ -0,0 +1,25 @@ +#!/bin/sh +# Copyright 2022 Jacob R. Edwards +# Like pop3, but using sshd +# +# There are a few reasons I'm using this instead of pop3: +# +# - I couldn't find a good pop3 client (though popa3d looks like a +# good server, since I'd tunnel through ssh anyway) +# - No extra network daemons running (assuming sshd is already) +# - Uses a general purpose tool +# +# This requires rsync(1), here is the reasoning: +# +# sftp(1) could be used, but it can't be sufficiently restricted +# for passwordless authentication. openrsync(1) would be great, but +# it can't delete source files; rsync(1) it is. + +# Pick through ssh output and find the remote command run, then add +# it to your authorized_keys like so: +# restrict,command="rsync ... " ssh-rsa ... +#rsync() command rsync -e 'ssh -v' "$@" + +rsync -az --remove-source-files "${1:-mail}":Maildir "$HOME" +# Comment if you use maildir +sendmaildir diff --git a/local/bin/bin/sendmaildir b/local/bin/bin/sendmaildir @@ -0,0 +1,21 @@ +#!/bin/sh +# Copyright 2022 Jacob R. Edwards +# Send mail from Maildir to mbox +# (specifically for OpenBSD) + +! test -d "$HOME"/Maildir && + exit 0 + +IFS=' +' +for mail in $(find "$HOME"/Maildir -type f) +do + if /usr/libexec/mail.local "$USER" < "$mail" + then + rm -f "$mail" + else + echo "$mail: Unable to move to mbox" 1>&2 + fi +done + +find "$HOME"/Maildir -type d -empty -delete diff --git a/local/ssh/.ssh/config b/local/ssh/.ssh/config @@ -18,6 +18,11 @@ Hostname jacobedwards.org # 46.23.91.219 IdentityFile /home/jacob/.ssh/rsa-ids/ams/jacob User jacob +Host mail +Hostname jacobedwards.org +IdentityFile /home/jacob/.ssh/rsa-ids/ams/mail +User jacob + Host amshost Hostname server14.openbsd.amsterdam IdentityFile /home/jacob/.ssh/rsa-ids/ams/jacob