X-Git-Url: https://the.earth.li/gitweb/?a=blobdiff_plain;f=autodns.pl;h=f84300fee11d88d4155bdb9417a72bf5fdf1352a;hb=88e5b43bbafc83d80e3e2d17d856c84deb922593;hp=67377a3025ee36bcb4cc875361b95a55e4ca2774;hpb=746e683bd12005337be464cbd1b21a73de78e8f7;p=autodns.git diff --git a/autodns.pl b/autodns.pl index 67377a3..f84300f 100755 --- a/autodns.pl +++ b/autodns.pl @@ -1,11 +1,11 @@ #!/usr/bin/perl -Tw -# autodns 0.0.7 -# Copyright 1999-2004 Project Purple. Written by Jonathan McDowell +# autodns 0.0.8 +# Copyright 1999-2005 Project Purple. Written by Jonathan McDowell # See ACKNOWLEDGEMENTS file for full details of contributors. # http://www.earth.li/projectpurple/progs/autodns.html # Released under the GPL. # -# $Id: autodns.pl,v 1.5 2005/03/21 15:11:01 noodles Exp $ +# $Id: autodns.pl,v 1.8 2005/04/08 13:51:13 noodles Exp $ # use strict; @@ -21,39 +21,18 @@ my ($user, $server, $inprocess, $delcount, $addcount, $reload_command); my ($domain, @MAIL, @GPGERROR, @COMMANDS, %zones); my ($me, $ccreply, $conffile, $domainlistroot, @cfgfiles, $VERSION); -$VERSION="0.0.7"; +$VERSION="0.0.8"; # -# Local configuration here (until it gets moved to a config file). +# Load our config # -# These are sort of suitable for a Debian setup. -# - -# Who I should reply as. -$me="autodns\@earth.li"; - -# Who replies should be CCed to. -$ccreply="noodles\@earth.li"; - -# Where to look for zones we're already hosting. -@cfgfiles=("/etc/bind/named.conf", - "/etc/bind/named.secondary.conf"); - -# The file we should add/delete domains from. -$conffile="/etc/bind/named.secondary.conf"; - -# The file that contains details of the authorized users. -$usersfile="/etc/bind/autodns.users"; - -# Base file name to for list of users domains. -$domainlistroot="/etc/bind/domains."; - -# The lockfile we use to ensure we have exclusive access to the -# $domainlistroot$user files and $conffile. -$lockfile="/etc/bind/autodns.lck"; - -# The command to reload the nameserver domains list. -$reload_command="sudo ndc reconfig 2>&1"; +my $file = '/etc/bind/autodns.conf'; +unless (my $ret = do $file) { + warn "Couldn't parse $file\n" if $@; + warn "Couldn't do $file\n" unless defined $ret; + warn "Couldn't run $file\n" unless $ret; + die "Problem reading config file!\n"; +} ### ### There should be no need to edit anything below (unless you're not @@ -336,6 +315,13 @@ foreach my $cfgfile (@cfgfiles) { getzones($cfgfile); } +# Force existance of the $domainlistroot$user file +if (! -e $domainlistroot.$user) { + open (DOMAINLIST, ">>$domainlistroot$user") or + &fatalerror("Couldn't create domains file.\n"); + close DOMAINLIST; +} + foreach (@COMMANDS) { # Remove trailing CRs and leading/trailing whitespace chomp;