rp

simple email tools
git clone https://git.parazyd.org/rp
Log | Files | Refs | README | LICENSE

commit 9bebefe3db43f8bf8e140581030e87339aad3371
parent f0b65604a58edec926e0bcfb268e6f6e4fc44218
Author: parazyd <parazyd@dyne.org>
Date:   Tue, 27 Feb 2018 23:26:42 +0100

Add common files and functions (rplib).

Diffstat:
Arplib/common.sh | 34++++++++++++++++++++++++++++++++++
Arplib/pass.sh | 25+++++++++++++++++++++++++
Arplib/tls.sh | 10++++++++++
3 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/rplib/common.sh b/rplib/common.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +# structure +reset="$(tput sgr0)" + +cyan="$(tput setaf 4)" +boldcyan="${green}$(tput bold)" + +green="$(tput setaf 2)" +boldgreen="${green}$(tput bold)" + +orange="$(tput setaf 3)" +boldorange="${orange}$(tput bold)" + +red="$(tput setaf 1)" +boldred="${red}$(tput bold)" +alertformat="${red}$(tput bold; tput blink)" + +ebegin() { + printf "${boldgreen} * ${reset}%s ...\n" "$*" >&2 +} + +einfo() { + printf "${boldgreen} * ${reset}%s\n" "$*" >&2 +} + +ewarn() { + printf "${boldorange} * ${reset}%s\n" "$*" >&2 +} + +edie() { + printf "${boldred} * ${reset}%s\n" "$*" >&2 + exit 1 +} diff --git a/rplib/pass.sh b/rplib/pass.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +. "$HOME"/.rp/rplib/common.sh + + +askpass() { + [ "$1" = -v ] && { + print=true + shift 1 + } + what="$1" + where="$2" + + mkdir -p "$(dirname $2)" + pass show "$1" >> "$2" || edie "'pass show' failed" + chmod 600 "$2" + + [ "$print" = true ] && printf "$2" || true +} + +askmuttpass() { + password="$(pass show "$1")" + [ -n "$password" ] || edie "'pass show' failed" + echo "set imap_pass = $password" > $profile/mutt/muttpass +} diff --git a/rplib/tls.sh b/rplib/tls.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +getfingerprint() { + host="$1" + port="$2" + + echo QUIT | openssl s_client -starttls smtp -connect $host:$port \ + -showcerts 2>/dev/null | \ + openssl x509 -fingerprint -sha1 -noout | cut -d'=' -f2 +}