#!/bin/bash # # firma v0.1: simple encrypted mailing list aliases # feedback: rhatto@riseup.net | GPL # # list configuration is passed thru the a config file, # where you put PARAMETER=value (whithout spaces) # # MAIL= path for mail program # GPG= path for gnupg binary # TMP= where you want the temp files # LISTNAME= list email # GPGDIR= gpg dir for the lists' keyring # PASSWD= passwd for the lists' keyring # eval the config file source $1 GPGCOMMAND="$GPG -q --homedir $GPGDIR" GPGLIST="$GPGCOMMAND --list-keys" GPGDECRYPT="$GPGCOMMAND --decrypt" GPGENCRYPT="$GPGCOMMAND --always-trust -e -s -a -r" rm $TMP $TMP.gpg touch $TMP; chmod 600 $TMP; touch $TMP.gpg; chmod 600 $TMP.gpg; # todo: use an array while read STDIN; do echo $STDIN >> $TMP done # get the headers FROM=$(grep -m 1 ^From: $TMP | cut -f 2 -d :) DATE=$(grep -m 1 ^Date: $TMP) SUBJECT=$(grep -m 1 ^Subject: $TMP) # detect the encrypted message sed -n '/-----BEGIN PGP MESSAGE-----/,/-----END PGP MESSAGE-----/p' $TMP >> $TMP.gpg # encrypting and sending for each recipient on the list for EMAIL in $($GPGLIST | grep pub | cut -d "<" -f 2 | sed -e 's/>//' | grep @ | grep -v $LISTNAME); do echo "$PASSWD Message from: $FROM $SUBJECT $DATE $(echo "$PASSWD" | $GPGDECRYPT $TMP.gpg)" | sed -e 's/=20$//' | $GPGENCRYPT $EMAIL | $MAIL -r $LISTNAME $EMAIL done rm $TMP $TMP.gpg