create_boot_config.pl
上传用户:xiao730204
上传日期:2007-01-04
资源大小:141k
文件大小:1k
- #!/usr/bin/perl
- $MYSQL_SERVER = 'localhost';
- $MYSQL_USER = 'root';
- $MYSQL_PASSWORD = '11pass';
- $MYSQL_DB = 'bind';
- use Mysql;
- $dbh = Mysql->connect( $MYSQL_SERVER, $MYSQL_DB, $MYSQL_USER, $MYSQL_PASSWORD )
- or die "Unable to connect to destination databasen";
- @all_dns_tables = $dbh->listtables();
- foreach $table ( @all_dns_tables ) {
- #print $table . "n";
- $domain = $table ;
- $domain =~ s/__/-/g;
- $domain =~ s/_/./g;
- #print "DOMAIN : $domainn";
- $sth = $dbh->query(
- '
- SELECT
- sqlOrigin, sqlSerialNumber, sqlRefresh, sqlRetry, sqlExpire, sqlMinTTL
- FROM
- ' . $table . '
- WHERE
- sqlType = "SOA"
- '
- );
- local( $sql_origin, $sql_serial, $sql_refresh, $sql_retry, $sql_expire, $sql_minttl ) =
- $sth->fetchrow();
- print <<"BOOT_REC";
- zone "$domain" in {
- type master;
- sql {
- db-host "$MYSQL_SERVER";
- db-user "$MYSQL_USER";
- db-pass "$MYSQL_PASSWORD";
- db-mbox "hostmaster.$domain";
- db-refresh $sql_refresh;
- db-retry $sql_retry;
- db-expire $sql_expire;
- db-minttl $sql_minttl;
- db-serial $sql_serial;
- };
- };
- BOOT_REC
- }