dhsanto - 2007-12-27

I just got on the site TODAY to post this and noticed that v1.0 was out. What timing. Oh well.

Going from 10.4 to 10.5 caused problems, so, here's how I fixed it. YMMV:

     Three(3) lines in the startup-item file didn't work in Leopard. I changed the "ps -auxww" in the line(s) "pid=$( ps -auxww | grep popfile.pl | grep -v grep | awk '{ print $2 }' )" and replaced the "ps -auxww" with "ps -axww -u 0" (the last item is a ZERO!). The "u" prior to Leopard had a different meaning. Now, it stands for "user" and the ZERO is for root. It also should be SEPARATE, like "-axww -u 0" NOT "-axwwu 0."

Also, three(3) more lines caused problems, I forget exactly what, so I just "commented them out." Place a crosshatch (a pound-sign, "#") in front of ALL of the "ConsoleMessage" lines.

     The second to the last change is pretty minor, but, still needed. Item 7, under "Creating a POPfile Startup Item for Mac OS X" at http://popfile.sourceforge.net/wiki/howtos:macosx reads:

     cd /Library/StartupItems
     sudo chown -R root.admin popfile
     cd popfile
     sudo chmod 754 popfile
     sudo chmod 644 StartupParameters.plist

Change "sudo chown -R root.admin popfile" in line 2 to "sudo chown -R root:wheel popfile" and in line 4, change 754 to 755. Hopefully, the Security Fixer won't activate when you next start up your Mac.

Now, just to make sure, I added, at the beginning of the startup-item, the following:

        AFTER ". /etc/rc.common"
    
    export ARCHFLAGS="-arch ppc" or the Intel equivalent.
    export DYLD_LIBRARY_PATH={a colon-separated list of your dynamic library folders}. Doesn't have to be extensive.
    export MANPATH={a colon-separated list of your man folders}. Maybe yes or no?
    export PATH={a colon-separated list of your bin, sbin and (maybe even) libexec folders}.
    export PERL5LIB={a colon-separated list of your (EXTRA) Perl folders}. Use "perl -le 'print join $/, @INC'" in Terminal
             to see the System list and add what you need here.
    export POPFILE_ROOT="/Library/POPfile" or such.

Here's MY file:

#!/opt/local/bin/bash
#
# POPfile - startup script
#
# For this to work POPfile should be in /Library/POPfile
#
. /etc/rc.common

export ARCHFLAGS="-arch ppc"
export DYLD_LIBRARY_PATH="/opt/local/lib:/usr/local/lib:/System/Library/Perl/5.8.8/darwin-thread-multi-2level/CORE:/System/Library/Perl/lib/5.8:/usr/lib:/usr/lib/system:/Library/Tcl/Tcl_SYStem_Symlinks_f:/usr/lib/sqlite3:/opt/local/lib/db44:/opt/local/lib/db46:/usr/local/clamXav/lib:/usr/lib/dtrace:/usr/lib/java:/usr/lib/samba:/usr/lib/samba/auth:/usr/lib/samba/charset:/usr/lib/samba/idmap:/usr/lib/samba/nss_info:/usr/lib/samba/pdb:/usr/lib/samba/vfs:/usr/libexec/gdb:/usr/libexec/oah/Shims:/usr/lib/gcc/powerpc-apple-darwin9/4.0.1:/usr/lib/gcc/i686-apple-darwin9/4.0.1:/Library/Tcl/macports1.0:/opt/local/share/macports/Tcl/darwintrace1.0:/opt/local/share/macports/Tcl/pextlib1.0:/opt/local/share/macports/Tcl/registry2.0:/opt/local/share/macports/Tcl/tclobjc1.0:/System/Library/CoreServices/Encodings:/System/Library/Printers/Libraries:/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A:/System/Library/Frameworks/AppKit.framework/Versions/C/Resources/BridgeSupport:/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources:/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources:/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/BridgeSupport:/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources:/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/Resources:/System/Library/Frameworks/CoreFoundation.framework/Versions/A/Resources/BridgeSupport:/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/Support:/System/Library/Frameworks/Foundation.framework/Versions/C/Resources/BridgeSupport:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Libraries:/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Libraries:/System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Libraries:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries:/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib:/System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/BridgeSupport:/System/Library/PrivateFrameworks/PSNormalizer.framework/Versions/A/Libraries:/Developer/usr/lib/gcc/powerpc-apple-darwin9/4.0.1:/Developer/usr/lib:/Developer/usr/libexec/gdb:/Developer/usr/lib/gcc/i686-apple-darwin9/4.0.1"
export MANPATH="/Library/Perl/man:/opt/local/share/man:/usr/local/share/man:/usr/local/clamXav/share/man:/usr/share/man:/Developer/usr/share/man"
export PATH="/opt/local/bin:/opt/local/sbin:/opt/local/libexec:/usr/local/bin:/usr/local/sbin:/usr/local/libexec:/Library/Perl/bin:/System/Library/Perl/Extras/bin:/System/Library/Perl/Extras/5.8.8/HeaderDoc/bin:/Users/dhs/Library/TeX/bin:/Users/dhs/Library/TeXShop/bin:/usr/local/clamXav/bin:/usr/local/clamXav/sbin:/usr/bin:/usr/sbin:/usr/libexec:/bin:/sbin:/Library/OpenBase/bin:/Developer/usr/bin:/Developer/usr/libexec:/Developer/usr/sbin:/usr/X11/bin:/usr/share/ant/bin:/usr/share/maven/bin:/usr/share/simg5/bin:/usr/share/simg4_plus/bin"
export PERL5LIB="/Library/Perl:/Library/Perl/Vendor_Perl:/System/Library/Perl/Extras/5.8.8"
export POPFILE_ROOT="/Library/POPfile"

if [ "$1" == "start" ]
then
    pid=$( ps -axww -u 0 | grep popfile.pl | grep -v grep | awk '{ print $2 }' )
    if ! [ $pid ]; then
        #ConsoleMessage "Starting POPfile mail classification proxy"
        cd /Library/POPfile
        /usr/bin/perl popfile.pl > /dev/null 2>&1 &
    fi
   
elif [ "$1" == "stop" ]
then
    pid=$( ps -axww -u 0 | grep popfile.pl | grep -v grep | awk '{ print $2 }' )
    if [ $pid ]; then 
        #ConsoleMessage "Stopping POPfile mail classification proxy"       
        kill -6 $pid
    fi
   
elif [ "$1" == "restart" ]
then
    pid=$( ps -axww -u 0 | grep popfile.pl | grep -v grep | awk '{ print $2 }' )
    #ConsoleMessage "Restarting POPfile mail classification proxy"
    kill -HUP $pid
    cd /Library/POPfile
    /usr/bin/perl popfile.pl > /dev/null 2>&1 &
fi

Now, to try v1.0!