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
21 ##############################################################################
22 ## Configuration section
23 ##############################################################################
25 my $from = "FILL HERE";
26 my $keyid = "FILL HERE";
27 my $to = 'dns-auto@ns0.blackcatnetworks.co.uk,'.
28 'dns-auto@ns1.blackcatnetworks.co.uk';
30 ##############################################################################
31 ##############################################################################
33 if ($from eq "FILL HERE") {
34 die "You need to edit the script to specify your email address".
35 " and GPG key ID (please also check the addresses of the".
36 " servers to update)\n");
39 my $sendmail = "/usr/sbin/sendmail";
40 my $gpg = "/usr/bin/gpg";
46 my @validcommands = qw(add remove list remotehelp);
48 # Only proceed if we have been given a valid command
50 die usage unless $ARGV[0];
53 for (@validcommands) {
59 die usage unless ($ok == 1);
63 open3(\*GPGIN, \*GPGOUT, \*GPGERR, "$gpg --default-key $keyid --clearsign");
65 # Generate AutoDNS commands
67 print GPGIN "BEGIN\n";
69 $command = shift(@ARGV);
71 if ($command eq "list") {
73 } elsif ($command eq "remotehelp") {
75 } elsif ($command eq "add") {
77 print GPGIN "ADD $_\n";
79 } elsif ($command eq "remove") {
81 print GPGIN "DEL $_\n";
91 my @gpgerror=<GPGERR>;
96 # Show user any error output from gpg...
102 # ...and what we intend to send
108 # Ask user whether this is ok
110 print "Send this mail to:\n";
125 if (!($mark eq "1")) {
126 print "Mail NOT sent.\n";
132 open MAIL, "|$sendmail -t -oi" or die $!;
133 print MAIL "From: $from\n" or die "Configuration error: $!";
134 print MAIL "To: $to\n" or die "Configuration error: $!";
135 print MAIL "Cc: $cc\n" if $cc;
136 print MAIL "Subject: AutoDNS commands\n";
137 print MAIL "X-Mailer: add-dns.pl 0.0.4alpha\n\n";
151 Usage: $0 <command> [list of domains]
153 Possible commands: add: Adds domains
154 remove: Removes domains
155 list: Lists current domains
156 remotehelp: Requests help from remote end
158 (You must have the private key $keyid in your gpg keyring