3 # Database intialization for Regano
5 # Regano is free software. You can redistribute it and/or modify
6 # it under the same terms as Perl itself.
14 $dbh = DBI
->connect('dbi:Pg:db=template1', undef, undef,
15 {AutoCommit
=> 1, RaiseError
=> 1})
19 local $dbh->{PrintError
};
20 print "ensure 'regano' user exists\n";
21 $dbh->do(q
[CREATE ROLE
"regano" WITH LOGIN
]);
24 local $dbh->{PrintError
};
25 print "ensure 'regano-www' user exists\n";
26 $dbh->do(q
[CREATE ROLE
"regano-www" WITH LOGIN
]);
30 local $dbh->{PrintError
};
31 $dbh->do(q
[DROP DATABASE
"regano"]);
32 print "erase database 'regano'\n";
33 } if defined $ARGV[0] and $ARGV[0] eq 'erasedb';
34 $dbh->do(q
[CREATE DATABASE
"regano" WITH OWNER
= "regano"]);
35 print "create database 'regano'\n";
39 foreach my $part (qw(types tables functions config api antiskid)) {
40 system {'psql'} qw(psql -d regano -f), "db_${part}.sql"
43 $dbh = DBI
->connect('dbi:Pg:db=regano', undef, undef,
44 {AutoCommit
=> 1, RaiseError
=> 1})
47 print "reserve \"@\" domain for storing TLD records\n";
49 (q
[INSERT INTO regano
.reserved_domains
(domain_name
, reason
)
50 VALUES
('@', 'Reserved for storing TLD records')]);
52 print "reserve \"@@\" domain for storing NS records for hosted zones\n";
54 (q
[INSERT INTO regano
.reserved_domains
(domain_name
, reason
)
55 VALUES
('@@', 'Reserved for storing NS records for host mirrors')]);
57 print "reserve \"example\" domain\n";
59 (q
[INSERT INTO regano
.reserved_domains
(domain_name
, reason
)
60 VALUES
('example', 'Reserved for use in documentation')]);
62 print "reserve IANA names:";
63 foreach (qw
/rfc
-editor gtld
-servers iana
-servers root
-servers
64 aso dnso pso iab iana icann iesg ietf irtf istf
65 internic afrinic arin apnic lacnic latnic ripe
/) {
68 (q
[INSERT INTO regano
.reserved_domains
(domain_name
, reason
)
69 VALUES
(?
, 'Reserved to avoid confusion with IANA')], {}, $_);
73 print "reserve OpenNIC names:";
74 foreach (qw
/register registrar opennic openic nic dot/) {
77 (q
[INSERT INTO regano
.reserved_domains
(domain_name
, reason
)
78 VALUES
(?
, 'Reserved for OpenNIC')], {}, $_);