equal
deleted
inserted
replaced
7 use File::Temp; |
7 use File::Temp; |
8 use Getopt::Long; |
8 use Getopt::Long; |
9 use Pod::Usage; |
9 use Pod::Usage; |
10 use File::Basename; |
10 use File::Basename; |
11 use if $ENV{DEBUG} => "Smart::Comments"; |
11 use if $ENV{DEBUG} => "Smart::Comments"; |
|
12 use my::Config qw(get_config); |
12 |
13 |
13 my $ME = basename $0; |
14 my $ME = basename $0; |
14 |
15 |
15 sub read_conf(@); |
16 sub read_conf(@); |
16 sub read_argv($); |
17 sub read_argv($); |
20 sub create_zsk($@); |
21 sub create_zsk($@); |
21 sub post_create($@); |
22 sub post_create($@); |
22 |
23 |
23 MAIN: { |
24 MAIN: { |
24 ### reading config |
25 ### reading config |
25 my %conf = read_conf("$FindBin::Bin/dnstools.conf", "/etc/dnstools.conf"); |
26 my %conf = get_config("$FindBin::Bin/dnstools.conf", "/etc/dnstools.conf"); |
26 |
27 |
27 my ($cmd, @zones) = read_argv($conf{master_dir}); |
28 my ($cmd, @zones) = read_argv($conf{master_dir}); |
28 |
29 |
29 given ($cmd) { |
30 given ($cmd) { |
30 when ("rm") { rm_keys($conf{master_dir}, @zones); exit } |
31 when ("rm") { rm_keys($conf{master_dir}, @zones); exit } |
67 push @zones, $zone; |
68 push @zones, $zone; |
68 } |
69 } |
69 return ($cmd, @zones); |
70 return ($cmd, @zones); |
70 } |
71 } |
71 |
72 |
72 sub read_conf(@) { |
|
73 |
|
74 # read configuration |
|
75 my @conffiles = @_; |
|
76 my %return; |
|
77 |
|
78 my ($_) = grep { -f } @conffiles; |
|
79 open(my $cf, $_) or die "Can't open $_: $!\n"; |
|
80 |
|
81 while (<$cf>) { |
|
82 s/#.*//; |
|
83 s/\s//g; |
|
84 next unless length; |
|
85 my ($cname, $ccont) = split(/\s*=\s*/, $_, 2); |
|
86 $return{$cname} = $ccont; |
|
87 } |
|
88 return %return; |
|
89 } |
|
90 |
73 |
91 sub rm_keys ($@) { |
74 sub rm_keys ($@) { |
92 |
75 |
93 # deletes all the keys were handed over -rm in argv |
76 # deletes all the keys were handed over -rm in argv |
94 my ($master_dir, @zone) = @_; |
77 my ($master_dir, @zone) = @_; |