function StartUpdate() { $updaterbin = "/opt/kaspersky/kav4proxy/bin/kav4proxy-keepup2date"; if (!is_file($updaterbin)) { return; } $t = time(); ufdbguard_admin_events("Starting updating Kaspersky For Proxy server", __FUNCTION__, __FILE__, __LINE__, "update"); $unix = new unix(); $sock = new sockets(); @mkdir("{$GLOBALS["RUN_DIR"]}", 0777, true); $chmod = $unix->find_program("chmod"); shell_exec("{$chmod} 777 {$GLOBALS["RUN_DIR"]}"); $pidFile = "{$GLOBALS["RUN_DIR"]}/keepup2date.pid"; $pid = $unix->get_pid_from_file($pidFile); if ($unix->process_exists($pid)) { ufdbguard_admin_events("Other instance {$pid} running, aborting task", __FUNCTION__, __FILE__, __LINE__, "update"); return; } $Kav4ProxyDatabasePath = $sock->GET_INFO("Kav4ProxyDatabasePath"); if ($Kav4ProxyDatabasePath == null) { $Kav4ProxyDatabasePath = "/home/artica/squid/kav4proxy/bases"; } $php5 = $unix->LOCATE_PHP5_BIN(); shell_exec("{$php5} /usr/share/artica-postfix/exec.kav4proxy.php --build"); @mkdir("/opt/tmp", 0755, true); @mkdir("{$Kav4ProxyDatabasePath}", 0755, true); @mkdir("/var/log/artica-postfix/kaspersky/kav4proxy", 0755, true); shell_exec("{$chmod} 777 /opt/tmp"); shell_exec("{$chmod} 777 {$Kav4ProxyDatabasePath}"); buildConf(); $logfile = "/var/log/artica-postfix/kaspersky/kav4proxy/" . date("Y-m-d_H-i-s"); $tmpFileName = "/etc/artica-postfix/kav4proxy-keepup2date.conf"; $nice = EXEC_NICE(); $cmd = "{$nice}{$updaterbin} -d {$pidFile} -c {$tmpFileName} -l {$logfile} 2>&1"; ufdbguard_admin_events("{$cmd}", __FUNCTION__, __FILE__, __LINE__, "update"); shell_exec($cmd); $t2 = time(); $timehuman = $unix->distanceOfTimeInWords($t, $t2); ufdbguard_admin_events("Updating Kaspersky For Proxy server finish took {$timehuman}", __FUNCTION__, __FILE__, __LINE__, "update"); ufdbguard_admin_events(@file_get_contents($logfile), __FUNCTION__, __FILE__, __LINE__, "update"); $t = file($logfile); while (list($index, $line) = each($t)) { if (preg_match("#^\\[.*?F\\]\\s+(.+)#", $line, $re)) { ufdbguard_admin_events("Failed: {$re[1]}", __FUNCTION__, __FILE__, __LINE__, "update"); } } if ($GLOBALS["VERBOSE"]) { $verb = " --verbose"; } shell_exec("/opt/kaspersky/kav4proxy/bin/kav4proxy-licensemanager -i >/etc/artica-postfix/kav4proxy-licensemanager-i"); shell_exec($unix->LOCATE_PHP5_BIN() . " /usr/share/artica-postfix/exec.kaspersky-update-logs.php --force{$verb}"); Kav4ProxyDatabasePathSatus(); }
} else { echo fM("The facileManager client scripts are not installed.\n"); exit(1); } /** Check running user */ if (exec(findProgram('whoami')) != $whoami && !$dryrun) { echo fM("This script must run as {$whoami}.\n"); exit(1); } /** Check if running supported version */ $data['server_version'] = detectFWVersion(); /** Build everything required via cron */ if ($cron) { $data['action'] = 'cron'; } /** Build the server config */ if ($buildconf) { $data['action'] = 'buildconf'; } /** Build the zone files */ if ($zones) { $data['action'] = 'zones'; } /** Set variables to pass */ $url = $proto . '://' . FMHOST . 'buildconf.php'; $data['dryrun'] = $dryrun; /** Build the configs provided by $url */ $retval = buildConf($url, $data); if (!$retval) { exit(1); }
function setup() { if (!_test_setup()) { @unlink("/var/opt/kaspersky/klms/installer.dat"); shell_exec("/bin/rm -rf /var/opt/kaspersky/klms/postgresql >/dev/null 2>&1"); @mkdir("/var/opt/kaspersky/klms/postgresql"); @chown("/var/opt/kaspersky/klms/postgresql", "kluser"); @chgrp("/var/opt/kaspersky/klms/postgresql", "klusers"); } if (file_exists("/var/opt/kaspersky/klms/installer.dat")) { echo "Starting......: " . date("H:i:s") . " Kaspersky Mail security Suite install already done...\n"; return; } $unix = new unix(); $local_gen = $unix->find_program("locale-gen"); echo "Starting......: " . date("H:i:s") . " Kaspersky Mail security Suite generating en_US.UTF-8\n"; shell_exec("{$local_gen} en_US.UTF-8"); echo "Starting......: " . date("H:i:s") . " Kaspersky Mail security Suite starting installation..\n"; $chmod = $unix->find_program("chmod"); $chown = $unix->find_program("chown"); $su = $unix->find_program("su"); $cp = $unix->find_program("cp"); @mkdir("/var/opt/kaspersky/klms/postgresql", 0755, true); shell_exec("{$chown} kluser:klusers /var/opt/kaspersky/klms/postgresql"); echo "Starting......: " . date("H:i:s") . " Kaspersky Mail security Suite creating database....\n"; if (!is_file("/var/opt/kaspersky/klms/postgresql/postgresql.conf")) { @unlink("/var/opt/kaspersky/klms/postgresql/postgresql.conf"); } $cmd = "su -m -l kluser -c \"/opt/kaspersky/klms/libexec/postgresql/initdb -L /opt/kaspersky/klms/share/postgresql --pgdata=/var/opt/kaspersky/klms/postgresql --encoding=utf-8 --locale=C\""; if ($GLOBALS["VERBOSE"]) { echo "{$cmd}\n"; } shell_exec($cmd); $cmd = "{$cp} -fp /opt/kaspersky/klms/share/postgresql.conf.skel /var/opt/kaspersky/klms/postgresql/postgresql.conf"; if ($GLOBALS["VERBOSE"]) { echo "{$cmd}\n"; } shell_exec($cmd); echo "Starting......: " . date("H:i:s") . " Kaspersky Mail security Suite starting Database service...\n"; shell_exec("/etc/init.d/klmsdb start"); $f[] = "configurator"; $f[] = "rule_storage"; $f[] = "backup"; $f[] = "product_status"; $f[] = "notifier"; $f[] = "statistics"; $f[] = "personal_settings"; while (list($index, $table) = each($f)) { echo "Starting......: " . date("H:i:s") . " Kaspersky Mail security Suite creating table \"{$table}\"\n"; $cmd = "su -m -l kluser -c \"/opt/kaspersky/klms/libexec/postgresql/createdb -h /var/run/klms -O kluser -E UTF8 {$table}\""; if ($GLOBALS["VERBOSE"]) { echo "{$cmd}\n"; } shell_exec($cmd); } echo "Starting......: " . date("H:i:s") . " Kaspersky Mail security Suite creating default password \"{$table}\"\n"; @copy("/usr/share/artica-postfix/bin/install/klms.db.password", "/var/opt/kaspersky/klms/db/password"); echo "Starting......: " . date("H:i:s") . " Kaspersky Mail security Suite fixing settings\n"; $t = exec("/opt/kaspersky/klms/libexec/generate_uuid"); if (preg_match("#.*?:(.+)#", $t, $re)) { $generate_uuid = $re[1]; } echo "Starting......: " . date("H:i:s") . " Kaspersky Mail security Suite identifier:{$generate_uuid}\n"; $file[] = "INSTALL_DATE=" . time(); $file[] = "EULA_AGREED=yes"; $file[] = "START_MILTER=1"; $file[] = "installation_id={$generate_uuid}"; $file[] = "KSN_EULA_AGREED=yes"; $file[] = "POSTFIX_INTEGRATION_TYPE=milter"; $file[] = "POSTGRESQL_INSTALLED=YES"; @file_put_contents("/var/opt/kaspersky/klms/installer.dat", @implode("\n", $file)); echo "Starting......: " . date("H:i:s") . " Kaspersky Mail security Suite creating watchdog...\n"; watchdog(); echo "Starting......: " . date("H:i:s") . " Kaspersky Mail security Suite installation done...\n"; buildConf(); }