<?

// NC1
$dyndns			= trim(exec('sudo nas-service get_ddns enabled'));
$dyndns_user_file 	= trim(exec('sudo nas-service get_ddns username'));
$dyndns_pass_file 	= trim(exec('sudo nas-service get_ddns password'));
$myip			= trim(exec('sudo nas-service get_ddns registered_ip'));
$mydomain		= trim(exec('sudo nas-service get_ddns alias'));
$confirm_ip		= trim(exec('sudo nas-service get_ddns confirm_ip'));

// NS1
/*
$dyndns			= trim(exec('sudo grep dyndns= /etc/sss_script/services/service.conf | cut -d "=" -f 2'));
$dyndns_user_file 	= trim(exec('sudo grep username /etc/ddnscli.conf | cut -d " " -f2'));
$dyndns_pass_file 	= trim(exec('sudo grep password /etc/ddnscli.conf | cut -d " " -f2'));
$myip			= trim(exec('sudo wget -q -O - http://ns.lgnas.com | cut -d " " -f 6 | cut -d "<" -f 0'));
$mydomain		= trim(exec('sudo grep alias /etc/ddnscli.conf | cut -d " " -f 2'));
$confirm_ip		= trim(exec("sudo dig +time=1 +tries=1 $mydomain | grep $mydomain | tail -1 | awk '{print $5}'"));
*/

//echo $myip.":".$confirm_ip;

if ($dyndns=='on') {
	if ($myip==$confirm_ip && $confirm_ip != '' ) $status = "OK";
		else $status="NG";
} else $status="STOP";

echo "$dyndns:$dyndns_user_file:$dyndns_pass_file:$mydomain:$confirm_ip:$status";
?>
