Example #1
0
    exit;
}
if ($argv[1] == "--transmission-daemon") {
    $GLOBALS["OUTPUT"] = true;
    transmission_daemon();
    exit;
}
if ($argv[1] == "--milter-regex") {
    $GLOBALS["OUTPUT"] = true;
    milter_regex();
    exit;
}
if ($argv[1] == "--milter-spamass") {
    $GLOBALS["OUTPUT"] = true;
    spamassin_milter();
    spamassassin();
    exit;
}
$unix = new unix();
if ($GLOBALS["VERBOSE"]) {
    echo "Open unix class\n";
}
$PID_FILE = "/etc/artica-postfix/pids/" . basename(__FILE__);
$PID_TIME = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
$timeF = $unix->file_time_min($PID_TIME);
if (!$GLOBALS["FORCE"]) {
    if ($timeF < 3) {
        echo "slapd: [INFO] Executed since {$timeF}Mn die (use --force to bypass)..\n";
        die;
    }
}
Example #2
0
	$conf[]=zarafa_ical();
	$conf[]=zarafa_dagent();
	$conf[]=zarafa_monitor();
	$conf[]=zarafa_gateway();
	$conf[]=zarafa_spooler();
	$conf[]=zarafa_server();
	$conf[]=zarafa_licensed();
	$conf[]=zarafa_indexer();
	echo @implode("\n",$conf);
	die();
}



if($argv[1]=="--amavis-full"){
	$conf[]=spamassassin();
	$conf[]=clamd();
	$conf[]=amavis();
	$conf[]=amavis_milter();
	echo @implode("\n",$conf);
	die();
}

if(strlen($argv[1])>0){
	write_syslog("Unable to understand {$argv[1]}",basename(__FILE__));
	die();
}

