summaryrefslogtreecommitdiffstats
path: root/news_wizard
diff options
context:
space:
mode:
authorFlorent Villard <warly@mandriva.com>2003-09-05 11:42:20 +0000
committerFlorent Villard <warly@mandriva.com>2003-09-05 11:42:20 +0000
commite4371f18753c98687f71de82810acc79428c51f9 (patch)
tree0fea71ac6b4e25072165c79f2c9e5e0d4ca3f28d /news_wizard
parent8dd32f86a6e97fa103be7155f5784c3dd3166308 (diff)
downloaddrakwizard-e4371f18753c98687f71de82810acc79428c51f9.tar
drakwizard-e4371f18753c98687f71de82810acc79428c51f9.tar.gz
drakwizard-e4371f18753c98687f71de82810acc79428c51f9.tar.bz2
drakwizard-e4371f18753c98687f71de82810acc79428c51f9.tar.xz
drakwizard-e4371f18753c98687f71de82810acc79428c51f9.zip
*** empty log message ***
Diffstat (limited to 'news_wizard')
-rwxr-xr-xnews_wizard/Inn.pm115
1 files changed, 92 insertions, 23 deletions
diff --git a/news_wizard/Inn.pm b/news_wizard/Inn.pm
index 713f2041..71e33c1f 100755
--- a/news_wizard/Inn.pm
+++ b/news_wizard/Inn.pm
@@ -23,60 +23,76 @@ use strict;
use common;
require MDK::Wizard::Wizcommon;
+use MDK::Wizard::Varspaceval;
my $wiz = new MDK::Wizard::Wizcommon;
my $o = {
- name => 'configuration wizard',
+ name => 'News Wizard',
var => {
- ip1 => '',
- ip2 => ''
- }
+ wiz_news_server => '',
+ wiz_news_freq => ''
+ },
+ needed_rpm => [ 'inn' ],
+ defaultimage => "$ENV{__WIZARD_HOME__}news_wizard/images/news.png"
};
$o->{pages} = {
welcome => {
- name => N('') . "\n\n" . N('') . "\n\n" . N(''),
+ name => N('Welcome to the News Wizard') . "\n\n" . N('This wizard will help you configuring the Internet News services for your network.'),
no_back => 1,
- next => 'ip_range'
+ next => 'ask_news_server'
},
- confige => {
- name => N('') . "\n\n" . N('') . "\n\n" . N(''),
+ ask_news_server => {
+ name => N('News Server') . "\n\n" . N('The news server name is the name of the host providing the Internet news to your network; the name is usually provided by your provider.') . "\n\n" . N('Internet host names must be in the form \qhost.domain.domaintype\q; for example, if your provider is \qprovider.com\q, the internet news server is usually \qnews.provider.com\q.'),
pre => sub {
- $o->{var}{ip1} ||= f1();
- $o->{var}{ip2} ||= f2();
+ $o->{var}{news_server} ||= get_server();
},
- post => \&check,
data => [
- { label => '' },
- { label => N(''), val => \$o->{var}{ip1} },
- { label => N(''), val => \$o->{var}{ip2} },
+ { label => N('News Server Name:'), val => \$o->{var}{news_server} },
],
+ post => sub { $o->{var}{news_server} or 'error_in_news_server' },
+ next => 'ask_news_freq'
+ },
+ ask_news_freq => {
+ name => N('Polling Period') . "\n\n" . N('Your server will regularly poll the News Server for obtaning the latest Internet News; the polling period set the interval between two consecutive polling.') . "\n\n" . N('Depending on the kind of internet connection you have, an appropriate polling period can change between 6 and 24 hours.'),
+ pre => sub {
+ $o->{var}{news_freq} ||= 24;
+ },
+ data => [
+ { label => N('Polling Period (Hours):'), val => \$o->{var}{news_freq} },
+ ],
+ post => \&check_valid_hours,
next => 'summary'
},
- warning => {
+ warning => {
name => N('Warning.'),
data => [ { label => N('') } ],
next => 'summary'
},
- error => {
+ error_in_news_server => {
name => N('Error.'),
- data => [ { label => N('') } ],
- next => 'config'
+ data => [ { label => N('The news server name is not correct') } ],
+ next => 'ask_news_server'
+ },
+ error_in_polling_time => {
+ name => N('Error.'),
+ data => [ { label => N('The polling period is not correct') } ],
+ next => 'ask_news_freq'
},
summary => {
- name => N('') . "\n\n" . N('') . "\n\n" . N(''),
+ name => N('Configuring the Internet News') . "\n\n" . N('The wizard collected the following parameters
+needed to configure your Internet News Service:') . "\n\n" . N('To accept these values, and configure your server, click the Next button or use the Back button to correct them.'),
data => [
- { label => N(''), type => 'field', val => \$o->{var}{ip1} },
- { label => '' },
- { label => N(''), type => 'field', val => \$o->{var}{ip2} },
+ { label => N('News Server:'), fixed_val => \$o->{var}{news_server} },
+ { label => N('Polling Interval:'), fixed_val => \$o->{var}{news_freq} },
],
post => \&do_it,
next => 'end'
},
end => {
name => N('Congratulation'),
- data => [ { label => N('') } ],
+ data => [ { label => N('The wizard successfully configured your Internet News service of your server.') } ],
end => 1,
next => 0
},
@@ -89,4 +105,57 @@ sub new {
}, $class;
}
+sub check_valid_hours {
+ $o->{var}{news_freq} =~ /^\d+$/ or return 'error_in_polling_time'
+}
+
+sub normalize_freq {
+ my ($freq) = @_;
+
+ if ($freq =~ /(\d*)/) {
+ $freq = $1;
+ }
+ if ($freq <= 0) {
+ $freq = 0;
+ }
+ if ($freq >= 24) {
+ $freq = 24;
+ }
+ $freq;
+}
+
+sub get_server {
+ my %mdk = MDK::Wizard::Varspaceval->get("/etc/leafnode/config");
+ $mdk{server}
+}
+
+sub normalize_server {
+ my ($server) = @_;
+ $server
+}
+
+sub do_it {
+ $::testing and return;
+ $o->{var}{wiz_news_freq} and my $freq = normalize_freq($o->{var}{wiz_news_freq}) or
+ die "freq not defined: $!";
+ $o->{var}{wiz_news_server} and my $server = normalize_server($o->{var}{wiz_news_server}) or
+ die "server not defined: $!";
+ my $file = "/etc/leafnode/config";
+ output($file, map {
+ s|__server__|$server|g;
+ $_;
+ } cat_("__WIZ_HOME__/news_wizard/scripts/config.default"));
+ $file = "/var/spool/cron/news";
+ my $file_c = "/etc/leafnode/crontab";
+ if (-f $file) {
+ MDK::Common::cp_af($file, $file_c);
+ MDK::Common::cp_af($file, $file . ".orig");
+ }
+ output($file_c, map {
+ s|__freq__|$freq|g;
+ $_;
+ } cat_("__WIZ_HOME__/news_wizard/scripts/news.cron"));
+ system("crontab -u news /etc/leafnode/crontab");
+}
+
1;