本文整理汇总了PHP中unix::THREAD_COMMAND_SET方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::THREAD_COMMAND_SET方法的具体用法?PHP unix::THREAD_COMMAND_SET怎么用?PHP unix::THREAD_COMMAND_SET使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unix
的用法示例。
在下文中一共展示了unix::THREAD_COMMAND_SET方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: amavis_reload
function amavis_reload(){
SPAMASSASSIN_V320();
PhishTag();
HitFreqsRuleTiming();
if(!is_file("/usr/local/sbin/amavisd")){return null;}
if(!is_file("/usr/local/etc/amavisd.conf")){return null;}
$amavis=new amavis();
$amavis->CheckDKIM();
$conf=$amavis->buildconf();
@file_put_contents("/usr/local/etc/amavisd.conf",$conf);
$unix=new unix();
$unix->THREAD_COMMAND_SET("/usr/share/artica-postfix/bin/artica-make APP_SPAMASSASSIN_RQ");
CheckSecuritiesFolders();
$unix->send_email_events("Amavis will be reloaded", "exec.spamassassin, ordered to reload amavis {$GLOBALS["CMDLINES"]}", "postfix");
$unix->THREAD_COMMAND_SET("/usr/local/sbin/amavisd -c /usr/local/etc/amavisd.conf reload");
}
示例2: launch_tests
function launch_tests()
{
$unix = new unix();
$php = $unix->LOCATE_PHP5_BIN();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
return;
}
if (system_is_overloaded(basename(__FILE__))) {
system_admin_events("Overloaded, aborting task...", __FUNCTION__, __FILE__, __LINE__, "system");
$unix->THREAD_COMMAND_SET("{$php} " . __FILE__);
return;
}
@file_put_contents($pidfile, getmypid());
$datafile = "/etc/artica-postfix/settings/Daemons/HdparmInfos";
writelogs("Testing hard drives ({$datafile})", __FUNCTION__, __FILE__, __LINE__);
$timenum = file_time_min($datafile);
if (is_file($datafile)) {
if (file_time_min($datafile) < 61) {
writelogs("{$timenum}Mn executed, waiting 60Mn", __FUNCTION__, __FILE__, __LINE__);
die;
}
}
if ($GLOBALS["FIND_HDPARM"] == null) {
writelogs("Unable to stat 'hdparm'", __FUNCTION__, __FILE__, __LINE__);
die;
}
$disks = GetDisks();
if (!is_array($disks)) {
return null;
}
while (list($index, $line) = each($disks)) {
unset($results);
exec("{$GLOBALS["FIND_HDPARM"]} -t {$index}", $results);
while (list($num, $line_result) = each($results)) {
if (preg_match("#=\\s+([0-9\\.]+)\\s+MB\\/sec\$#", $line_result, $re)) {
if (preg_match("#.+?\\/(.+)\$#", $index, $ri)) {
system_admin_events("{$ri[1]}:{$re[1]}MB/sec", __FUNCTION__, __FILE__, __LINE__, "system");
writelogs("testing disk {$ri[1]}:{$re[1]}MB/sec...", __FUNCTION__, __FILE__, __LINE__);
$array[$ri[1]] = $re[1];
}
}
}
}
@unlink($datafile);
@file_put_contents($datafile, base64_encode(serialize($array)));
if (!is_file($datafile)) {
writelogs("{$datafile} no such file or directory", __FUNCTION__, __FILE__, __LINE__);
}
}
示例3: export_rules
function export_rules(){
$unix=new unix();
if(!is_dir("/var/log/artica-postfix/iptaccount")){@mkdir("/var/log/artica-postfix/iptaccount",0644,true);}
$iptaccount=$unix->find_program("iptaccount");
if(!is_file($iptaccount)){
if($GLOBALS["VERBOSE"]){echo "iptaccount, no such file\n";}
return;
}
exec("$iptaccount -a 2>&1",$results);
while (list ($num, $ligne) = each ($results) ){
if(preg_match("#Found table.+?rule_([0-9]+)#",$ligne,$re)){
$time=time();
$rule=$re[1];
if($GLOBALS["VERBOSE"]){echo "Rule [{$re[1]}] ($time)\n";}
$filename="/var/log/artica-postfix/iptaccount/$time.$rule";
$cmd="$iptaccount -s -l rule_$rule -f >$filename 2>&1";
if($GLOBALS["VERBOSE"]){echo "$cmd\n";}
shell_exec($cmd);
}
}
$unix->THREAD_COMMAND_SET($unix->LOCATE_PHP5_BIN()." ".__FILE__." --import");
}
示例4: savenic
function savenic($NIC)
{
$unix = new unix();
$ipClass = new IP();
$ETH_IP = trim(@file_get_contents("/etc/artica-postfix/WIZARDIP_{$NIC}"));
$NETMASK = trim(@file_get_contents("/etc/artica-postfix/WIZARDMASK_{$NIC}"));
$GATEWAY = trim(@file_get_contents("/etc/artica-postfix/WIZARDGATEWAY_{$NIC}"));
if (!$ipClass->isIPAddress($ETH_IP)) {
echo "* * * * {$ETH_IP} * * * * WRONG !!!!\n";
@file_put_contents("/etc/artica-postfix/WIZARDRESULT_{$NIC}", 0);
return;
}
if (!$ipClass->isIPAddress($GATEWAY)) {
echo "* * * * {$GATEWAY} * * * * WRONG !!!!\n";
@file_put_contents("/etc/artica-postfix/WIZARDRESULT_{$NIC}", 0);
return;
}
$nics = new system_nic($NIC);
$nics->eth = $NIC;
$nics->IPADDR = $ETH_IP;
$nics->NETMASK = $NETMASK;
$nics->GATEWAY = $GATEWAY;
$nics->dhcp = 0;
$nics->metric = 1;
$nics->defaultroute = 1;
$nics->enabled = 1;
if (!$nics->SaveNic()) {
echo "* * * * MYSQL ERROR !!! * * * * WRONG !!!!\n";
@file_put_contents("/etc/artica-postfix/WIZARDRESULT_{$NIC}", 0);
return;
}
$php = $unix->LOCATE_PHP5_BIN();
$nohup = $unix->find_program("nohup");
$php5 = $php;
system("{$php5} " . dirname(__FILE__) . " /exec.virtuals-ip.php --build --force >/dev/null 2>&1");
echo "20%] Please Wait, apply network configuration....\n";
system("/etc/init.d/artica-ifup start");
echo "30%] Please Wait, restarting services....\n";
$unix->THREAD_COMMAND_SET("{$php5} /usr/share/artica-postfix/exec.postfix.maincf.php --reconfigure");
$unix->THREAD_COMMAND_SET("/usr/share/artica-postfix/bin/artica-install --reconfigure-cyrus");
system("{$nohup} /etc/init.d/artica-status reload >/dev/null 2>&1 &");
system("{$nohup} /etc/init.d/nginx restart >/dev/null 2>&1 &");
system("{$nohup} /etc/init.d/monit restart >/dev/null 2>&1 &");
echo "30%] Please Wait, Changing IP address to {$NIC}....\n";
$ifconfig = $unix->find_program("ifconfig");
system("{$ifconfig} {$NIC} down");
system("{$ifconfig} {$NIC} {$ETH_IP} netmask {$NETMASK} up");
system("/bin/ip route add 127.0.0.1 dev lo");
if ($GATEWAY != "0.0.0.0") {
echo "31%] Please Wait, Define default gateway to {$GATEWAY}....\n";
system("/sbin/route add {$GATEWAY} dev {$NIC}");
$route = $unix->find_program("route");
shell_exec("{$route} add -net 0.0.0.0 gw {$GATEWAY} dev {$NIC} metric 1");
}
echo "95%] Restarting Web Console\n";
system("/etc/init.d/artica-webconsole restart");
echo "100%] Configuration done.\n";
@file_put_contents("/etc/artica-postfix/WIZARDRESULT_{$NIC}", 1);
echo "###################################################\n";
echo "############ #############\n";
echo "############ SUCCESS #############\n";
echo "############ #############\n";
echo "###################################################\n\n\n\n";
}
示例5: repair_tables
function repair_tables()
{
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
$pid = @file_get_contents($pidfile);
$unix = new unix();
if ($unix->process_exists($pid, basename(__FILE__))) {
events_tail("Already executed pid {$pid}");
if ($GLOBALS["VERBOSE"]) {
echo "Already executed pid {$pid}\n";
}
return;
}
$files = $unix->DirFiles("/usr/share/artica-postfix/ressources/logs/categorize-tables");
$php5 = $unix->LOCATE_PHP5_BIN();
while (list($none, $tablename) = each($files)) {
$filePath = "/usr/share/artica-postfix/ressources/logs/categorize-tables/{$tablename}";
if (!is_file($filePath)) {
@unlink($filePath);
continue;
}
$ARRAY = unserialize(@file_get_contents($filePath));
if (!is_array($ARRAY)) {
@unlink($filePath);
continue;
}
$PID = $ARRAY["PID"];
$CUR = $ARRAY["CURRENT"];
$MAX = $ARRAY["MAX"];
if ($CUR == $MAX) {
@unlink($filePath);
continue;
}
if ($unix->process_exists($PID)) {
continue;
}
categorize_tables_events("Ask to schedule table Current:{$CUR}/{$MAX}", null, $tablename, 1);
$unix->THREAD_COMMAND_SET("{$php5} " . __FILE__ . " --table {$tablename}");
}
}
示例6: restart_monit
function restart_monit()
{
$unix = new unix();
$unix->THREAD_COMMAND_SET("/etc/init.d/artica-postfix restart monit");
writelogs_framework("{$cmd}", __FUNCTION__, __FILE__, __LINE__);
}
示例7: xtart
function xtart()
{
if (!isset($GLOBALS["ARTICALOGDIR"])) {
$GLOBALS["ARTICALOGDIR"] = @file_get_contents("/etc/artica-postfix/settings/Daemons/ArticaLogDir");
if ($GLOBALS["ARTICALOGDIR"] == null) {
$GLOBALS["ARTICALOGDIR"] = "/var/log/artica-postfix";
}
}
$unix = new unix();
$binfile = "/usr/share/artica-postfix/bin/seeker";
if (!is_file($binfile)) {
build_progress("{failed}", 110);
events("Unable to stat {$binfile}");
return;
}
$php = $unix->LOCATE_PHP5_BIN();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pidTime = "/etc/artica-postfix/pids/exec.seeker.php.xtart.time";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
events("Already process executed pid {$pid}");
return;
}
if (system_is_overloaded(basename(__FILE__))) {
events("Overloaded system, schedule it later", __LINE__);
$unix->THREAD_COMMAND_SET("{$php} " . __FILE__);
build_progress("{failed} Overloaded", 110);
return;
}
@file_put_contents($pidfile, getmypid());
$timefile = $unix->file_time_min($pidTime);
$DisksBenchs = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/DisksBenchs"));
$DisksBenchs = $DisksBenchs * 60;
if (!$GLOBALS["FORCE"]) {
if ($timefile < $DisksBenchs) {
events("{$timefile}mn, require at least {$DisksBenchs}mn", __LINE__);
return;
}
}
@unlink($pidTime);
@file_put_contents($pidTime, time());
build_progress("{scanning} {disks}", 10);
$fdisk = $unix->find_program("fdisk");
exec("{$fdisk} -l 2>&1", $results);
$DISKS = array();
while (list($index, $line) = each($results)) {
$line = trim($line);
if ($line == null) {
continue;
}
if (preg_match("#^(Disque|Disk)\\s+\\/([a-zA-Z0-9\\-\\_\\/\\.]+).*?:\\s+[0-9]+.*?(bytes|octets)#", $line, $re)) {
$DISKS["/" . $re[2]] = true;
}
}
if (count($DISKS) == 0) {
build_progress("{scanning} {disks} {failed}", 110);
events("Unable to detect disks");
$unix->ToSyslog("Unable to detect disks");
system_admin_events("Unable to detect disks\n" . @implode("\n", $results), __FUNCTION__, __FILE__, __LINE__, "system");
return;
}
$RUN = false;
while (list($disk, $line) = each($DISKS)) {
$results = array();
@chmod("{$binfile}", 0755);
$cmd = "{$binfile} \"" . trim($disk) . "\" 2>&1";
build_progress("{scanning} {$disk}", 60);
events("{$cmd}");
exec($cmd, $results);
while (list($index, $line) = each($results)) {
$line = trim($line);
echo "***: {$line}\n";
$md5 = md5("{$disk}" . time());
if ($line == null) {
continue;
}
if (!preg_match("#^Results:\\s+([0-9]+)\\s+seeks.*?,\\s+([0-9\\.]+)\\s+ms#", $line, $re)) {
continue;
}
$seeks = $re[1];
$ms = $re[2];
events("{$disk} {$seeks} seeks, {$ms} ms", __LINE__);
$array = array();
@mkdir("{$GLOBALS["ARTICALOGDIR"]}/seeker-queue", 0755, true);
$array["SEEKS"] = $seeks;
$array["DISK"] = $disk;
$array["MS"] = $ms;
$array["time"] = time();
$unix->ToSyslog("Bench disk {$disk} {$ms} ms for {$seeks} seeks");
events("{$GLOBALS["ARTICALOGDIR"]}/seeker-queue/{$md5}.ay", __LINE__);
@file_put_contents("{$GLOBALS["ARTICALOGDIR"]}/seeker-queue/{$md5}.ay", serialize($array));
$RUN = true;
break;
}
}
if ($RUN) {
$php = $unix->LOCATE_PHP5_BIN();
$nohup = $unix->find_program("nohup");
build_progress("{analyze}", 90);
$cmd = "{$php} " . dirname(__FILE__) . "/exec.syslog-engine.php --seeker";
//.........这里部分代码省略.........
示例8: RestartDedicatedServices
function RestartDedicatedServices($aspid = false)
{
$unix = new unix();
if ($aspid) {
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = @file_get_contents($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
echo "Starting......: " . date("H:i:s") . " RestartDedicatedServices already executed PID: {$pid} since {$time}Mn\n";
if ($time < 120) {
if (!$GLOBALS["FORCE"]) {
die;
}
}
unix_system_kill_force($pid);
}
@file_put_contents($pidfile, getmypid());
}
$nohup = $unix->find_program("nohup");
$php = $unix->LOCATE_PHP5_BIN();
$squidbin = $unix->LOCATE_SQUID_BIN();
$unix->THREAD_COMMAND_SET("{$php} /usr/share/artica-postfix/exec.web-community-filter.php --register");
events("Starting artica");
echo "Starting......: " . date("H:i:s") . " nightly builds starting artica...\n";
@file_put_contents("/usr/share/artica-postfix/download_progress", 45);
system("/etc/init.d/artica-postfix start");
echo "Starting......: " . date("H:i:s") . " nightly builds building init scripts\n";
@file_put_contents("/usr/share/artica-postfix/download_progress", 50);
system("{$php} /usr/share/artica-postfix/exec.initslapd.php --force >/dev/null 2>&1");
echo "Starting......: " . date("H:i:s") . " nightly builds updating network\n";
@file_put_contents("/usr/share/artica-postfix/download_progress", 55);
system("{$php} /usr/share/artica-postfix/exec.virtuals-ip.php >/dev/null 2>&1");
system("{$php} /usr/share/artica-postfix/exec.monit.php --build >/dev/null 2>&1");
echo "Starting......: " . date("H:i:s") . " nightly builds purge and clean....\n";
@file_put_contents("/usr/share/artica-postfix/download_progress", 60);
shell_exec("{$nohup} /etc/init.d/slapd start >/dev/null 2>&1 &");
shell_exec("{$nohup} /etc/init.d/artica-webconsole start >/dev/null 2>&1 &");
if (is_file("/etc/init.d/nginx")) {
shell_exec("{$nohup} /etc/init.d/nginx reload >/dev/null 2>&1 &");
}
shell_exec("{$nohup} /etc/init.d/auth-tail restart >/dev/null 2>&1 &");
shell_exec("{$nohup} /etc/init.d/artica-framework restart >/dev/null 2>&1 &");
shell_exec("{$nohup} /usr/share/artica-postfix/bin/process1 -perm >/dev/null 2>&1 &");
shell_exec("{$nohup} /usr/share/artica-postfix/bin/artica-make --empty-cache >/dev/null 2>&1 &");
shell_exec("{$nohup} /etc/init.d/monit restart >/dev/null 2>&1 &");
shell_exec("{$nohup} /etc/init.d/artica-status restart --force >/dev/null 2>&1 &");
shell_exec("{$nohup} {$php} /usr/share/artica-postfix/exec.squid.php --build-schedules >/dev/null 2>&1 &");
shell_exec("{$nohup} {$php} /usr/share/artica-postfix/exec.schedules.php --defaults >/dev/null 2>&1 &");
if (is_file($squidbin)) {
squid_admin_mysql(1, "Reconfiguring proxy service", null, __FILE__, __LINE__);
$cmd = "/etc/init.d/squid reload --script=" . basename(__FILE__) . " >/dev/null 2>&1 &";
shell_exec($cmd);
}
events("done");
@file_put_contents("/usr/share/artica-postfix/download_progress", 100);
echo "Starting......: " . date("H:i:s") . " Done you can close the screen....\n";
_artica_update_event(2, "RestartDedicatedServices(): finish", null, __FILE__, __LINE__);
}
示例9: build
function build()
{
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = @file_get_contents($pidfile);
$unix = new unix();
if ($unix->process_exists($pid)) {
echo "Starting......: " . date("H:i:s") . " Already process exists pid {$pid}\n";
return;
}
@file_put_contents($pidfile, getmypid());
$php = $unix->LOCATE_PHP5_BIN();
if (system_is_overloaded()) {
$unix->THREAD_COMMAND_SET("{$php} " . __FILE__ . " --build");
return;
}
patch_grub_default();
$sock = new sockets();
$q = new mysql();
$sql = "SELECT * FROM users_containers WHERE created=0 AND onerror=0";
$results = $q->QUERY_SQL($sql, "artica_backup");
$count = mysql_num_rows($results);
if (!$q->ok) {
echo "Starting......: " . date("H:i:s") . " users_containers {$q->mysql_error}\n";
return;
}
echo "Starting......: " . date("H:i:s") . " {$count} containers to build\n";
if ($count > 0) {
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
$directory = trim($ligne["directory"]);
$ID = $ligne["container_id"];
if ($directory == null) {
users_containers_error($ID, "No specified main directory...");
continue;
}
$directory_size_avai = $unix->DIRECTORY_FREEM($directory);
if ($directory_size_avai == 0) {
users_containers_error($ID, "no space left on specified directory");
continue;
}
@mkdir($directory, 0755, true);
if (!is_dir($directory)) {
users_containers_error($ID, "Permission denied on specified directory");
continue;
}
$ContainerFullPath = $directory . "/{$ID}.disk";
$size = $ligne["container_size"];
if ($size > $directory_size_avai) {
users_containers_error($ID, "{$size}MB will exceed space on main storage");
continue;
}
$label = "{$ID}_disk";
echo "Starting......: " . date("H:i:s") . " Verify {$ContainerFullPath} with a size of {$size}MB\n";
if (!stat_system($ContainerFullPath)) {
echo "Starting......: " . date("H:i:s") . " buil_dd {$ContainerFullPath} {$size}MB\n";
if (!build_dd($ContainerFullPath, $size)) {
users_containers_error($ID, "Unable to build the virtual disk (ERR." . __LINE__ . ")");
continue;
}
}
$GetLoops = GetLoops();
if (!stat_system($ContainerFullPath)) {
users_containers_error($ID, "Unable to build the virtual disk (ERR." . __LINE__ . ")");
continue;
}
if ($GetLoops[$ContainerFullPath] == null) {
echo "Starting......: " . date("H:i:s") . " {$ContainerFullPath} no such loop\n";
if (!build_loop($ContainerFullPath)) {
echo "`{$ContainerFullPath}` unable to create loop\n";
echo "Starting......: " . date("H:i:s") . " Re-check the loop list...\n";
$GetLoops = GetLoops();
if ($GetLoops[$ContainerFullPath] == null) {
users_containers_error($ID, "Loop error (ERR." . __LINE__ . ")");
continue;
}
}
}
echo "Starting......: " . date("H:i:s") . " {$ContainerFullPath} loop={$GetLoops[$ContainerFullPath]}\n";
$sql = "UPDATE users_containers SET loop_dev='{$GetLoops[$ContainerFullPath]}' WHERE `container_id`='{$ID}'";
$q->QUERY_SQL($sql, 'artica_backup');
if (!$q->ok) {
echo "{$q->mysql_error}\n";
continue;
}
$dev = $GetLoops[$ContainerFullPath];
echo "Starting......: " . date("H:i:s") . " {$ContainerFullPath} is {$dev}\n";
if (!ifFileSystem($dev)) {
if (!mke2fs($dev, $label)) {
users_containers_error($ID, "mke2fs error (ERR." . __LINE__ . ")");
continue;
}
}
$uuid = Getuuid($dev);
echo "Starting......: " . date("H:i:s") . " {$dev} uuid={$uuid}\n";
$q->QUERY_SQL("UPDATE users_containers SET uuid='{$uuid}' WHERE `container_id`='{$ID}'", 'artica_backup');
if ($uuid == null) {
continue;
}
$q->QUERY_SQL("UPDATE users_containers SET created='1' WHERE `container_id`='{$ID}'", 'artica_backup');
}
}
//.........这里部分代码省略.........
示例10: ipblocks
function ipblocks(){
if(system_is_overloaded()){return;}
include_once(dirname(__FILE__) . '/ressources/class.mysql.inc');
$unix=new unix();
$php=$unix->LOCATE_PHP5_BIN();
$nogup=$unix->find_program("nohup");
$pidfile="/etc/artica-postfix/pids/".basename(__FILE__).".".__FUNCTION__.".pid";
$pidtime="/etc/artica-postfix/pids/".basename(__FILE__).".".__FUNCTION__.".time";
$pid=@file_get_contents($pidfile);
if($unix->process_exists($pid)){echo "Already running pid $pid\n";return;}
$q=new mysql();
if(!$q->TABLE_EXISTS('ipblocks_db','artica_backup')){$q->BuildTables();}
if(!is_file($pidtime)){
$count=$q->COUNT_ROWS("ipblocks_db", "artica_backup");
if($count==0){shell_exec(trim("$nogup /usr/share/artica-postfix/bin/artica-update --ipblocks >/dev/null 2>&1 &"));}
sleep(5);
@file_put_contents($pidtime, time());
}
if($unix->file_time_min($pidtime)>480){
shell_exec(trim("$nogup /usr/share/artica-postfix/bin/artica-update --ipblocks >/dev/null 2>&1 &"));
sleep(5);
@unlink($pidtime);
@file_put_contents($pidtime, time());
$unix->THREAD_COMMAND_SET("$php /usr/share/artica-postfix/exec.postfix.iptables.php --ipdeny");
}
@file_put_contents($pidfile, getmypid());
foreach (glob("/var/log/artica-postfix/ipblocks/*.zone") as $filename) {
$basename=basename($filename);
if(!preg_match("#(.+?)\.zone#", $basename,$re)){continue;}
$country=$re[1];
$datas=explode("\n", @file_get_contents($filename));
$f=true;
while (list ($index, $line) = each ($datas) ){
$line=trim($line);if($line==null){continue;}if($country==null){continue;}
$sql="INSERT IGNORE INTO ipblocks_db (cdir,country) VALUES('$line','$country')";
$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){events("ipblocks:: $q->mysql_error line:".__LINE__);$f=false;break;}
}
if(!$f){continue;}
@unlink($filename);
}
$file_time="/etc/artica-postfix/pids/". basename(__FILE__).".".__FUNCTION__.".time";
if($unix->file_time_min($file_time)>300){
$sql="DELETE FROM loadavg WHERE stime < DATE_SUB( NOW( ) , INTERVAL 7 DAY )";
$q->QUERY_SQL($sql,"artica_events");
@unlink($file_time);
@file_put_contents($file_time, time());
}
}
示例11: restore
function restore()
{
$sock = new sockets();
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
if ($GLOBALS["VERBOSE"]) {
echo "PID: {$pidfile}\n";
}
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid)) {
$TTL = $unix->PROCESS_TTL($pid);
if ($TTL < 240) {
return;
}
$kill = $unix->find_program("kill");
unix_system_kill_force($pid);
}
@file_put_contents($pidfile, getmypid());
$hostname = $unix->hostname_g();
progress(10, "{mounting}");
if (!restore_TestNas()) {
system_admin_events("Mounting NAS filesystem report false", __FUNCTION__, __FILE__, __LINE__);
progress(100, "{failed}");
return;
}
$BackupArticaRestoreNASIpaddr = $sock->GET_INFO("BackupArticaRestoreNASIpaddr");
$BackupArticaRestoreNASFolder = $sock->GET_INFO("BackupArticaRestoreNASFolder");
$BackupArticaRestoreNASUser = $sock->GET_INFO("BackupArticaRestoreNASUser");
$BackupArticaRestoreNASPassword = $sock->GET_INFO("BackupArticaRestoreNASPassword");
$BackupArticaRestoreNASFolderSource = $sock->GET_INFO("BackupArticaRestoreNASFolderSource");
$BackupArticaRestoreNetwork = $sock->GET_INFO("BackupArticaRestoreNetwork");
$mountPoint = "/mnt/BackupArticaRestoreNAS";
$BackupArticaRestoreNASFolderSource = str_replace("\\", "/", $BackupArticaRestoreNASFolderSource);
$sourceDir = "{$mountPoint}/{$BackupArticaRestoreNASFolderSource}";
$sourceDir = str_replace("//", "/", $sourceDir);
if (!is_file("{$sourceDir}/BKVERSION.txt")) {
progress(100, "{failed} BKVERSION.txt no such file");
$mount = new mount("/var/log/artica-postfix/backup.debug");
if ($mount->ismounted($mountPoint)) {
$mount->umount($mountPoint);
}
return;
}
$time = trim(@file_get_contents("{$sourceDir}/BKVERSION.txt"));
progress(15, "{backup} " . date("Y-m-d H:i:s"));
progress(20, "{restoring_ldap_database}, {please_wait}...");
Restore_ldap($sourceDir);
progress(40, "{restoring_artica_settings}, {please_wait}...");
restore_artica_settings($sourceDir);
progress(50, "{restoring_artica_databases}, {please_wait}...");
restore_artica_backup($sourceDir);
progress(60, "{restoring_artica_databases}, {please_wait}...");
restore_ocsweb($sourceDir);
progress(80, "{restoring_artica_databases}, {please_wait}...");
restore_squidlogs($sourceDir);
progress(82, "{restoring} PowerDNS, {please_wait}...");
restore_powerdns($sourceDir);
progress(90, "{reconfigure_server}, {please_wait}...");
$squidbin = $unix->LOCATE_SQUID_BIN();
$php = $unix->LOCATE_PHP5_BIN();
if (is_file($squidbin)) {
shell_exec("{$php} /usr/share/artica-postfix/exec.squid.php --build --force");
}
progress(100, "{success}");
$mount = new mount("/var/log/artica-postfix/backup.debug");
if ($mount->ismounted($mountPoint)) {
$mount->umount($mountPoint);
}
if ($BackupArticaRestoreNetwork == 1) {
$unix->THREAD_COMMAND_SET("{$php} /usr/share/artica-postfix/exec.virtuals-ip.php --build");
}
return;
}
示例12: changemysqldir
function changemysqldir($dir)
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/squiddbstart.pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Already task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
initd();
$dirCMD = $unix->shellEscapeChars($dir);
if ($dir == "/opt/squidsql/data") {
return;
}
@mkdir($dir, 0755, true);
echo "Stopping Squid-db";
shell_exec("/etc/init.d/squid-db stop");
$Size = $unix->DIRSIZE_BYTES("/opt/squidsql/data");
echo "Copy /home/zarafa-db content to next dir size={$Size}";
$cp = $unix->find_program("cp");
$rm = $unix->find_program("rm");
$ln = $unix->find_program("ln");
shell_exec("{$cp} -rf /opt/squidsql/data/* {$dirCMD}/");
$Size2 = $unix->DIRSIZE_BYTES($dir);
if ($Size2 < $Size) {
echo "Copy error {$Size2} is less than original size ({$Size})\n";
}
echo "Removing old data\n";
shell_exec("{$rm} -rf /opt/squidsql/data");
echo "Create a new symbolic link...\n";
shell_exec("{$ln} -s {$dirCMD} /opt/squidsql/data");
echo "Starting MySQL database engine...\n";
shell_exec("/etc/init.d/squid-db start");
$unix->THREAD_COMMAND_SET($unix->LOCATE_PHP5_BIN() . " " . __FILE__ . " --databasesize");
}
示例13: clients
//.........这里部分代码省略.........
$iscsiadm = $unix->find_program("iscsiadm");
if (!is_file($iscsiadm)) {
if ($GLOBALS["VERBOSE"]) {
echo "{$GLOBALS["deflog_start"]} iscsiadm no such file\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
$f[] = "node.startup = automatic";
$f[] = "#node.session.auth.authmethod = CHAP";
$f[] = "#node.session.auth.username = username";
$f[] = "#node.session.auth.password = password";
$f[] = "#node.session.auth.username_in = username_in";
$f[] = "#node.session.auth.password_in = password_in";
$f[] = "#discovery.sendtargets.auth.authmethod = CHAP";
$f[] = "#discovery.sendtargets.auth.username = username";
$f[] = "#discovery.sendtargets.auth.password = password";
$f[] = "#discovery.sendtargets.auth.username_in = username_in";
$f[] = "#discovery.sendtargets.auth.password_in = password_in";
$f[] = "node.session.timeo.replacement_timeout = 120";
$f[] = "node.conn[0].timeo.login_timeout = 15";
$f[] = "node.conn[0].timeo.logout_timeout = 15";
$f[] = "node.conn[0].timeo.noop_out_interval = 10";
$f[] = "node.conn[0].timeo.noop_out_timeout = 15";
$f[] = "node.session.initial_login_retry_max = 4";
$f[] = "#node.session.iscsi.InitialR2T = Yes";
$f[] = "node.session.iscsi.InitialR2T = No";
$f[] = "#node.session.iscsi.ImmediateData = No";
$f[] = "node.session.iscsi.ImmediateData = Yes";
$f[] = "node.session.iscsi.FirstBurstLength = 262144";
$f[] = "node.session.iscsi.MaxBurstLength = 16776192";
$f[] = "node.conn[0].iscsi.MaxRecvDataSegmentLength = 131072";
$f[] = "discovery.sendtargets.iscsi.MaxRecvDataSegmentLength = 32768";
$f[] = "#node.conn[0].iscsi.HeaderDigest = CRC32C,None";
$f[] = "#node.conn[0].iscsi.DataDigest = CRC32C,None";
$f[] = "#node.conn[0].iscsi.HeaderDigest = None,CRC32C";
$f[] = "#node.conn[0].iscsi.DataDigest = None,CRC32C";
$f[] = "#node.conn[0].iscsi.HeaderDigest = CRC32C";
$f[] = "#node.conn[0].iscsi.DataDigest = CRC32C";
$f[] = "#node.conn[0].iscsi.HeaderDigest = None";
$f[] = "#node.conn[0].iscsi.DataDigest = None";
$f[] = "";
@file_put_contents("/etc/iscsi/iscsid.conf", @implode("\n", $f));
$sql = "SELECT * FROM iscsi_client";
if ($GLOBALS["VERBOSE"]) {
echo "{$GLOBALS["deflog_start"]} iscsiadm {$sql}\n";
}
$q = new mysql();
$results = $q->QUERY_SQL($sql, 'artica_backup');
if (!$q->ok) {
echo "{$GLOBALS["deflog_start"]} iscsiadm {$q->mysql_error}\n";
return;
}
if (mysql_num_rows($results) == 0) {
echo "{$GLOBALS["deflog_start"]} iscsiadm no iSCSI disk connection scheduled\n";
return;
}
if (!$q->ok) {
if ($GLOBALS["VERBOSE"]) {
echo "{$GLOBALS["deflog_start"]} {$q->mysql_error}\n";
}
return;
}
while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
$subarray2 = unserialize(base64_decode($ligne["Params"]));
$iqn = "{$subarray2["ISCSI"]}:{$subarray2["FOLDER"]}";
$port = $subarray2["PORT"];
$ip = $subarray2["IP"];
echo "{$GLOBALS["deflog_start"]} {$iqn} -> {$ip}:{$port} Auth:{$ligne["EnableAuth"]} Persistane:{$ligne["Persistante"]}\n";
if ($ligne["EnableAuth"] == 1) {
$cmds[] = "{$iscsiadm} -m node --targetname {$iqn} -p {$ip}:{$port} -o update -n node.session.auth.username -v \"{$ligne["username"]}\" 2>&1";
$cmds[] = "{$iscsiadm} -m node --targetname {$iqn} -p {$ip}:{$port} -o update -n node.session.auth.password -v \"{$ligne["password"]}\" 2>&1";
} else {
$cmds[] = "{$iscsiadm} -m node --targetname {$iqn} -p {$ip}:{$port} --login 2>&1";
}
if ($ligne["Persistante"] == 1) {
$cmds[] = "{$iscsiadm} -m node --targetname {$iqn} -p {$ip}:{$port} -o update -n node.startup -v automatic 2>&1";
} else {
$cmds[] = "{$iscsiadm} -m node --targetname {$iqn} -p {$ip}:{$port} -o update -n node.startup -v manual 2>&1";
}
$cmds[] = "{$iscsiadm} -m node --logoutall all 2>&1";
}
if (is_array($cmds)) {
while (list($num, $line) = each($cmds)) {
if ($GLOBALS["VERBOSE"]) {
echo "--------------------------\n{$line}\n";
}
$results = array();
exec($line, $results);
if ($GLOBALS["VERBOSE"]) {
@implode("\n", $results);
}
}
}
if ($GLOBALS["VERBOSE"]) {
echo "--------------------------\n{$iscsiadm} -m node --loginall all\n";
}
shell_exec("{$iscsiadm} -m node --loginall all");
$unix->THREAD_COMMAND_SET("/usr/share/artica-postfix/bin/artica-install --usb-scan-write");
}
示例14: reconfigure
function reconfigure(){
if($GLOBALS["VERBOSE"]){writelogs("starting reconfigure()",__FUNCTION__,__FILE__,__LINE__);}
$unix=new unix();
$sock=new sockets();
if($GLOBALS["VERBOSE"]){writelogs("->clladp()",__FUNCTION__,__FILE__,__LINE__);}
$ldap=new clladp();
$smbpasswd=$unix->find_program("smbpasswd");
if($GLOBALS["VERBOSE"]){writelogs("smbpasswd=$smbpasswd -->samba()",__FUNCTION__,__FILE__,__LINE__);}
$samba=new samba();
$net=$unix->LOCATE_NET_BIN_PATH();
$ldap_passwd=$ldap->ldap_password;
$EnableSambaActiveDirectory=$sock->GET_INFO("EnableSambaActiveDirectory");
$EnableSambaRemoteLDAP=$sock->GET_INFO("EnableSambaRemoteLDAP");
if($EnableSambaRemoteLDAP==1){
$SambaRemoteLDAPInfos=unserialize(base64_decode($sock->GET_INFO("SambaRemoteLDAPInfos")));
$ldap_passwd=$SambaRemoteLDAPInfos["user_dn_password"];
}
if($EnableSambaActiveDirectory==1){activedirectory();}
CheckFilesAndDirectories();
FixsambaDomainName();
echo "Starting......: Samba building main configuration...\n";
@file_put_contents("/etc/samba/smb.conf",$samba->BuildConfig());
shell_exec("$smbpasswd -w $ldap_passwd");
SambaAudit();
fixEtcHosts();
$master_password=$samba->GetAdminPassword("administrator");
$SambaEnableEditPosixExtension=$sock->GET_INFO("SambaEnableEditPosixExtension");
if($SambaEnableEditPosixExtension==1){
$cmd="$net idmap secret {$samba->main_array["global"]["workgroup"]} \"$ldap_passwd\" >/dev/null 2>&1 &";
shell_exec($cmd);
$cmd="$net idmap secret alloc \"$ldap_passwd\" >/dev/null 2>&1 &";
shell_exec($cmd);
}
if($EnableSambaActiveDirectory==1){kinit();}
$unix->THREAD_COMMAND_SET(LOCATE_PHP5_BIN2()." ".__FILE__." --check-dirs");
$unix->THREAD_COMMAND_SET("/usr/share/artica-postfix/bin/artica-install --samba-reconfigure");
reload();
}
示例15: start
//.........这里部分代码省略.........
$MailArchiverToMySQL = $sock->GET_INFO("MailArchiverToMySQL");
$MailArchiverToMailBox = $sock->GET_INFO("MailArchiverToMailBox");
$MailArchiverMailBox = $sock->GET_INFO("MailArchiverMailBox");
$MailArchiverUsePerl = $sock->GET_INFO("MailArchiverUsePerl");
if (!is_numeric($MailArchiverEnabled)) {
$MailArchiverEnabled = 0;
}
if (!is_numeric($MailArchiverToMySQL)) {
$MailArchiverToMySQL = 1;
}
if (!is_numeric($MailArchiverUsePerl)) {
$MailArchiverUsePerl = 1;
}
if ($GLOBALS["VERBOSE"]) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: VERBOSE MODE\n";
}
}
if ($MailArchiverEnabled == 0) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Mail Archiver is disabled...\n";
}
return;
}
if ($MailArchiverUsePerl == 0) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Mail Archiver (Perl method) is disabled...\n";
}
return;
}
$pid = mailarchive_pid();
if ($unix->process_exists($pid)) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Mail Archiver (Perl method) already running pid {$pid} since {$time}mn...\n";
}
return;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Mail Archiver (Perl method)...\n";
}
$usersMenus = new usersMenus();
$OS = $usersMenus->LinuxDistriCode;
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Mail Archiver (Perl method) on {$OS}...\n";
}
if ($OS == "DEBIAN" or $OS == "UBUNTU") {
CheckPerlDebian();
}
$mhonarc = $unix->find_program("mhonarc");
if (!is_file($mhonarc)) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Mail Archiver (Perl method) failed mhonarc not such binary !!!\n";
}
return;
}
$nohup = $unix->find_program("nohup");
@mkdir("/var/spool/mail-rtt-backup", 0755, true);
@mkdir("/var/run/maildump", 0777, true);
@unlink("/var/run/maildump/maildump.socket");
$cmd = "{$nohup} /usr/share/artica-postfix/bin/milter_archiver.pl >/dev/null 2>&1 &";
shell_exec($cmd);
for ($i = 0; $i < 5; $i++) {
sleep(1);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Mail Archiver (Perl method) waiting {$i}/5...\n";
}
$pid = mailarchive_pid();
if ($unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Mail Archiver (Perl method) Success running with pid {$pid}...\n";
}
break;
}
}
$pid = mailarchive_pid();
if ($unix->process_exists($pid)) {
for ($i = 0; $i < 5; $i++) {
if ($unix->is_socket("/var/run/maildump/maildump.socket")) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Mail Archiver permission on maildump.socket done\n";
}
@chmod("/var/run/maildump/maildump.socket", 0777);
break;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Mail Archiver waiting socket {$i}/5...\n";
}
sleep(1);
}
$unix->THREAD_COMMAND_SET("/etc/init.d/artica-status restart --force");
} else {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Mail Archiver (Perl method) failed to start..\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$cmd}\n";
}
}
}