Example #1
0
function pdns_server(){
	$verbose=$GLOBALS["VERBOSE"];
	if(!$GLOBALS["CLASS_USERS"]->POWER_DNS_INSTALLED){if($verbose){echo "POWER_DNS_INSTALLED -> FALSE, return\n";}}
	
	
	if(!$GLOBALS["CLASS_USERS"]->POWER_DNS_INSTALLED){return null;}
	
	
	$enabled=1;
	$DisablePowerDnsManagement=$GLOBALS["CLASS_SOCKETS"]->GET_INFO("DisablePowerDnsManagement");
	
	
	$EnablePDNS=$GLOBALS["CLASS_SOCKETS"]->GET_INFO("EnablePDNS");
	$PDNSRestartIfUpToMB=$GLOBALS["CLASS_SOCKETS"]->GET_INFO("PDNSRestartIfUpToMB");
	if($DisablePowerDnsManagement==1){$enabled=0;}
	if(!is_numeric($EnablePDNS)){$EnablePDNS=1;}
	if(!is_numeric($PDNSRestartIfUpToMB)){$PDNSRestartIfUpToMB=700;}
	

	
	$pdns_server=$GLOBALS["CLASS_UNIX"]->find_program("pdns_server");
	
	if($verbose){echo "DisablePowerDnsManagement=$DisablePowerDnsManagement\n";}
	if($verbose){echo "EnablePDNS=$EnablePDNS\n";}
	if($verbose){echo "PDNSRestartIfUpToMB=$PDNSRestartIfUpToMB\n";}
	if($verbose){echo "pdns_server=$pdns_server\n";}
	
	if($pdns_server==null){
		if($verbose){echo "pdns_server no such binary\n";}
		return null;
	}
	
		$pid_path="/var/run/pdns/pdns.pid";
		$master_pid=trim(@file_get_contents($pid_path));
		if(!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)){
			$master_pid=$GLOBALS["CLASS_UNIX"]->PIDOF($pdns_server);
			if($master_pid<>null){@file_put_contents($pid_path,$master_pid);}
		}
		
		if($enabled==1){
			if($EnablePDNS==0){$enabled=0;}
		}
		$version=GetVersionOf("pdns");
		$GLOBALS["PDNS_VERSION"]=$version;
		if($verbose){echo "version=$version Enabled=$enabled\n";}
		
		$l[]="[APP_PDNS]";
		$l[]="service_name=APP_PDNS";
	 	$l[]="master_version=$version";
	 	$l[]="service_cmd=pdns";	
	 	$l[]="service_disabled=$enabled";
	 	$l[]="pid_path=$pid_path";
	 	$l[]="watchdog_features=1";
	 	$l[]="family=network";
	 	
	 	if($enabled==0){
	 		if($verbose){echo "-> pdns_instance()";}
	 		$instance=pdns_instance();
	 		return implode("\n",$l).$instance;
	 	}		 	
	 	
	 	
		if(!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)){
			if($verbose){echo "-> pid: [$master_pid] failed -> watchdog";}
			WATCHDOG("APP_PDNS","pdns");
			$l[]="running=0\ninstalled=1";$l[]="";return implode("\n",$l);
			return;
		}	
		$l[]="running=1";
		$l[]=GetMemoriesOf($master_pid);
		$l[]="";
	
	if($verbose){echo "-> pdns_instance()";}
	$instance=pdns_instance();
	return implode("\n",$l).$instance;return;		
	
}
Example #2
0
function pdns_server()
{
    $verbose = $GLOBALS["VERBOSE"];
    if (!$GLOBALS["CLASS_USERS"]->POWER_DNS_INSTALLED) {
        if ($verbose) {
            echo "POWER_DNS_INSTALLED -> FALSE, return\n";
        }
    }
    if (!$GLOBALS["CLASS_USERS"]->POWER_DNS_INSTALLED) {
        return null;
    }
    $enabled = 1;
    $DisablePowerDnsManagement = $GLOBALS["CLASS_SOCKETS"]->GET_INFO("DisablePowerDnsManagement");
    $EnablePDNS = $GLOBALS["CLASS_USERS"]->EnablePDNS();
    $PDNSRestartIfUpToMB = $GLOBALS["CLASS_SOCKETS"]->GET_INFO("PDNSRestartIfUpToMB");
    if ($DisablePowerDnsManagement == 1) {
        $enabled = 0;
    }
    if (!is_numeric($PDNSRestartIfUpToMB)) {
        $PDNSRestartIfUpToMB = 700;
    }
    $pdns_server = $GLOBALS["CLASS_UNIX"]->find_program("pdns_server");
    if ($pdns_server == null) {
        if ($verbose) {
            echo "pdns_server no such binary\n";
        }
        return null;
    }
    $pid_path = "/var/run/pdns/pdns.pid";
    $master_pid = trim(@file_get_contents($pid_path));
    if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) {
        $master_pid = $GLOBALS["CLASS_UNIX"]->PIDOF($pdns_server);
        if ($master_pid != null) {
            @file_put_contents($pid_path, $master_pid);
        }
    }
    if ($enabled == 1) {
        if ($EnablePDNS == 0) {
            $enabled = 0;
        }
    }
    $version = pdns_version();
    $GLOBALS["PDNS_VERSION"] = $version;
    if ($verbose) {
        echo "version={$version} Enabled={$enabled}\n";
    }
    $l[] = "[APP_PDNS]";
    $l[] = "service_name=APP_PDNS";
    $l[] = "master_version={$version}";
    $l[] = "service_cmd=/etc/init.d/pdns";
    $l[] = "service_disabled={$enabled}";
    $l[] = "pid_path={$pid_path}";
    $l[] = "watchdog_features=1";
    $l[] = "family=network";
    if ($enabled == 0) {
        if ($verbose) {
            echo "PNS is not enabled running next function -> pdns_instance()\n";
        }
        if ($GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) {
            if ($DisablePowerDnsManagement == 0) {
                shell_exec2("/etc/init.d/pdns stop >/dev/null 2>&1 &");
            }
        }
        $instance = pdns_instance();
        return implode("\n", $l) . $instance;
    }
    if ($verbose) {
        echo "Detected PID: {$master_pid} ->  check it...\n";
    }
    if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) {
        if (!$GLOBALS["DISABLE_WATCHDOG"]) {
            if ($verbose) {
                echo "-> pid: [{$master_pid}] failed -> watchdog";
            }
            shell_exec2("{$GLOBALS["nohup"]} /etc/init.d/pdns restart >/dev/null 2>&1 &");
        }
        $l[] = "running=0\ninstalled=1";
        $l[] = "";
        return implode("\n", $l);
        return;
    }
    if ($verbose) {
        echo "Detected PID: {$master_pid} ->  Seems to be running\n";
    }
    $l[] = "running=1";
    $l[] = GetMemoriesOf($master_pid);
    $l[] = "";
    if ($verbose) {
        echo "-> pdns_instance()";
    }
    $instance = pdns_instance();
    return implode("\n", $l) . $instance;
    return;
}