diff options
-rw-r--r-- | news_wizard/scripts/Newsconf.pm | 54 |
1 files changed, 14 insertions, 40 deletions
diff --git a/news_wizard/scripts/Newsconf.pm b/news_wizard/scripts/Newsconf.pm index a0968891..2ec5675d 100644 --- a/news_wizard/scripts/Newsconf.pm +++ b/news_wizard/scripts/Newsconf.pm @@ -27,52 +27,26 @@ sub normalize_server { } sub do_it { - defined $ENV{wiz_news_freq} and my $freq = normalize_freq($ENV{wiz_news_freq}) or - die "freq not defined: $!"; - defined $ENV{wiz_news_server} and my $server = normalize_server($ENV{wiz_news_server}) or - die "server not defined: $!"; - my %mdk = Vareqval->get("/etc/sysconfig/mdk_serv"); - $mdk{wiz_news_freq} = $freq; - $mdk{wiz_news_server} = $server; - Vareqval->commit("/etc/sysconfig/mdk_serv", \%mdk); + $ENV{wiz_news_freq} and my $freq = normalize_freq($ENV{wiz_news_freq}) or + die "freq not defined: $!"; + $ENV{wiz_news_server} and my $server = normalize_server($ENV{wiz_news_server}) or + die "server not defined: $!"; my $file = "/etc/leafnode/config"; - if (! -f $file) { die "$file not found: $!"}; - my $tmp = `mktemp /tmp/Newsconf.XXXXXX` - or die "can't make a temp file: $!"; - open(OLD, "< __WIZ_HOME__/news_wizard/scripts/config.default") - or die "can't open default: $!"; - open(NEW, "> $tmp") - or die "can't open $tmp: $!"; - while (<OLD>) { + output($file, map { s|__server__|$server|g; - print NEW $_; - } - close(OLD); - close(NEW); - chomp($tmp); - system("mv $tmp $file"); + $_; + } cat_("__WIZ_HOME__/news_wizard/scripts/config.default")); $file = "/var/spool/cron/news"; - if (-f $file) { - MDK::Common::cp_af($file, "/etc/leafnode/crontab"); - } + -f $file and MDK::Common::cp_af($file, "/etc/leafnode/crontab"); $file = "/etc/leafnode/crontab"; MDK::Common::cp_af($file, $file . ".orig"); my $file = "/etc/leafnode/crontab"; - my $tmp = `mktemp /tmp/Newsconf.XXXXXX` - or die "can't make a temp file: $!"; - open(OLD, "< __WIZ_HOME__/news_wizard/scripts/news.cron") - or die "can't open default: $!"; - open(NEW, "> $tmp") - or die "can't open $tmp: $!"; - while (<OLD>) { + output($file, map { s|__freq__|$freq|g; - print NEW $_; - } - close(OLD); - close(NEW); - chomp($tmp); - system("mv $tmp $file"); - print "hello\n"; + $_; + } cat_("__WIZ_HOME__/news_wizard/scripts/news.cron")); system("crontab -u news /etc/leafnode/crontab"); - print "hello\n"; + 10; } + +1; |