Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Installation/Configuration

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 25th March 2010, 13:23
flevoict flevoict is offline
Junior Member
 
Join Date: Aug 2009
Posts: 8
Thanks: 0
Thanked 2 Times in 2 Posts
Default Bulk add DNS Records

Dear all,

I hope somebody can help.

We have installed a third NS server in an other datacenter. Now I want to add an extra NS record to all my domains in ISP config (about 50 domains).

Does somebody know how to do this in bulk, like add a record with mysql or something like that.

I hope somebody can help me so I don't have to this manually.

Cheers,

Bas aka Flevoict
Reply With Quote
Sponsored Links
  #2  
Old 25th March 2010, 21:14
till till is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 36,394
Thanks: 833
Thanked 5,489 Times in 4,321 Posts
Default

You can do this e.g. with a script that uses the datalogInsert function from the ispconfig mysql library to insert the records in the database.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
The Following User Says Thank You to till For This Useful Post:
adamassasda291 (27th June 2013)
  #3  
Old 26th March 2010, 10:09
flevoict flevoict is offline
Junior Member
 
Join Date: Aug 2009
Posts: 8
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Thanks Till for your reply.

Now I have the following issue, I'm not really a database/mysql programmer, more a network engineer who has to manage these things as well.

Is there somebody who can point me in the right direction with the sql script.

Thnx in advance.

Bas
Reply With Quote
The Following User Says Thank You to flevoict For This Useful Post:
adamassasda291 (9th July 2013)
  #4  
Old 26th March 2010, 18:48
SamTzu SamTzu is offline
HowtoForge Supporter
 
Join Date: Apr 2007
Location: Helsinki
Posts: 429
Thanks: 33
Thanked 56 Times in 39 Posts
Send a message via Skype™ to SamTzu
Default

I just updated our MyDNS sync script.
http://www.howtoforge.com/forums/sho...279#post209279
__________________

Sami Mattila
Internet-Content

Telephone:
00358942833310
Email: firstname.lastname@internet-content.org
Shop: http://shop.internet-content.net
Site: http://www.internet-content.net
Blog: http://www.internet-content.net/en/blog
FB: https://www.facebook.com/internetcontent

Reply With Quote
  #5  
Old 28th May 2010, 16:08
BorderAmigos BorderAmigos is offline
Senior Member
 
Join Date: Apr 2008
Location: San Diego & Tijuana
Posts: 302
Thanks: 26
Thanked 33 Times in 31 Posts
Send a message via MSN to BorderAmigos Send a message via Yahoo to BorderAmigos
Default

What and where is the "ispconfig mysql library"? I will write a script for it if I can find it.
__________________
System6Hosting.com, ISPConfig 3, Debian.
Reply With Quote
The Following User Says Thank You to BorderAmigos For This Useful Post:
adamassasda291 (9th July 2013)
  #6  
Old 28th May 2010, 16:17
till till is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 36,394
Thanks: 833
Thanked 5,489 Times in 4,321 Posts
Default

The ISPConfig mysql library is here:

/usr/local/ispconfig/interface/lib/classes/db_mysql.inc.php

Your php script should look like this (untested, partly pseudo code):

Code:
<?php

include_once('/usr/local/ispconfig/interface/lib/config.inc.php');
include_once('/usr/local/ispconfig/interface/lib/classes/db_mysql.inc.php');

$db = new db;

$tablename = "database_table_name";
$insert_data = "(a,b,c) values ('a','b','c')";
$index_field = "dbtable_index_field_name";

$db->datalogInsert($tablename, $insert_data, $index_field);

?>
The content of the variables has to be changed to match the data and table that you want to modify.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
The Following User Says Thank You to till For This Useful Post:
adamassasda291 (21st June 2013)
  #7  
Old 28th May 2010, 17:50
BorderAmigos BorderAmigos is offline
Senior Member
 
Join Date: Apr 2008
Location: San Diego & Tijuana
Posts: 302
Thanks: 26
Thanked 33 Times in 31 Posts
Send a message via MSN to BorderAmigos Send a message via Yahoo to BorderAmigos
Default

This is the script I came up with. There are no errors in any logs but it doesn't appear to work as the mail_content_filter table stays empty. Putting it here to see if someone can see what's not working...

mail_content_filters.php
Code:
<?php
// Note:  These includes and their ancestor directories needed 755 permissions 
include('/usr/local/ispconfig/interface/lib/config.inc.php');
include('/usr/local/ispconfig/interface/lib/classes/db_mysql.inc.php');

$tablename = "mail_content_filter";  // I emptied this table first using phpMyAdmin
$index_field = "content_filter_id";
$db = new db;

