本文整理汇总了PHP中unix::MOUNTED_TMPFS_MEM方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::MOUNTED_TMPFS_MEM方法的具体用法?PHP unix::MOUNTED_TMPFS_MEM怎么用?PHP unix::MOUNTED_TMPFS_MEM使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unix
的用法示例。
在下文中一共展示了unix::MOUNTED_TMPFS_MEM方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ufdbdatabases_in_mem
function ufdbdatabases_in_mem()
{
$sock = new sockets();
$unix = new unix();
$UfdbDatabasesInMemory = $sock->GET_INFO("UfdbDatabasesInMemory");
if (!is_numeric($UfdbDatabasesInMemory)) {
$UfdbDatabasesInMemory = 0;
}
if ($UfdbDatabasesInMemory == 0) {
echo "Starting URLfilterDB Database in memory feature is disabled\n";
$MOUNTED_DIR_MEM = $unix->MOUNTED_TMPFS_MEM("/var/lib/ufdbguard-memory");
if ($MOUNTED_DIR_MEM > 0) {
echo "Starting URLfilterDB Database unmounting...\n";
$umount = $unix->find_program("umount");
shell_exec("{$umount} -l /var/lib/ufdbguard-memory");
}
return;
}
$POSSIBLEDIRS[] = "/var/lib/ufdbartica";
$POSSIBLEDIRS[] = "/var/lib/squidguard";
$POSSIBLEDIRS[] = "/var/lib/ftpunivtlse1fr";
$ufdbartica_size = $unix->DIRSIZE_BYTES("/var/lib/ufdbartica");
$ufdbartica_size = round($ufdbartica_size / 1024 / 1000) + 5;
$squidguard_size = $unix->DIRSIZE_BYTES("/var/lib/squidguard");
$squidguard_size = round($squidguard_size / 1024 / 1000) + 5;
$ftpunivtlse1fr_size = $unix->DIRSIZE_BYTES("/var/lib/ftpunivtlse1fr");
$ftpunivtlse1fr_size = round($ftpunivtlse1fr_size / 1024 / 1000) + 5;
echo "Starting URLfilterDB ufdbartica DB....: about {$ufdbartica_size}MB\n";
echo "Starting URLfilterDB squidguard DB....: about {$squidguard_size}MB\n";
echo "Starting URLfilterDB ftpunivtlse1fr DB: about {$ftpunivtlse1fr_size}MB\n";
$total = $ufdbartica_size + $squidguard_size + $ftpunivtlse1fr_size + 10;
echo "Starting URLfilterDB require {$total}MB\n";
$mount = $unix->find_program("mount");
$MOUNTED_DIR_MEM = $unix->MOUNTED_TMPFS_MEM("/var/lib/ufdbguard-memory");
if ($MOUNTED_DIR_MEM == 0) {
$system_mem = $unix->TOTAL_MEMORY_MB();
echo "Starting URLfilterDB system memory {$system_mem}MB\n";
if ($system_mem < $total) {
$require = $total - $system_mem;
echo "Starting URLfilterDB not engough memory require at least {$require}MB\n";
return;
}
$system_free = $unix->TOTAL_MEMORY_MB_FREE();
echo "Starting URLfilterDB system memory available {$system_free}MB\n";
if ($system_free < $total) {
$require = $total - $system_free;
echo "Starting URLfilterDB not engough memory require at least {$require}MB\n";
return;
}
}
$idbin = $unix->find_program("id");
$mount = $unix->find_program("mount");
$umount = $unix->find_program("umount");
$rm = $unix->find_program("rm");
$cp = $unix->find_program("cp");
$chown = $unix->find_program("chown");
if ($MOUNTED_DIR_MEM > 0) {
if ($MOUNTED_DIR_MEM < $total) {
echo "Starting URLfilterDB: umounting from memory\n";
shell_exec("{$umount} -l /var/lib/ufdbguard-memory");
$MOUNTED_DIR_MEM = $unix->MOUNTED_TMPFS_MEM("/var/lib/ufdbguard-memory");
}
}
if ($MOUNTED_DIR_MEM == 0) {
if (strlen($idbin) < 3) {
echo "Starting URLfilterDB: tmpfs `id` no such binary\n";
return;
}
if (strlen($mount) < 3) {
echo "Starting URLfilterDB: tmpfs `mount` no such binary\n";
return;
}
exec("{$idbin} squid 2>&1", $results);
if (!preg_match("#uid=([0-9]+).*?gid=([0-9]+)#", @implode("", $results), $re)) {
echo "Starting......: " . date("H:i:s") . "MySQL mysql no such user...\n";
return;
}
$uid = $re[1];
$gid = $re[2];
echo "Starting URLfilterDB: tmpfs uid/gid ={$uid}:{$gid} for {$total}M\n";
@mkdir("/var/lib/ufdbguard-memory");
$cmd = "{$mount} -t tmpfs -o rw,uid={$uid},gid={$gid},size={$total}M,nr_inodes=10k,mode=0700 tmpfs \"/var/lib/ufdbguard-memory\"";
shell_exec($cmd);
$MOUNTED_DIR_MEM = $unix->MOUNTED_TMPFS_MEM("/var/lib/ufdbguard-memory");
if ($MOUNTED_DIR_MEM == 0) {
echo "Starting URLfilterDB: tmpfs failed...\n";
return;
}
}
echo "Starting URLfilterDB: mounted as {$MOUNTED_DIR_MEM}MB\n";
reset($POSSIBLEDIRS);
while (list($index, $directory) = each($POSSIBLEDIRS)) {
$directoryname = basename($directory);
@mkdir("/var/lib/ufdbguard-memory/{$directoryname}", 0755, true);
if (!is_dir("/var/lib/ufdbguard-memory/{$directoryname}")) {
echo "Starting URLfilterDB: {$directoryname} permission denied\n";
return;
}
@chown("/var/lib/ufdbguard-memory/{$directoryname}", "squid");
echo "Starting URLfilterDB: replicating {$directoryname}\n";
//.........这里部分代码省略.........
示例2: _start_instance
function _start_instance($hostname)
{
if ($hostname == "master") {
return;
}
if (trim($hostname) == null) {
return;
}
$unix = new unix();
$main = new maincf_multi($hostname);
$PostFixEnableQueueInMemory = $main->GET("PostFixEnableQueueInMemory");
$PostFixQueueInMemory = $main->GET("PostFixQueueInMemory");
$ifconfig = $unix->find_program("ifconfig");
$ln = $unix->find_program("ln");
$route = $unix->find_program("route");
$directory = "/var/spool/postfix-{$hostname}";
$postfixbin = $unix->find_program("postfix");
if ($PostFixEnableQueueInMemory == 1) {
reconfigure_instance_tmpfs($hostname, $PostFixQueueInMemory);
} else {
$MOUNTED_TMPFS_MEM = $unix->MOUNTED_TMPFS_MEM($directory);
if ($MOUNTED_TMPFS_MEM > 0) {
reconfigure_instance_tmpfs_umount($hostname);
}
}
if (!is_file("/etc/postfix-{$hostname}/main.cf")) {
echo "Starting......: " . date("H:i:s") . " Postfix \"{$hostname}\" /etc/postfix-{$hostname}/main.cf no such file (reconfigure)\n";
ConfigureMainCF($hostname, true);
}
$pidfile = "/var/spool/postfix-{$hostname}/pid/master.pid";
if ($GLOBALS["postmulti"] == null) {
$GLOBALS["postmulti"] = $unix->find_program("postmulti");
}
$pid = $unix->get_pid_from_file($pidfile);
writelogs("{$hostname}:: Checking directories IP address={$main->ip_addr}", __FUNCTION__, __FILE__, __LINE__);
$q = new mysql();
$sql = "SELECT * FROM nics_virtuals WHERE ipaddr='{$main->ip_addr}'";
$ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
echo "Starting......: " . date("H:i:s") . " Postfix \"{$hostname}\" {$main->ip_addr} on {$ligne["nic"]}:{$ligne["ID"]}\n";
if ($ligne["ipv6"] == 0) {
if ($ligne["ID"] > 0) {
shell_exec("{$ifconfig} {$ligne["nic"]}:{$ligne["ID"]} {$main->ip_addr} >/dev/null 2>&1");
shell_exec("{$route} add -host {$main->ip_addr} dev {$ligne["nic"]}:{$ligne["ID"]} >/dev/null 2>&1");
}
}
$main->CheckDirectories($hostname);
writelogs("{$hostname}:: {$pidfile}={$pid}", __FUNCTION__, __FILE__, __LINE__);
if ($unix->process_exists($pid)) {
echo "Starting......: " . date("H:i:s") . " Postfix \"{$hostname}\" reloading\n";
writelogs("{$hostname}::reloading postfix {$GLOBALS["postmulti"]} -i postfix-{$hostname} -p reload", __FUNCTION__, __FILE__, __LINE__);
exec("{$GLOBALS["postmulti"]} -i postfix-{$hostname} -p reload 2>&1", $results);
while (list($num, $line) = each($results)) {
if (preg_match("#unused parameter#", $line)) {
continue;
}
writelogs("{$line}", __FUNCTION__, __FILE__, __LINE__);
echo "Starting......: " . date("H:i:s") . " Postfix \"{$hostname}\" {$line}\n";
if (preg_match("#fatal: open /etc/postfix-(.+?)\\/main\\.cf#", $line, $re)) {
echo "Starting......: " . date("H:i:s") . " Postfix reconfigure \"{$re[1]}\"\n";
reconfigure_instance($re[1]);
}
}
return;
}
echo "Starting......: " . date("H:i:s") . " Postfix starting \"{$hostname}\"\n";
writelogs("{$hostname}::Starting postfix {$GLOBALS["postmulti"]} -i postfix-{$hostname} -p start", __FUNCTION__, __FILE__, __LINE__);
exec("{$GLOBALS["postmulti"]} -i postfix-{$hostname} -p start 2>&1", $results);
writelogs("{$hostname}::Starting LOG=" . count($results) . " lines", __FUNCTION__, __FILE__, __LINE__);
while (list($num, $line) = each($results)) {
if (preg_match("#unused parameter:#", $line)) {
continue;
}
writelogs("{$line}", __FUNCTION__, __FILE__, __LINE__);
echo "Starting......: " . date("H:i:s") . " Postfix \"{$hostname}\" {$line}\n";
if (preg_match("#fatal: open /etc/postfix-(.+?)\\/main\\.cf#", $line, $re)) {
echo "Starting......: " . date("H:i:s") . " Postfix reconfigure \"{$re[1]}\"\n";
reconfigure_instance($re[1]);
}
}
$pid = $unix->get_pid_from_file($pidfile);
for ($i = 0; $i < 10; $i++) {
if ($GLOBALS["VERBOSE"]) {
echo "Starting......: " . date("H:i:s") . " Postfix \"{$hostname}\" DEBUG open \"{$pidfile}\"\n";
}
if ($unix->process_exists($pid)) {
break;
}
echo "Starting......: " . date("H:i:s") . " Postfix \"{$hostname}\" waiting run ({$pid})\n";
sleep(1);
$pid = $unix->get_pid_from_file($pidfile);
}
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid)) {
echo "Starting......: " . date("H:i:s") . " Postfix \"{$hostname}\" SUCCESS with PID={$pid}\n";
writelogs("{$hostname}::DONE", __FUNCTION__, __FILE__, __LINE__);
return;
}
echo "Starting......: " . date("H:i:s") . " Postfix \"{$hostname}\" FAILED\n";
writelogs("{$hostname}::FAILED", __FUNCTION__, __FILE__, __LINE__);
}
示例3: _start_instance
function _start_instance($hostname){
if($hostname=="master"){return;}
if(trim($hostname)==null){return;}
$unix=new unix();
$main=new maincf_multi($hostname);
$PostFixEnableQueueInMemory=$main->GET("PostFixEnableQueueInMemory");
$PostFixQueueInMemory=$main->GET("PostFixQueueInMemory");
$directory="/var/spool/postfix-$hostname";
if($PostFixEnableQueueInMemory==1){
reconfigure_instance_tmpfs($hostname,$PostFixQueueInMemory);
}else{
$MOUNTED_TMPFS_MEM=$unix->MOUNTED_TMPFS_MEM($directory);
if($MOUNTED_TMPFS_MEM>0){
reconfigure_instance_tmpfs_umount($hostname);
}
}
$pidfile="/var/spool/postfix-$hostname/pid/master.pid";
if($GLOBALS["postmulti"]==null){$GLOBALS["postmulti"]=$unix->find_program("postmulti");}
$pid=$unix->get_pid_from_file($pidfile);
writelogs("$hostname:: Checking directories",__FUNCTION__,__FILE__,__LINE__);
$main->CheckDirectories($hostname);
writelogs("$hostname:: $pidfile=$pid",__FUNCTION__,__FILE__,__LINE__);
if($unix->process_exists($pid)){
echo "Starting......: Postfix \"$hostname\" reloading\n";
writelogs("$hostname::reloading postfix {$GLOBALS["postmulti"]} -i postfix-$hostname -p reload",__FUNCTION__,__FILE__,__LINE__);
exec("{$GLOBALS["postmulti"]} -i postfix-$hostname -p reload 2>&1",$results);
while (list ($num, $line) = each ($results) ){
writelogs("$line",__FUNCTION__,__FILE__,__LINE__);
echo "Starting......: Postfix \"$hostname\" $line\n";
if(preg_match("#fatal: open /etc/postfix-(.+?)\/main\.cf#",$line,$re)){
echo "Starting......: Postfix reconfigure \"{$re[1]}\"\n";
reconfigure_instance($re[1]);
}
}
return;
}
echo "Starting......: Postfix starting \"$hostname\"\n";
writelogs("$hostname::Starting postfix {$GLOBALS["postmulti"]} -i postfix-$hostname -p start",__FUNCTION__,__FILE__,__LINE__);
exec("{$GLOBALS["postmulti"]} -i postfix-$hostname -p start 2>&1",$results);
writelogs("$hostname::Starting LOG=".count($results)." lines",__FUNCTION__,__FILE__,__LINE__);
while (list ($num, $line) = each ($results) ){
writelogs("$line",__FUNCTION__,__FILE__,__LINE__);
echo "Starting......: Postfix \"$hostname\" $line\n";
if(preg_match("#fatal: open /etc/postfix-(.+?)\/main\.cf#",$line,$re)){
echo "Starting......: Postfix reconfigure \"{$re[1]}\"\n";
reconfigure_instance($re[1]);
}
}
$pid=$unix->get_pid_from_file($pidfile);
for($i=0;$i<10;$i++){
if($unix->process_exists($pid)){break;}
echo "Starting......: Postfix \"$hostname\" waiting run ($pid)\n";
sleep(1);
}
if($unix->process_exists($pid)){
echo "Starting......: Postfix \"$hostname\" SUCCESS with PID=$pid\n";
writelogs("$hostname::DONE",__FUNCTION__,__FILE__,__LINE__);
return;
}
echo "Starting......: Postfix \"$hostname\" FAILED\n";
writelogs("$hostname::FAILED",__FUNCTION__,__FILE__,__LINE__);
}