On Tue, 27 May 2014 11:27:56 +0530
Kushal Kumaran <kushal.kumaran+deb...@gmail.com> wrote:

> Joe Pfeiffer <pfeif...@cs.nmsu.edu> writes:
> 
> > First, here's what I'm trying to do:
> >
> > I'm using encfs to give myself an encrypted home directory, and I'm
> > successfully mounting it automatically using pam_mount when I log
> > in.
> >
> > My email is processed by a .procmailrc file in my home directory,
> > and I'm passing the email through bogofilter.  So, at present I
> > have a nearly empty home directory containing .procmailrc
> > and .bogofilter/ which is accessed when I'm not logged in, and my
> > "real" home directory which is available when I am logged in.  This
> > is, of course, less than optimal since I have to keep two versions
> > of .procmailrc and .bogofilter/ in sync.
> >
> 
> You could keep the two files outside your home, and create symlinks to
> them in both the unencrypted and encrypted homes.

That sounds good to me.

If you want to keep two separate files, it's as simple as running a
shellscript to make sure they are the same. For instance,
my .procmailrc got so big and complicated that I split it into parts.
For instance, all the trolls and irritants go into something called
badguys.rc. Mailing lists go in maillists.rc. So to filter yet another
person, I'd edit badguys.rc, run my shellscript, and it would create a
new ~/.procmailrc with everything in the right order (bad guys get
filtered out before mailing list decisions are made, etc). There's one
file called vitals.rc that rises to the top of the file, and is
reserved for anything from a person or organization I consider
absolutely essential, and I want to see it even if it would normally be
moved by other filters. My shellscript could just as easily write a
copy in two different places.

I guess what I'm saying is that if and only if both your .procmailrc
and .bogofilter/ would benefit from such a shellscript without regard
to your two directory situation, you could make your shellscript write
both files, safe in the knowledge that they're both the same.
Otherwise, symlinks seem to me a good way to go.

Here's my shellscript, called make_pm_filters.sh:

===============================================
#!/bin/bash

######################################################
# Copyright (C) 2014 by Steve Litt
# 
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and
# associated documentation files (the "Software"), to
# deal in the Software without restriction, including
# without limitation the rights to use, copy, modify,
# merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom
# the Software is furnished to do so, subject to the
# following conditions:
# 
# The above copyright notice and this permission notice
# shall be included in all copies or substantial
# portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
# LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO
# EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
# FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
# USE OR OTHER DEALINGS IN THE SOFTWARE.
######################################################

#### The Procmail resource file
#### Careful, gets overwritten on every run
pmrcfile=~/.procmailrc

#### Dir containing component files
componentdir=/d/inst/pmfilters/   

#### Procmail resource components, ORDER IS IMPORTANT!!!
componentfiles="envvars.rc
   vitals.rc
   badguys.rc
   maillists.rc
   diag_first.rc
   by_account.rc
   diag_second.rc
   fallthrough.rc"

function apppend(){
   local fname=$1
   echo  >> $pmrcfile
   echo  >> $pmrcfile
   echo  >> $pmrcfile
   echo "###############" >> $pmrcfile
   echo "##### $fname" >> $pmrcfile
   echo "###############" >> $pmrcfile
   echo  >> $pmrcfile
   fname=$componentdir$fname
   cat $fname >> $pmrcfile
}

function makeheader(){
   echo -n "##### CREATED BY $0: " > $pmrcfile
   echo "DO NOT EDIT BY HAND!!! #####" >> $pmrcfile
   echo -n "##### COMPONENT FILE DIRECTORY " >> $pmrcfile
   echo "IS $componentdir #####" >> $pmrcfile
   echo >>$pmrcfile
   echo >>$pmrcfile
}

cd $componentdir

echo
echo -n "This will concat the following component "
echo "files to $pmrcfile,"
echo "in the following order ..."
echo
for f in $componentfiles; do
   echo $f
done

echo
echo "Next, will test that all component files exist..."
echo

let errs=0
for f in $componentfiles; do
   if ! test -f $f; then
      let errs=$errs+1
      echo -n "FATAL ERROR: "
      echo "No file $f in directory $componentdir"
   fi
done

if test $errs -gt 0; then
   echo "$errs ERRORS, aborting..."
   echo
   exit 2
else
   echo "All componentfiles accounted for, continuing..."
fi

makeheader
for f in $componentfiles; do
   echo Appending component file file $f
   chmod 600 $f
   apppend $f
done

chmod 600 $pmrcfile

echo
echo -n "Procmail resource file $pmrcfile "
echo "is now updated"
echo "with contents of component files."
echo

===============================================



SteveT

Steve Litt                *  http://www.troubleshooters.com/
Troubleshooting Training  *  Human Performance


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/20140527111914.69c7d98e@mydesk

Reply via email to