$pidfile="/etc/artica-postfix/".basename(__FILE__).".pid";
$unix=new unix();
if($unix->process_exists(@file_get_contents($pidfile))){
Example #3
0
function spamassin_milter()
{
    include_once dirname(__FILE__) . "/ressources/class.spamassassin.inc";
    $spam = new spamassassin();
    $users = new usersMenus();
    spamassassin();
    $R = null;
    if (intval($spam->main_array["block_with_required_score"]) > 0) {
        $R = " -r {$spam->main_array["block_with_required_score"]} ";
    }
    $ldap = new clladp();
    $ARR[] = "127.0.0.1";
    if (!$ldap->ldapFailed) {
        $nets = $ldap->load_mynetworks();
        while (list($i, $mask) = each($nets)) {
            if (preg_match("#^127\\.0\\.0\\.#", $mask)) {
                continue;
            }
            $ARR[] = $mask;
        }
    }
    $f[] = "#!/bin/sh";
    $f[] = "#";
    $f[] = "# \$Id: spamass-milter.init 553 " . date("Y-m-d H:i:s") . " don \$";
    $f[] = "#";
    $f[] = "# Sample init script for Debian GNU/Linux";
    $f[] = "#";
    $f[] = "#  Copyright (c) 2002 Georg C. F. Greve <*****@*****.**>,";
    $f[] = "#   all rights maintained by FSF Europe e.V., ";
    $f[] = "#   Villa Vogelsang, Antonienallee 1, 45279 Essen, Germany";
    $f[] = "#";
    $f[] = "#   This program is free software; you can redistribute it and/or modify";
    $f[] = "#   it under the terms of the GNU General Public License as published by";
    $f[] = "#   the Free Software Foundation; either version 2 of the License, or";
    $f[] = "#   (at your option) any later version.";
    $f[] = "#  ";
    $f[] = "#   This program is distributed in the hope that it will be useful,";
    $f[] = "#   but WITHOUT ANY WARRANTY; without even the implied warranty of";
    $f[] = "#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the";
    $f[] = "#   GNU General Public License for more details.";
    $f[] = "#  ";
    $f[] = "#   You should have received a copy of the GNU General Public License";
    $f[] = "#   along with this program; if not, write to the Free Software";
    $f[] = "#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA";
    $f[] = "#";
    $f[] = "#   Contact:";
    $f[] = "#            Michael Brown <*****@*****.**>";
    $f[] = "";
    $f[] = "# This init script was modified on Thu, 30 Jan 2003 02:06:04 -0500 by";
    $f[] = "# Don Armstrong <*****@*****.**> from contrib/spamass-milter to";
    $f[] = "# allow force-reload and options specified in";
    $f[] = "# /etc/default/spamass-milter necessary for inclusion in debian.";
    $f[] = "";
    $f[] = "# It has been modified additionally to support LSB Boot options and";
    $f[] = "# status on Friday, July 6, 2007 14:02:44 PDT";
    $f[] = "";
    $f[] = "";
    $f[] = "### BEGIN INIT INFO";
    $f[] = "# Provides:          spamass-milter";
    $f[] = "# Required-Start:    \$syslog \$local_fs \$remote_fs";
    $f[] = "# Required-Stop:     \$syslog \$local_fs \$remote_fs";
    $f[] = "# Default-Start:     2 3 4 5";
    $f[] = "# Default-Stop:      0 1 6";
    $f[] = "# Short-Description: milter for spamassassin";
    $f[] = "# Description:       Calls spamassassin to allow filtering out";
    $f[] = "#                    spam from ham in libmilter compatible MTAs.";
    $f[] = "### END INIT INFO";
    $f[] = "";
    $f[] = "";
    $f[] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
    $f[] = "NAME=spamass-milter";
    $f[] = "DAEMON=/usr/sbin/spamass-milter";
    $f[] = "SOCKET=/var/run/spamass/spamass.sock";
    $f[] = "PIDFILE=/var/run/spamass/spamass.pid";
    $f[] = "DESC=\"Sendmail milter plugin for SpamAssassin\"";
    $f[] = "";
    $f[] = "DEFAULT=/etc/default/spamass-milter";
    $f[] = "OPTIONS=\"{$R}-u postfix -i " . @implode(",", $ARR) . " -- --socket /var/run/spamassassin/spamd.sock --config {$users->spamassassin_conf_path}\"";
    $f[] = "RUNAS=\"postfix\"";
    $f[] = "CHUID=\"\"";
    $f[] = "SOCKETMODE=\"0660\"";
    $f[] = "SOCKETOWNER=\"postfix:postfix\"";
    $f[] = "CHUID=\"--chuid \$RUNAS\";";
    $f[] = "";
    $f[] = "test -x \$DAEMON || exit 0";
    $f[] = "set -e";
    $f[] = "if [ ! -f \"/etc/artica-postfix/settings/Daemons/SpamAssMilterEnabled\" ]; then";
    $f[] = "\techo 0 >/etc/artica-postfix/settings/Daemons/SpamAssMilterEnabled || true";
    $f[] = "fi";
    $f[] = "if [ ! -f \"/etc/artica-postfix/settings/Daemons/EnableAmavisDaemon\" ]; then";
    $f[] = "\techo 0 >/etc/artica-postfix/settings/Daemons/EnableAmavisDaemon || true";
    $f[] = "fi";
    $f[] = "if [ ! -f \"/etc/artica-postfix/settings/Daemons/SpamAssBlockWithRequiredScore\" ]; then";
    $f[] = "\techo 5 >/etc/artica-postfix/settings/Daemons/SpamAssBlockWithRequiredScore || true";
    $f[] = "fi";
    $f[] = "if [ ! -f \"/etc/artica-postfix/settings/Daemons/SpamassassinDelegation\" ]; then";
    $f[] = "\techo 0 >/etc/artica-postfix/settings/Daemons/SpamassassinDelegation || true";
    $f[] = "fi";
    $f[] = "SpamAssMilterEnabled=`cat /etc/artica-postfix/settings/Daemons/SpamAssMilterEnabled`";
    $f[] = "EnableAmavisDaemon=`cat /etc/artica-postfix/settings/Daemons/EnableAmavisDaemon`";
    $f[] = "SpamassassinDelegation=`cat /etc/artica-postfix/settings/Daemons/SpamassassinDelegation`";
    $f[] = "";
    $f[] = "";
    $f[] = "start() {";
    $f[] = "if [ \$EnableAmavisDaemon != 0 ]; then";
    $f[] = "\techo \"WARNING: \$NAME Not enabled ( see EnableAmavisDaemon [ set to 1] )\";";
    $f[] = "\texit 0";
    $f[] = "fi";
    $f[] = "if [ \$SpamAssMilterEnabled != 1 ]; then";
    $f[] = "\techo \"WARNING: \$NAME Not enabled ( see SpamAssMilterEnabled )\";";
    $f[] = "\texit 0";
    $f[] = "fi";
    $f[] = "    # Because the default socket is in the same location as the";
    $f[] = "    # pidfile, we create them in this order.";
    $f[] = "    for DIR in \"\$(dirname \$PIDFILE)\" \"\$(dirname \$SOCKET)\"; do ";
    $f[] = "    # if the dirname is '.', then it's some kind of odd socket, like";
    $f[] = "    # an inet socket. Don't create the directory in such a case";
    $f[] = "\tif [ \"\$DIR\" != \".\" ] && [ ! -d \"\$DIR\" ]; then";
    $f[] = "\t    mkdir -p \"\$DIR\";";
    $f[] = "\t    if [ -x /sbin/restorecon ]; then ";
    $f[] = "\t\t/sbin/restorecon \"\$DIR\";";
    $f[] = "\t    fi;";
    $f[] = "\t    if [ -n \"\$RUNAS\" ]; then";
    $f[] = "\t\tchown \"\$RUNAS\" \"\$DIR\";";
    $f[] = "\t    fi;";
    $f[] = "\tfi;";
    $f[] = "    done;";
    $f[] = "    if [ -n \"\$RUNAS\" ] && [ -d \$(dirname \$PIDFILE) ] &&";
    $f[] = "\t[ \"\$(stat -c '%U' \$(dirname \$PIDFILE))\" != \"\$RUNAS\" ]; then";
    $f[] = "\techo \"WARNING: \$NAME will run as user \$RUNAS but \$(dirname \$PIDFILE) is not owned by \$RUNAS\";";
    $f[] = "\techo \"Either delete this directory or chown it appropriately. Startup attempts may fail.\";";
    $f[] = "    fi;";
    $f[] = "    if [ -n \"\$RUNAS\" ] && [ \$(dirname \$SOCKET) != \".\" ] &&";
    $f[] = "\t[ -d \$(dirname \$SOCKET) ] &&";
    $f[] = "\t[ \"\$(stat -c '%U' \$(dirname \$SOCKET))\" != \"\$RUNAS\" ]; then";
    $f[] = "\techo \"WARNING: \$NAME will run as user \$RUNAS but \$(dirname \$SOCKET) is not owned by \$RUNAS\";";
    $f[] = "\techo \"Either delete this directory or chown it appropriately. Startup attempts may fail.\";";
    $f[] = "    fi;";
    $f[] = "    if [ \$(dirname \$SOCKET) != \".\" ]; then ";
    $f[] = "\t/bin/rm -f \$SOCKET";
    $f[] = "    fi;";
    $f[] = "    start-stop-daemon --start -p \$PIDFILE \$CHUID --exec \$DAEMON -- -P \$PIDFILE -f -p \$SOCKET \$OPTIONS";
    $f[] = "    sleep 1s";
    $f[] = "    if [ -n \"\$SOCKETMODE\" ]; then";
    $f[] = "\tchmod \$SOCKETMODE \$SOCKET;";
    $f[] = "    fi;";
    $f[] = "    if [ -n \"\$SOCKETOWNER\" ]; then";
    $f[] = "\tchown \$SOCKETOWNER \$SOCKET;";
    $f[] = "    fi;";
    $f[] = "}";
    $f[] = "";
    $f[] = "stop(){";
    $f[] = "    start-stop-daemon --oknodo --stop -p \$PIDFILE --signal 3 --exec \$DAEMON";
    $f[] = "    /bin/sleep 5s";
    $f[] = "    /bin/rm -f \$SOCKET";
    $f[] = "    /bin/rm -f \$PIDFILE";
    $f[] = "}";
    $f[] = "";
    $f[] = "status(){";
    $f[] = "    if [ -e \$PIDFILE ]; then ";
    $f[] = "\tif kill -0 \$(cat \$PIDFILE); then";
    $f[] = "\t    echo \"\${NAME} running\";";
    $f[] = "\t    exit 0;";
    $f[] = "\telse";
    $f[] = "\t    echo \"\${NAME} dead but \$PIDFILE exists\";";
    $f[] = "\t    exit 1;";
    $f[] = "\tfi;";
    $f[] = "\techo \"\${NAME} not running\";";
    $f[] = "\texit 3;";
    $f[] = "    fi;";
    $f[] = "}";
    $f[] = "";
    $f[] = "case \"\$1\" in";
    $f[] = "  start)";
    $f[] = "\techo -n \"Starting \$DESC: \"";
    $f[] = "\tstart";
    $f[] = "\techo \"\${NAME}\"";
    $f[] = "\t;;";
    $f[] = "  stop)";
    $f[] = "\techo -n \"Stopping \$DESC: \"";
    $f[] = "\tstop";
    $f[] = "\techo \"\${NAME}\"";
    $f[] = "\t;;";
    $f[] = "  force-reload | restart)";
    $f[] = "\techo -n \"Restarting \$DESC: \"";
    $f[] = "";
    $f[] = "\tstop";
    $f[] = "  /etc/init.d/spamassassin reload >/dev/null 2>&1 || true";
    $f[] = "\tstart";
    $f[] = "\techo \"\${NAME}\"";
    $f[] = "\t;;";
    $f[] = "  status)";
    $f[] = "\tstatus";
    $f[] = "\t;;";
    $f[] = "  *)";
    $f[] = "\tN=\$0";
    $f[] = "\techo \"Usage: \$N {start|stop|restart|force-reload|status}\" >&2";
    $f[] = "\texit 1";
    $f[] = "\t;;";
    $f[] = "esac";
    $f[] = "";
    $f[] = "exit 0";
    @file_put_contents("/etc/init.d/spamass-milter", @implode("\n", $f));
    @chmod("/etc/init.d/spamass-milter", 0755);
    if (is_file('/usr/sbin/update-rc.d')) {
        shell_exec('/usr/sbin/update-rc.d -f spamass-milter >/dev/null 2>&1');
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: spamass-milter daemon success...\n";
    }
}