View Single Post
  #6  
Old 12th October 2012, 00:31
SuperJC SuperJC is offline
Junior Member
 
Join Date: Oct 2012
Posts: 9
Thanks: 2
Thanked 3 Times in 2 Posts
Lightbulb

Quote:
Originally Posted by till View Post
You can do this with the datalogUpdate function of the db_mysql.inc.php script. It executes the sql query and creates the nescessary information for the datalog.
Quote:
Originally Posted by SuperJC View Post
...That was the function I had my eye on! Now I just have to figure out how to use it. I think I have some ideas, so we'll see how it goes!...
Piecing together information I found in various posts on this forum, I think I was able to figure it out. Here's the script I worked up. It probably could be refined, and I'm open to suggestions & improvements!

Code:
#!/bin/bash
[ $# -eq 1 ] || { echo -e "\nError:\tConfiguration file needed ...\nUsage:\t${0##*/} <configuration_file.conf>\n"; exit 1; }
LCL_CONF_FILE="${1}"
# source in the variables set in the config file
source ${LCL_CONF_FILE}

php <<PHP1
<?php
include_once('/usr/local/ispconfig/interface/lib/config.inc.php');
\$conf['start_session'] = false;
include_once('/usr/local/ispconfig/interface/lib/app.inc.php');
include_once('/usr/local/ispconfig/interface/lib/classes/db_mysql.inc.php');

	global \$app;
	\$tablename = "server";
	\$index_field = "server_name";

	// WEB
	\$index_value = "${LCL_SERVER_FQDN_WEB}";
	\$update_data = array(	"mail_server"		=>	"0",
				"web_server"		=>	"1",
				"dns_server"		=>	"0",
				"file_server"		=>	"1",
				"db_server"		=>	"0",
				"vserver_server"	=>	"0",
				"proxy_server"		=>	"0",
				"firewall_server"	=>	"1",
				"updated"		=>	"1",);
	\$app->db->datalogUpdate(\$tablename, \$update_data, \$index_field, \$index_value, \$force_update = false);

	// MAIL
	\$index_value = "${LCL_SERVER_FQDN_MAIL}";
	\$update_data = array(	"mail_server"		=>	"1",
				"web_server"		=>	"0",
				"dns_server"		=>	"0",
				"file_server"		=>	"0",
				"db_server"		=>	"0",
				"vserver_server"	=>	"0",
				"proxy_server"		=>	"0",
				"firewall_server"	=>	"1",
				"updated"		=>	"2",);
	\$app->db->datalogUpdate(\$tablename, \$update_data, \$index_field, \$index_value, \$force_update = false);

	// DB
	\$index_value = "${LCL_SERVER_FQDN_DB}";
	\$update_data = array(	"mail_server"		=>	"0",
				"web_server"		=>	"0",
				"dns_server"		=>	"0",
				"file_server"		=>	"0",
				"db_server"		=>	"1",
				"vserver_server"	=>	"0",
				"proxy_server"		=>	"0",
				"firewall_server"	=>	"1",
				"updated"		=>	"3",);
	\$app->db->datalogUpdate(\$tablename, \$update_data, \$index_field, \$index_value, \$force_update = false);

	// DNS1
	\$index_value = "${LCL_SERVER_FQDN_DNS1}";
	\$update_data = array(	"mail_server"		=>	"0",
				"web_server"		=>	"0",
				"dns_server"		=>	"1",
				"file_server"		=>	"0",
				"db_server"		=>	"0",
				"vserver_server"	=>	"0",
				"proxy_server"		=>	"0",
				"firewall_server"	=>	"1",
				"updated"		=>	"4",);
	\$app->db->datalogUpdate(\$tablename, \$update_data, \$index_field, \$index_value, \$force_update = false);

	// DNS2
	\$index_value = "${LCL_SERVER_FQDN_DNS2}";
	\$update_data = array(	"mail_server"		=>	"0",
				"web_server"		=>	"0",
				"dns_server"		=>	"1",
				"file_server"		=>	"0",
				"db_server"		=>	"0",
				"vserver_server"	=>	"0",
				"proxy_server"		=>	"0",
				"firewall_server"	=>	"1",
				"updated"		=>	"5",);
	\$app->db->datalogUpdate(\$tablename, \$update_data, \$index_field, \$index_value, \$force_update = false);
?>
PHP1
These posts were helpful in constructing this:
Thanks,
SuperJC
Reply With Quote