3 # add-dns.pl version 0.0.4alpha
4 # Dominic Hargreaves <dom@earth.li>
6 # Use this to tell nameservers supporting AutoDNS
7 # (http://www.earth.li/projectpurple/progs/autodns.html) to slave for you.
11 # 03/07/01 dom: Added remotehelp and remove command for AutoDNS 0.0.4alpha
12 # Changed to header to ns1 (from terry)
13 # 22/05/01 dom: Initial code completed for AutoDNS 0.0.3
20 my $sendmail = "/usr/sbin/sendmail";
21 my $gpg = "/usr/bin/gpg";
23 my $to = 'dns-auto@tuschin.blackcatnetworks.co.uk,
24 dns-auto@ns1.blackcatnetworks.co.uk';
26 my $from = 'Urchin Hostmaster <hostmaster@urchin.earth.li>';
29 my $keyid = "25B2616D";
31 my @validcommands = qw(add remove list remotehelp);
33 # Only proceed if we have been given a valid command
35 die usage unless $ARGV[0];
38 for (@validcommands) {
44 die usage unless ($ok == 1);
48 open3(\*GPGIN, \*GPGOUT, \*GPGERR, "$gpg --default-key $keyid --clearsign");
50 # Generate AutoDNS commands
52 print GPGIN "BEGIN\n";
54 $command = shift(@ARGV);
56 if ($command eq "list") {
58 } elsif ($command eq "remotehelp") {
60 } elsif ($command eq "add") {
62 print GPGIN "ADD $_\n";
64 } elsif ($command eq "remove") {
66 print GPGIN "DEL $_\n";
76 my @gpgerror=<GPGERR>;
81 # Show user any error output from gpg...
87 # ...and what we intend to send
93 # Ask user whether this is ok
95 print "Send this mail to:\n";
110 if (!($mark eq "1")) {
111 print "Mail NOT sent.\n";
117 open MAIL, "|$sendmail -t -oi" or die $!;
118 print MAIL "From: $from\n" or die "Configuration error: $!";
119 print MAIL "To: $to\n" or die "Configuration error: $!";
120 print MAIL "Cc: $cc\n" if $cc;
121 print MAIL "Subject: AutoDNS commands\n";
122 print MAIL "X-Mailer: add-dns.pl 0.0.4alpha\n\n";
136 Usage: $0 <command> [list of domains]
138 Possible commands: add: Adds domains
139 remove: Removes domains
140 list: Lists current domains
141 remotehelp: Requests help from remote end
143 (You must have the private key $keyid in your gpg keyring