
25th March 2010, 13:23
|
|
Junior Member
|
|
Join Date: Aug 2009
Posts: 8
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|

25th March 2010, 21:14
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,886
Thanks: 691
Thanked 4,188 Times in 3,205 Posts
|
|
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.
|
|
The Following User Says Thank You to till For This Useful Post:
|
|

26th March 2010, 10:09
|
|
Junior Member
|
|
Join Date: Aug 2009
Posts: 8
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|

26th March 2010, 18:48
|
|
HowtoForge Supporter
|
|
Join Date: Apr 2007
Location: Helsinki
Posts: 374
Thanks: 24
Thanked 36 Times in 24 Posts
|
|
|

28th May 2010, 16:08
|
|
Senior Member
|
|
Join Date: Apr 2008
Location: San Diego & Tijuana
Posts: 302
Thanks: 26
Thanked 32 Times in 30 Posts
|
|
What and where is the "ispconfig mysql library"? I will write a script for it if I can find it.
|

28th May 2010, 16:17
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,886
Thanks: 691
Thanked 4,188 Times in 3,205 Posts
|
|
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.
|

28th May 2010, 17:50
|
|
Senior Member
|
|
Join Date: Apr 2008
Location: San Diego & Tijuana
Posts: 302
Thanks: 26
Thanked 32 Times in 30 Posts
|
|
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
|

28th May 2010, 17:56
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,886
Thanks: 691
Thanked 4,188 Times in 3,205 Posts
|
|
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]')";
|

28th May 2010, 18:09
|
|
Senior Member
|
|
Join Date: Apr 2008
Location: San Diego & Tijuana
Posts: 302
Thanks: 26
Thanked 32 Times in 30 Posts
|
|
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.
Last edited by BorderAmigos; 28th May 2010 at 19:51.
|

28th May 2010, 19:49
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,886
Thanks: 691
Thanked 4,188 Times in 3,205 Posts
|
|
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.
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT +2. The time now is 12:18.
|
Recent comments
9 hours 54 min ago
14 hours 52 min ago
16 hours 19 min ago
17 hours 12 min ago
18 hours 55 min ago
23 hours 18 min ago
1 day 10 min ago
1 day 2 hours ago
1 day 15 hours ago
1 day 17 hours ago