print "Running... ";
$dataFile = fopen("./mail_content_filters.csv", "rb");
while (!feof($dataFile) ) {
	$mailFilters = fgets($dataFile);
	$dVal = explode(',', $mailFilters);
	$insert_data = "content_filter_id,sys_userid,sys_groupid,sys_perm_user,sys_perm_group,sys_perm_other,server_id,type,pattern,data,action,active";
	$insert_data .= " values ";
	$insert_data .= "$dVal[0],$dVal[1],$dVal[2],$dVal[3],$dVal[4],$dVal[5],$dVal[6],$dVal[7],$dVal[8],$dVal[9],$dVal[10],$dVal[11]";
	$db->datalogInsert($tablename, $insert_data, $index_field);
}
fclose($dataFile);
print " Finished!<br>";
?>
mail_content_filters.csv (partial)
Code:
1,1,1,riud,riud,,1,body,"/^(Content-Type:.*|\s+)charset\s*=\s*""?(big5|euc-kr|gb2312|koi8|ks_c_5601-1987|Windows-1251)""?/",No foreign character sets please.,REJECT,y
2,1,1,riud,riud,,1,body,"/(filename|name)="".*\..*""$/",No files of type $1 allowed here.,REJECT,y
3,1,1,riud,riud,,1,body,"/(filename|name)=""(music*|dhcp*|Emanuel|kmbfejkm|Na kedWife|Seicho_no_ie|JAMGCJJA|Happy99|Navidad|pret typark|pretty|data|WTC|wtc|README)\.EXE""/",Known virus names,REJECT,y
4,1,1,riud,riud,,1,body,"/(filename|name)=""(doc|body|file)\.scr""/",Known for MyDoom virus names 1,REJECT,y
5,1,1,riud,riud,,1,body,"/(filename|name)=""(document|message|body|text|test) \.pif""/",Known for MyDoom virus names 2,REJECT,y
6,1,1,riud,riud,,1,body,"/(filename|name)=""(document|message|body|text|test) \.zip""/",Known for MyDoom virus names 3,REJECT,y
7,1,1,riud,riud,,1,body,/important information regarding your email address/,Possible W32_Mlmaill@MM,REJECT,y
8,1,1,riud,riud,,1,body,/mailto:.*\@.*\?subject\=(3D)*(remove|removeme|plea sedelete|pleaseremove|deleteme)+/,Lets just say we are removing now.,REJECT,y
9,1,1,riud,riud,,1,body,/.*\@.*\.ru/,No foreign character sets from ru please.,REJECT,y
10,1,1,riud,riud,,1,body,/.*\@.*\.bg/,No foreign character sets from bg please.,REJECT,y
11,1,1,riud,riud,,1,body,/.*\@.*\.it/,No foreign character sets from it please.,REJECT,y
12,1,1,riud,riud,,1,body,/.*\@.*\.au/,No foreign character sets from au please.,REJECT,y
__________________
System6Hosting.com, ISPConfig 3, Debian.
Reply With Quote
  #8  
Old 28th May 2010, 17:56
till till is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 36,394
Thanks: 833
Thanked 5,489 Times in 4,321 Posts
Default

Quote:
// Note: These includes and their ancestor directories needed 755 permissions
No, do do this or you open up your system for hackers! Please restore the permissions on your system. The permissions must stay as they are. You have to execute your script as root or ispconfig to be able to include the files.

Regarding your script, you missed a few () and also you missed to quote the content:

Code:
$insert_data = "(content_filter_id,sys_userid,sys_groupid,sys_perm_user,sys_perm_group,sys_perm_other,server_id,type,pattern,data,action,active)";
	$insert_data .= " values ";
	$insert_data .= "('$dVal[0]','$dVal[1]','$dVal[2]','$dVal[3]','$dVal[4]','$dVal[5]','$dVal[6]','$dVal[7]','$dVal[8]','$dVal[9]','$dVal[10]','$dVal[11]')";
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
The Following User Says Thank You to till For This Useful Post:
adamassasda291 (21st June 2013)
  #9  
Old 28th May 2010, 18:09
BorderAmigos BorderAmigos is offline
Senior Member
 
Join Date: Apr 2008
Location: San Diego & Tijuana
Posts: 302
Thanks: 26
Thanked 33 Times in 31 Posts
Send a message via MSN to BorderAmigos Send a message via Yahoo to BorderAmigos
Default

The permissions were only temporary.

I had tried both with and without the ().

Now it gives:
Fatal error: Call to a member function quote() on a non-object in /usr/local/ispconfig/interface/lib/classes/db_mysql.inc.php on line 280

...

OK, got it working but had to modify the ISPConfig 3 code slightly. Not sure if the modification is a work around or a bug fix. Will leave that to others to decide.

in /usr/local/ispconfig/interface/lib/classes/db_mysql.inc.php the $old_rec variable is empty and not being seen as an object. Added the line "$old_rec = $new_rec;" as shown below to define it and now my script works. Comments? Does this break something else?
Code:
	public function datalogInsert($tablename, $insert_data, $index_field) {
		global $app;
		
		$old_rec = array();
		$this->query("INSERT INTO $tablename $insert_data");
		$index_value = $this->insertID();
		$new_rec = $this->queryOneRecord("SELECT * FROM $tablename WHERE $index_field = '$index_value'");
		$old_rec = $new_rec;  // Added.
		$this->datalogSave($tablename, 'INSERT', $index_field, $index_value, $old_rec, $new_rec);
		
		return $index_value;
	}
Also added a shell script so can be run as root instead of from the web server. When there is confirmation that this doesn't break something else I'll post the full scripts with the entire mail_content_filters.csv attached.
__________________
System6Hosting.com, ISPConfig 3, Debian.

Last edited by BorderAmigos; 28th May 2010 at 19:51.
Reply With Quote
  #10  
Old 28th May 2010, 19:49
till till is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 36,394
Thanks: 833
Thanked 5,489 Times in 4,321 Posts
 
Default

Yes, the $app object from ispconfig is missing. Changing all accurrences in the diffrec function from:

$app->db->quote(

to:

$this->quote(

in the mysql class should fix this.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
sarg issue while generating reports for squid mail4vij Server Operation 3 31st December 2009 13:12
Ubuntu Server, ISPConfig, Domain name, and problems NYCSavage Server Operation 5 27th November 2009 17:45
Google Apps dayjahone General 19 29th March 2008 17:25
Unable send receive emails vassilis3 Installation/Configuration 15 19th May 2007 14:34
No SPF record. beryl Installation/Configuration 6 17th May 2007 19:52


All times are GMT +2. The time now is 19:09.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.