Installing POPFile on Linux
From Foochal
Contents |
[edit]
Getting POPFile binary
[edit]
Installing the binary
[edit]
Setting up startup/shutdown scripts
[edit]
Creating the script
Create the file /etc/init.d/popfile. Copy the following text into the file:
#--- SCRIPT START file called: popfile
#!/bin/sh
#
# Copyright (C) 2003 John Zoetebier <johnzoet@users.sourceforge.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# ==============
# History
# --------------
# Modified by Peter Davie to include RedHat specific featues (e.g. using the 'functions' scripts)
# 19 Nov 2003 10:49am MYT
#
#
# popfile
#
# A shell-script wrapper for popfile designed for use in the SysV-init
# system (/etc/init.d).
#
#
# usage: popfile { start | stop | restart | }
#
# See also: LSB, start_daemon (lsb), startproc (suse), install_initd (lsb),
# insserv (suse), /usr/share/doc/initscripts*/sysvinitfiles (redhat)
#
##
# RedHat comment block...
#
# chkconfig: 345 80 20
# description: popfile is a POP3 proxy and mail filter
# pidfile: /var/run/popfile.pid # processname: popfile
#
#
##
# LSB comment block...
#
# The bogus 345 run-levels are a workround for a buggy RedHat chkconfig which
# reads the LSB comment block (incorrectly) as an undocumented 'feature'.
#
### BEGIN INIT INFO
# Provides: popfile
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 345 3 4 5
# Default-Stop: 345 3 4 5
# Description: popfile is a POP3 proxy and mail filter
### END INIT INFO ##
# Source function library.
if [ -f /etc/init.d/functions ] ; then
/etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
/etc/rc.d/init.d/functions
else
exit 0
fi
popfile_home=/usr/local/popfile
popfile="${popfile_home}/popfile.pl" # file must be executable, otherwise perl will not start
# Setup variables
folder_saved=`pwd`
start() {
cd ${popfile_home}
echo -n "Starting popfile: "
${popfile} >> /dev/null 2>&1 &
echo -n "started as background process" && echo success && echo
# echo -en "\033[${RES_COL}G[ OK ]" -- Commented out PD, see history above.
}
stop() {
echo -n "Stopping popfile ... "
pid=`ps -ef | grep perl | grep popfile.pl | gawk '{print $2}'`
if [ "${pid}" = "" ] ; then
echo "popfile is not running"
else
kill $pid
fi
#echo -en "\033[${RES_COL}G[ OK ]"
echo success && echo
}
status() {
pid=`ps -ef | grep perl | grep popfile.pl | gawk '{print $2}'`
if [ "${pid}" = "" ] ; then
echo "stopped"
else
echo "running"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
# Back to original folder
cd $folder_saved
exit 0
#--- SCRIPT END
[edit]
Setting script permissions
chmod uga+x /etc/init.d/popfile
[edit]
Setting up auto startup/shutdown links
cd /etc/rc0.d/ ln -s ../init.d/popfile K82popfile
cd /etc/rc3.d/ ln -s ../init.d/popfile S82popfile
[edit]
Install Perl Modules
Check your perl version
perl -v
Install required perl modules:
perl -MCPAN -e shell install DBI install DBD::SQLite install DBD::mysql install Digest::base install Digest::MD5 install HTML::Tagset install MIME::Base64 install MIME::QuotedPrint install Date::Parse install HTML::Template install Net::SSLeay install IO::Socket::SSL quit
Reference [1]

