jaromail

a commandline tool to easily and privately handle your e-mail
git clone git://parazyd.org/jaromail.git
Log | Files | Refs | Submodules | README

commit ab9a28381bb480fed01122726d0831ca0460fce4
parent 7e15896feffffb135c7e7b32103d362b245d5ef3
Author: Jaromil <jaromil@dyne.org>
Date:   Wed, 21 Mar 2012 19:37:20 +0100

enabled little brother database installation and query

Diffstat:
Mbuild-osx.sh | 2+-
Minstall.sh | 133++++++++++++++++++++++++++++++++++++++++---------------------------------------
Mshare/lbdb/lbdb.rc.in | 2+-
Mshare/lbdb/m_osx_addressbook.sh.in | 2+-
Mshare/mutt/formats | 4+++-
Mshare/mutt/general | 2++
Msrc/postino | 35++++++++++++++++++++---------------
7 files changed, 96 insertions(+), 84 deletions(-)

diff --git a/build-osx.sh b/build-osx.sh @@ -74,7 +74,7 @@ act "lbdb address book module" cd aux/lbdb-ABQuery xcodebuild > /dev/null cd - -cp aux/lbdb-ABQuery/build/Release/lbdb-ABQuery build/osx +cp aux/lbdb-ABQuery/build/Release/lbdb-ABQuery build/osx/ABQuery copydeps bin/mutt copydeps bin/msmtp diff --git a/install.sh b/install.sh @@ -9,14 +9,14 @@ fi WORKDIR=$HOME/.postino -MAILDIR=$HOME/Mail +MAILDIRS=$HOME/Mail umask 007 # James Bond ;^) if [ $1 ]; then WORKDIR=$1; fi # make sure the directory is private mkdir -p $WORKDIR -mkdir -p $MAILDIR +mkdir -p $MAILDIRS source src/postino @@ -35,20 +35,24 @@ cp src/postino ${WORKDIR}/bin # make sure we have a temp and cache dir mkdir -p $WORKDIR/tmp $WORKDIR/cache -if ! [ -r $MAILDIR/Configuration.txt ]; then - cat <<EOF > $MAILDIR/Configuration.txt +if ! [ -r $MAILDIRS/Configuration.txt ]; then + cat <<EOF > $MAILDIRS/Configuration.txt +# Name appearing in From: field +FULLNAME="Anonymous" + # MAIL USER (the left and right parts of an email) -NAME=user +USER=username # @ DOMAIN=gmail.com # IMAP (RECEIVE) IMAP_ADDRESS=imap.gmail.com -IMAP_LOGIN=\${NAME}@\${DOMAIN} +IMAP_LOGIN=\${USER}@\${DOMAIN} # SMTP (SEND) SMTP_ADDRESS=smtp.gmail.com -SMTP_LOGIN=\${NAME}@\${DOMAIN} +SMTP_LOGIN=\${USER}@\${DOMAIN} +SMTP_PORT=465 # SMTP_CERTIFICATE=gmail.pem # LOCAL FILES @@ -57,7 +61,7 @@ SMTP_LOGIN=\${NAME}@\${DOMAIN} # the defaults below should be ok, they place # mutt, procmail, mstmp and other confs in ~/.postino -MAILDIRS=$HOME/Mail +MAILDIRS=$MAILDIRS MUTTDIR=$WORKDIR/.mutt PROCMAILDIR=$WORKDIR/.procmail CERTIFICATES=$HOME/.ssl/certs @@ -67,14 +71,14 @@ CERTIFICATES=$HOME/.ssl/certs EOF act "Default configuration created" else - error "Existing $MAILDIR/Configuration.txt skipped" + error "Existing $MAILDIRS/Configuration.txt skipped" fi # source the default configuration -source $MAILDIR/Configuration.txt +source $MAILDIRS/Configuration.txt -if ! [ -r $MAILDIR/Filters.txt ]; then - cat <<EOF > $MAILDIR/Filters.txt +if ! [ -r $MAILDIRS/Filters.txt ]; then + cat <<EOF > $MAILDIRS/Filters.txt # Example filter configuration for Postino # accepted email addresses @@ -108,59 +112,10 @@ from academia.edu save web.academia EOF act "Default filters created" else - error "Existing configuration $MAILDIR/Filters.txt skipped" + error "Existing configuration $MAILDIRS/Filters.txt skipped" fi -source $MAILDIR/Configuration.txt - -# make sure maildirs where to put mails exist -mkdir -p $MAILDIRS -maildirmake $MAILDIRS/known -maildirmake $MAILDIRS/sent -maildirmake $MAILDIRS/priv -maildirmake $MAILDIRS/postponed -maildirmake $MAILDIRS/unsorted - -if ! [ -r $MUTTDIR ]; then - mkdir -p $MUTTDIR - cat<<EOF > $MUTTDIR/rc -# mutt config generated by postino -# don't edit, change Mail/Configuration.txt instead -unset use_domain -set hostname = $DOMAIN -set realname = $NAME -set folder = $MAILDIRS -set spoolfile = $MAILDIRS/known/ -set record = $MAILDIRS/sent/ -set postponed= $MAILDIRS/postponed/ -set tmpdir = $WORKDIR/tmp -set query_command = "postino query '%s'" -set sendmail = "postino queue" -set header_cache= $MUTTDIR/cache -set maildir_header_cache_verify=no -set editor = "$EDITOR" -set mailcap_path = "$WORKDIR/mailcap" - -# mailboxes in order of priority -source $MUTTDIR/mboxes -# user tweaked configuration -source $MUTTDIR/general -## end of generated muttrc -########################## - -EOF - cp -f share/mutt/* $MUTTDIR/ - touch $MUTTDIR/mboxes - touch $MUTTDIR/pass - ln -sf $MUTTDIR/rc $HOME/.muttrc - if [ $? != 0 ]; then - error "Error setting Postino to handle Mutt's default configuration" - error "Set symlink manually: $HOME/.muttrc -> $MUTTDIR/rc" - fi - act "Default mutt configuration created" -else - error "Existing configuration for Mutt skipped" -fi +source $MAILDIRS/Configuration.txt # procmail is entirely generated # so overwriting it won't hurt @@ -168,6 +123,54 @@ act "Installing procmail scripts" mkdir -p $PROCMAILDIR cp -a share/procmail/* $PROCMAILDIR +# also mutt is safe to override +mkdir -p $MUTTDIR +cp -a share/mutt/* $MUTTDIR + +act "Installing little brother database" +# safe to override +mkdir -p $WORKDIR/.lbdb +for aw in munge.awk.in munge-keeporder.awk.in tac.awk.in; do + dst=`echo $aw | sed -e 's/.awk.in$//'` + cat share/lbdb/$aw \ + | sed -e "s&@AWK@&/usr/bin/env awk&g" \ + > $WORKDIR/.lbdb/$dst +done +for sh in lbdb-fetchaddr.sh.in lbdb-munge.sh.in lbdb_lib.sh.in lbdbq.sh.in; do + dst=`echo $sh | sed -e 's/.sh.in$//'` + cat share/lbdb/$sh \ + | sed -e "s&@SH@&/usr/bin/env zsh&g" \ + | sed -e "s&@LBDB_VERSION@&0.38-postino&g" \ + | sed -e "s&@prefix@&${WORKDIR}/.lbdb&g" \ + | sed -e "s&@exec_prefix@&${WORKDIR}/.lbdb&g" \ + | sed -e "s&@libdir@&${WORKDIR}/.lbdb&g" \ + | sed -e "s&@sysconfdir@&${WORKDIR}/.lbdb&g" \ + | sed -e "s&@MODULES@&${WORKDIR}/.lbdb&g" \ + | sed -e "s&@TAC@&${WORKDIR}/.lbdb/tac.awk&g" \ + > $WORKDIR/.lbdb/${dst} +done +lbdb_modules=(m_finger m_gpg m_inmail m_muttalias m_osx_addressbook m_vcf) +for mod in ${lbdb_modules}; do + cat share/lbdb/${mod}.sh.in \ + | sed -e "s&@SH@&/usr/bin/env zsh&g" \ + | sed -e "s&@LBDB_VERSION@&0.38-postino&g" \ + | sed -e "s&@prefix@&${WORKDIR}/.lbdb&g" \ + | sed -e "s&@exec_prefix@&${WORKDIR}/.lbdb&g" \ + | sed -e "s&@libdir@&${WORKDIR}/.lbdb&g" \ + > $WORKDIR/.lbdb/${mod} +done +chmod +x $WORKDIR/.lbdb/* +ln -sf $WORKDIR/.lbdb/lbdb-fetchaddr $WORKDIR/bin/ +ln -sf $WORKDIR/.lbdb/lbdbq $WORKDIR/bin/ +cp share/lbdb/lbdb.rc.in ${WORKDIR}/.lbdb/lbdb.rc +ln -sf $WORKDIR/.lbdb $HOME/ +#### + + +# generate initial configuration +src/postino update + + case `uname -s` in Darwin) if [ -r build/osx ]; then @@ -189,7 +192,7 @@ EOF esac notice "Installation completed, now edit your personal settings:" -act "$MAILDIR/Configuration.txt" +act "$MAILDIRS/Configuration.txt" if [ `uname -s` = Darwin ]; then - open /Applications/TextEdit.app $MAILDIR/Configuration.txt + open /Applications/TextEdit.app $MAILDIRS/Configuration.txt fi diff --git a/share/lbdb/lbdb.rc.in b/share/lbdb/lbdb.rc.in @@ -40,7 +40,7 @@ # - m_evolution search in the Ximan Evolution addressbook. # - m_vcf search a vcard (according to RFC2426) file. -METHODS="m_inmail m_passwd m_finger" +METHODS=(m_inmail m_finger m_gpg m_osx_addressbook m_vcf) # diff --git a/share/lbdb/m_osx_addressbook.sh.in b/share/lbdb/m_osx_addressbook.sh.in @@ -24,5 +24,5 @@ libdir=@libdir@ m_osx_addressbook_query() { - $libdir/ABQuery "$@" | grep -ia "$@" || : + ABQuery "$@" | grep -ia "$@" || : } diff --git a/share/mutt/formats b/share/mutt/formats @@ -19,7 +19,9 @@ set pager_format="%Z %C/%m %d (%F) %s (%c/%l) %|-" set pgp_entry_format="%3n %t%f %4l/0x%k %-4a %2c %u %[%a %e.%h'%y at %k:%M:%S %Z]" -set status_format="_%r_ %h: %f, %l/%m (%P,%s) [ %?p?PP:%p ?%?t?Tag:%t ?%?d?DEL:%d ?]%?V?, %L/%M only=%V? < %?F?go:%F ?%?n?new:%n ?> %v" +set attribution='On %{%a, %d %b %Y}, %n wrote:\n' + +set status_format="-%r-Mutt: %f [Msgs:%?M?%M/?%m%?n? New:%n?%?o? Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b? %?l? %l?]---(%s/%S)-default-%>-(%P)---" set forward_format = "[Fwd] %s" diff --git a/share/mutt/general b/share/mutt/general @@ -92,6 +92,8 @@ set honor_followup_to = yes set abort_nosubject = no set abort_unmodified = no set copy = yes +# folder to copy sent messages +fcc-hook . "=sent" ################## ## Forward options diff --git a/src/postino b/src/postino @@ -33,16 +33,6 @@ QUIET=0 DEBUG=1 umask 007 # James Bond :^) - -source $HOME/Mail/Configuration.txt - -# default working dir -if [ -z $POSTINO_DIR ]; then - WORKDIR=$HOME/.postino -else - WORKDIR=$POSTINO_DIR -fi - ########################## @@ -67,6 +57,18 @@ act() { fi } +if ! [ -r $HOME/Mail/Configuration.txt ]; then return; fi + +source $HOME/Mail/Configuration.txt + +# default working dir +if [ -z $POSTINO_DIR ]; then + WORKDIR=$HOME/.postino +else + WORKDIR=$POSTINO_DIR +fi + + # make sure the directory is private chmod 700 $WORKDIR if [ $? != 0 ]; then @@ -248,7 +250,7 @@ send() { ask_password ${slogin} ${shost} cat <<EOF > $WORKDIR/tmp/send account default -from ${NAME}@${DOMAIN} +from ${USER}@${DOMAIN} tls on host ${SMTP_ADDRESS} port ${SMTP_PORT} @@ -295,7 +297,7 @@ peek() { mutt -f imaps://`echo $ilogin | sed 's/@/\\@/'`@${ihost} } -sync() { +update() { notice "Updating all configurations and filters" # this function should: # parse all filters @@ -327,7 +329,8 @@ sync() { # mutt config generated by postino unset use_domain set hostname = $DOMAIN -set realname = $NAME +set realname = $FULLNAME +set from = "$FULLNAME <${USER}@${DOMAIN}>" set folder = $MAILDIRS set spoolfile = $MAILDIRS/known/ set record = $MAILDIRS/sent/ @@ -371,6 +374,7 @@ LOGFILE=$PROCMAILDIR/log SHELL = /bin/sh # VERY IMPORTANT UMASK = 007 # James Bond :-) LINEBUF = 8192 # avoid procmail choke +src/postino update # Using Procmail Module Library http://sf.net/projects/pm-lib PMSRC = $PROCMAILDIR # Load the central initial startup code. @@ -384,7 +388,7 @@ PF_RECURSE = yes { # filters generated from postino Filters.txt EOF - for f in `cat $MAILDIR/Filters.txt | awk '/^#/ {next} /^./ { print $1 ";" $2 ";" $3 ";" $4 }'`; do + for f in `cat $MAILDIRS/Filters.txt | awk '/^#/ {next} /^./ { print $1 ";" $2 ";" $3 ";" $4 }'`; do header="${f[(ws:;:)1]}" address="${f[(ws:;:)2]}" action="${f[(ws:;:)3]}" @@ -461,7 +465,7 @@ main() subcommands_opts[send]="" subcommands_opts[peek]="" subcommands_opts[update]="" - subcommands_opts[list]="" + subcommands_opts[query]="" subcommands_opts[source]="" # subcommands_opts[mount]=${subcommands_opts[open]} # subcommands_opts[create]="s: -size=s -ignore-swap k: -key=k" @@ -530,6 +534,7 @@ main() send) send ;; peek) peek ;; update) update ;; + query) lbdbq $@ ;; 'source') return 0 ;; __default) ;; *) error "command \"$subcommand\" not recognized"