function verify_user($username) { global $conf_base_path, $is_control_node, $is_compute_node, $is_svn_node, $svn_node_addr, $users; $userdata = setup_paths($username); $server = $users[$username]['server']; if (is_local($server) && $is_compute_node) { // Is node server up? $nodeup = false; if (file_exists($userdata['node_watch'])) { $pid = trim(file_get_contents($userdata['node_watch'])); if (file_exists("/proc/{$pid}")) { $nodeup = true; } } // It isn't, restart if (!$nodeup) { if (file_exists($userdata['node_watch'])) { unlink($userdata['node_watch']); } // This command will apparently kill some node servers that it shouldn't? too dangerous //exec("ps ax | grep tmux | grep " . $userdata['esa'] . " | grep -v grep | cut -c 1-5 | xargs kill"); // Kill related processes stop_node($username, false); // Check to see if port is in use $log_path = "{$conf_base_path}/log/" . $userdata['efn']; $inuse = `tail -20 {$log_path} | grep EADDRINUSE`; if (!empty(trim($inuse))) { $port = find_free_port(); print "Found port: {$port}\n"; $users[$username]['port'] = $port; write_files(); if ($is_control_node) { write_nginx_config(); } } // Restart node print "Starting node for {$username}...\n"; start_node($username); } } else { if ($is_control_node) { $output = run_on($server, "{$conf_base_path}/bin/webidectl verify-user " . $userdata['esa']); if (strstr($output, "Found port:")) { $port = intval(substr($output, 11)); if (intval($port) == 0) { $port = 1; } $users[$username]['port'] = $port; write_files(); write_nginx_config(); } } } if ($is_svn_node) { // Is syncsvn up? $svnup = false; if (file_exists($userdata['svn_watch'])) { $pid = trim(file_get_contents($userdata['svn_watch'])); if (file_exists("/proc/{$pid}")) { $svnup = true; } } // It isn't, restart if (!$svnup) { if (file_exists($userdata['svn_watch'])) { unlink($userdata['svn_watch']); } stop_inotify($username); // New inotify will be started by syncsvn print "Starting syncsvn for {$username}...\n"; syncsvn($username); } } else { if ($is_control_node) { run_on($svn_node_addr, "{$conf_base_path}/bin/webidectl login " . $userdata['esa']); run_on($svn_node_addr, "{$conf_base_path}/bin/webidectl verify-user " . $userdata['esa']); } } }
$act = "Write GMdata " . $prauth[$ADMM][0] . " {$ADMM} "; logwrite($act); writeconfigtblsd(); dispref(); exit; } if ($write == cmsg("SYNC")) { sync(""); exit; } if ($write == cmsg("SYNC_ST")) { autoupdatecfgs($files); exit; } if ($write == cmsg("SVN_UPD")) { syncsvn(""); exit; } function sync($conf) { global $mirroraddress, $pr; //$mirroraddress="http://la2.chg.su/dbs4/_conf/"; $mirroraddress = $pr[96]; if (!$mirroraddress) { echo "Mirror not found"; exit; } lprint("SYNC_SEL"); echo "<br><form action=admin.php>"; // файлы к этому моменту уже должны быть сгенерированы и хотя бы быть в наличии $path = getcwd() . "/_conf/";