blob: bae49313c6704b56ee6a76de6e238c8895a8344c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
#!/usr/bin/perl -w
use strict;
use Debconf::Client::ConfModule;
use English;
my $address;
my $operator;
my $sitename;
if ( -e '/etc/echolot/pingd.conf' ) {
my $CONFIG;
{
local $/ = undef;
open(CONFIGCODE, '/etc/echolot/pingd.conf') or
die ("Cannot open /etc/echolot/pingd.conf: $!");
my $config_code = <CONFIGCODE>;
close (CONFIGCODE);
($config_code) = $config_code =~ /^(.*)$/s;
eval ($config_code);
($EVAL_ERROR) and
die("Evaling config code from /etc/echolot/pingd.conf returned error: $EVAL_ERROR");
}
$address = $CONFIG->{'my_localpart'}.'@'.$CONFIG->{'my_domain'} if (defined $CONFIG->{'my_localpart'} && defined $CONFIG->{'my_domain'});
$operator = $CONFIG->{'operator_address'} if (defined $CONFIG->{'operator_address'});
$sitename = $CONFIG->{'sitename'} if (defined $CONFIG->{'sitename'});
};
my $mailname;
$mailname = `cat /etc/mailname` if ( -e '/etc/mailname' );
$mailname = `hostname` unless ( defined $mailname );
$mailname = 'example.org' unless ( defined $mailname );
chomp $mailname;
$address = 'echolot@'.$mailname unless defined $address;
$operator = 'abuse@'.$mailname unless defined $operator;
$sitename = $mailname unless defined $sitename;
Debconf::Client::ConfModule::set('echolot/address', $address);
Debconf::Client::ConfModule::set('echolot/operator', $operator);
Debconf::Client::ConfModule::set('echolot/sitename', $sitename);
my $state = 1;
my $numerr = 0;
Debconf::Client::ConfModule::version('2.0');
Debconf::Client::ConfModule::capb('backup');
while (1) {
if ($state == 0) {
$state = 1;
} elsif ($state == 1) {
Debconf::Client::ConfModule::input('high', 'echolot/address');
my @return = Debconf::Client::ConfModule::go();
$address = Debconf::Client::ConfModule::get('echolot/address');
unless ($address =~ /@/) {
$address .= '@'.$mailname;
Debconf::Client::ConfModule::set('echolot/address', $address);
$numerr++;
next if ($numerr <= 5);
};
if ($return[0] == 30) {
$numerr = 0;
$state--;
} else {
$numerr = 0;
$state++;
};
next;
} elsif ($state == 2) {
Debconf::Client::ConfModule::input('high', 'echolot/operator');
Debconf::Client::ConfModule::input('high', 'echolot/sitename');
Debconf::Client::ConfModule::input('medium', 'echolot/addnow');
} elsif ($state == 3) {
last;
} else {
die ("Unknown state $state");
};
my @return = Debconf::Client::ConfModule::go();
if ($return[0] == 30) {
$state--;
} else {
$state++;
};
};
# vim:set ts=4:
# vim:set shiftwidth=4:
|