From e3806b2546f03be8c8b1827e375a6e349045c1c9 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Sun, 11 Aug 2002 18:46:21 +0000 Subject: Initial import --- debian/echolot.config | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100755 debian/echolot.config (limited to 'debian/echolot.config') diff --git a/debian/echolot.config b/debian/echolot.config new file mode 100755 index 0000000..e2d8938 --- /dev/null +++ b/debian/echolot.config @@ -0,0 +1,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 = ; + 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"); + } + + $sitename = $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: -- cgit v1.2.3