14 March 2004 - POPFile 0.2.x - Mac OS X 10.3 - artz-net.de home
The current HOW-TO for POPFile 0.22.x
I don't have the time right now to update the installation HOW-TO to version 0.21.0. However, you will find the instructions how to update popfile 0.20.x to 0.21.x written by Ken Edwards here. I will try to update these instructions for the new version in a few days time.
POPFile is an automatic mail classification tool. Once properly set up and trained, it will work in the background of your computer, scanning mail as it arrives and filing it however you wish. You can give it a simple job, like separating out junk e-mail, or a complicated one - like filing mail into a dozen folders. Think of it as a personal assistant for your inbox.
POPFile makes use of the BSD Subsystem of Mac OS X and you will need to know how to type a few commands in Terminal.app. Don't be afraid, however, it's very easy to set-up POPFile, and once installed all configuration will be done through a very well structured interface in the browser of your choice.
This HOW-TO assumes that you are running Mac OS X 10.3 or later and I have tested POPFile 0.2.x on this version of the Mac OS, only. There should be no problems running POPFile 0.2.x on Mac OS X 10.2.x, though.
However, I upgraded all my Macs to Panther by now, so please don't mail me with Jaguar-specific problems as I will not be able to reproduce them on my machines. Thank you.
I will cover the whole installation process as if installing POPFile for the first time. Steps that can be skipped when upgrading from version 0.1.x are marked accordingly. Please make sure you are logged into Mac OS X as a user with admin privileges.
You will need the Apple Developer Tools to build the BerkelyDB database and the perl modules that are needed by POPFile 0.2.x. The Developer Tools are included with any retail version of Mac OS X 10.3. on CD 4 labeled "Mac OS X Xcode Tools". If you want to save some disk space do a customized install and select just the "Developer Tools Software", the "Mac OS X SDK" and the "BSD SDK".
Go to popfile.sourceforge.net and download the latest universal "non-Windows" version.
Upgraders may skip this step:
POPFile requires the MIME-Base64 perl module to be installed. However, Apple decided not to include this module in OS X. So, go to cpan.org and download the latest MIME-Base64 perl module to your computer.
The Berkeley DB database program is distributed by Sleepycat Software. Go to their download page and download the current Berkeley DB release (either with or without strong encryption, this doesn't matter for the POPFile installation).
In order to be able to interact with the Berkeley DB, POPFile needs the BerkeleyDB perl module. So, go to cpan.org and download the latest BerkeleyDB perl module to your computer as well.
Upgraders may skip this step:
I'd suggest you create a new directory in '/Library/' and name it "POPfile". (Note: make sure you are logged in as a user with admin privileges)
Simply navigate to your download folder and unpack the files you just downloaded. Four new folders will be created in your download folder:
drwxr-xr-x 15 michael admin 510 Nov 05 19:24 BerkeleyDB-0.25 drwxr-xr-x 15 michael admin 510 Nov 05 19:24 db-4.1.25 drwxr-xr-x 15 michael admin 510 Nov 05 19:24 MIME-Base64-2.21 drwxr-xr-x 14 michael admin 476 Nov 05 19:25 popfile-0.2.1
Go to the POPFile configuration interface at http://127.0.0.1:8080 and click on 'Shutdown POPFile' to stop POPFile.
Please follow these steps exactely in the same order as I have arranged them. The installation will not work otherwise.
Install the Developer Tools first. See the hint in step 2.1 above on how to save some disk space.
Different ways of obtaining root privileges
Many of the following comands need to be executed with root privileges. If you did not activate the root account on your Mac you could use 'sudo' in front of these comands as in 'sudo make install'.
A much easier approach, however, is to become 'root' for a complete terminal session. Just type
sudo -s -H
once, enter you password and you will be root for as long as you keep the current terminal window open. I will assume that you did so from now on.
Upgraders may skip this step:
Installing the perl module should be very easy. Open a Terminal window, become root as described above and type 'cd '. Now drop the expanded folder onto the Terminal window and press 'enter'.
Once you have changed into the "MIME-Base64-2.21" folder type the following commands:
perl Makefile.PL [enter]
make [enter]
make test [enter]
make install [enter]
If all goes well - you should see a few message on the command line whether the installation worked or not - the perl module should now be installed
Type 'cd ' again and drop the 'db-4.1.25' folder onto you terminal window. Press enter and type the following commands:
cd build_unix [enter]
../dist/configure [enter]
make [enter]
make install [enter]
After the installation has finished - hopefully without any error messages - type the followning:
cd /usr/local/ [enter]
ln -s BerkeleyDB.4.1 BerkeleyDB [enter]
When you take a look at the directory with the comand 'ls -la' you will notice that we just created a so called symbolic link:
lrwxr-xr-x 1 root wheel 15 5 Nov 18:15 BerkeleyDB -> BerkeleyDB.4.1/ drwxr-xr-x 6 root wheel 204 5 Nov 18:14 BerkeleyDB.4.1
The link 'BerkeleyDB' points to the actual directory 'BerkeleyDB.4.1' with its version number suffix. This has two advantages: You will be able to install the BerkeleyDB perl module in step 4.2 without having to adjust the paths in its 'config.in' file. What is more, you will be able to upgrade to future versions of the Berkeley DB without problems. All you will have to do is point the 'BerkeleyDB' link to the newer directory and all programs that depend on the BerkeleyDB will still be able to find the updated version.
As of version 0.25 of the BerkeleyDB perl module, the 'config.in' file is broken. The author of the module told me that he will fix this in the next version. In the meantime, open the file 'config.in' in a text editor and make sure that these lines are uncommented:
INCLUDE = /usr/local/BerkeleyDB/include LIB = /usr/local/BerkeleyDB/lib
Do the old 'cd ' & drop trick with the BerkeleyDB-0.25 folder, press enter and type the following:
perl Makefile.PL [enter]
make [enter]
make test [enter]
After your system has passed all the tests install the module by typing:
make install [enter]
Finally, the last and easiest step: Open the "popfile-0.2.x" folder and copy all files to '/Library/POPfile/'.
You could now start up POPFile with the following command:
cd /Library/POPfile/ [enter]
perl popfile.pl [enter]
A message telling you that POPFile is running should appear on the command line. To quit POPFile and regain control of the command line type 'ctrl c'.
POPFile is now installed. However, you'll probably want POPFile to start at boot time without the need to provide a password. So, there's just one more thing (pardon the pun):
If you're upgrading from POPFile 1.x you can skip the rest and start your new POPFile installation as described in step 5.
It's time to navigate to '/Library/StartupItems/'. Now either download this file which contains a complete startup item which you can unpack and place in '/Library/StartupItems/' and read on here or continue if you want to create the files yourself.
Special note to fink users:
If you used fink to install the MIME-Base64 perl module you will have to add the following lines to your '/Library/StartupItems/popfile/popfile' or automatic startup at system boot will fail:
. /etc/rc.common #### begin export PERL5LIB for fink if ( $?PERL5LIB ) then PERL5LIB="/sw/lib/perl5:$PERL5LIB" export PERL5LIB else PERL5LIB="/sw/lib/perl5" export PERL5LIB fi #### end export PERL5LIB for fink if [ "$1" == "start" ]
Thanks to Kevin Horton for this work-around.
Create a folder named 'popfile', open it and create a text file called 'StartupParameters.plist' which contains the following text:
{
Description = "POPfile mail filter proxy";
Provides = ("popfile");
Requires = ("Network");
Uses = ("Disks", "Network Time", "IPServices");
OrderPreference = "Last";
Messages =
{
start = "Starting popfile";
stop = "Stopping popfile";
};
}
Next comes the actual StartupItem. Create a second text file and call it 'popfile':
#!/bin/sh
##
# POPfile - startup script
##
# For this to work POPfile should be in /Library/POPfile
##
. /etc/rc.common
if [ "$1" == "start" ]
then
pid=$( ps -auxww | grep popfile.pl | grep -v grep | awk '{ print $2 }' )
if ! [ $pid ]; then
ConsoleMessage "Starting POPfile POP mail proxy"
cd /Library/POPfile
perl popfile.pl > /dev/null 2>&1 &
fi
elif [ "$1" == "stop" ]
then
pid=$( ps -auxww | grep popfile.pl | grep -v grep | awk '{ print $2 }' )
if [ $pid ]; then
ConsoleMessage "Stopping POPfile mail proxy"
kill -6 $pid
fi
elif [ "$1" == "restart" ]
then
pid=$( ps -auxww | grep popfile.pl | grep -v grep | awk '{ print $2 }' )
ConsoleMessage "Restarting POPfile mail proxy"
kill -HUP $pid
cd /Library/POPfile
perl popfile.pl > /dev/null 2>&1 &
fi
Now create a directory named 'Resources', open it and create another directory 'English.lproj'. The path to this directory should be:
/Library/StartupItems/popfile/Resources/English.lproj/
The last file you'll need should be called 'Localizable.strings' and needs to be placed in the 'English.lproj' folder:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist SYSTEM " file://localhost/System/Library/DTDs/PropertyList.dtd" ; ;> <plist version="0.9"> <dict> <key>Starting popfile</key> <string>Starting popfile</string> <key>Stopping popfile</key> <string>Stopping popfile</string> </dict> </plist>
That's it! All that remains to be done is setting correct permissions for the StartupItem.
Type the following (remember to become root by typing 'sudo -s -H' first if you closed your terminal window in the meantime):
cd /Library/StartupItems [enter]
chown -R root.admin popfile [enter]
cd popfile/ [enter]
chmod 754 popfile [enter]
chmod 644 StartupParameters.plist [enter]
You're done! POPFile should now always start at boot time.
An alternative method of starting POPFile
If you would like to start POPFile at login (as opposed to system boot) so multiple users can have different buckets and settings, you might want to take a look at POPFile Startup. POPFile Startup will start the POPFile email proxy without any user interaction when the user logs in.
Note: Only users with Administrator privileges can use POPFile Startup. This is because POPFile Startup must use the 'sudo' command to run POPFile as root. Only users with Administrator privileges can run commands as root.
If you want to start up POPFile without rebooting just type this at the command prompt:
/Library/StartupItems/popfile/popfile start [enter]
Open the browser of your choice and go to the POPFile configuration interface at http://127.0.0.1:8080. Start by reading the short introduction on training POPFile and enjoy your soon to be spam free mailbox.
© 2003 - Michael Artz (web2006 at artz-net.de)
http://www.artz-net.de/popfile/