diff --git a/package-updates/config b/package-updates/config index 34e06be5a..595c27609 100644 --- a/package-updates/config +++ b/package-updates/config @@ -1 +1 @@ -cache_time=1 +cache_time=6 diff --git a/package-updates/install_check.pl b/package-updates/install_check.pl new file mode 100755 index 000000000..08610f1c8 --- /dev/null +++ b/package-updates/install_check.pl @@ -0,0 +1,14 @@ +# install_check.pl + +do 'package-updates-lib.pl'; + +# is_installed(mode) +# For mode 1, returns 2 if the server is installed and configured for use by +# Webmin, 1 if installed but not configured, or 0 otherwise. +# For mode 0, returns 1 if installed, 0 if not +sub is_installed +{ +return 0 if (!&foreign_installed("software")); +return $software::update_system ? $_[0]+1 : 0; +} + diff --git a/package-updates/module.info b/package-updates/module.info index 2f82c9641..cf1ef1222 100644 --- a/package-updates/module.info +++ b/package-updates/module.info @@ -1,5 +1,5 @@ desc=Software Package Updates longdesc=Displays available package updates from YUM, APT or other update systems category=system -depends=software cron mailboxes 1.420 +depends=software cron mailboxes os_support=redhat-linux debian-linux mandrake-linux/10.2-* solaris diff --git a/package-updates/package-updates-lib.pl b/package-updates/package-updates-lib.pl index 871d5c01d..9cdf74868 100644 --- a/package-updates/package-updates-lib.pl +++ b/package-updates/package-updates-lib.pl @@ -1,9 +1,5 @@ # Functions for checking for updates to packages from YUM, APT or some other # update system. -# -# XXX cron job to collect .. actually use webmin module collector -# XXX re-check after package update -# XXX show on system information page? BEGIN { push(@INC, ".."); }; eval "use WebminCore;"; diff --git a/package-updates/update.cgi b/package-updates/update.cgi index 05080bce0..fcdaad83b 100755 --- a/package-updates/update.cgi +++ b/package-updates/update.cgi @@ -98,7 +98,10 @@ else { } # Refresh collected package info - # XXX call webmin + if (&foreign_checked("system-status")) { + &foreign_require("system-status"); + &system_status::refresh_possible_packages(\@got)); + } &webmin_log("update", "packages", scalar(@got), { 'got' => \@got }); diff --git a/system-status/CHANGELOG b/system-status/CHANGELOG new file mode 100644 index 000000000..e07aeef05 --- /dev/null +++ b/system-status/CHANGELOG @@ -0,0 +1,2 @@ +---- Changes since 1.490 ---- +First version of this module, for collecting system information using a background Cron job. diff --git a/system-status/enable-collection.pl b/system-status/enable-collection.pl new file mode 100755 index 000000000..01b2b1b1c --- /dev/null +++ b/system-status/enable-collection.pl @@ -0,0 +1,11 @@ +#!/usr/local/bin/perl +# Command-line script to enable status collection + +$no_acl_check++; +require 'system-status-lib.pl'; +$ARGV[0] eq 'none' || $ARGV[0] =~ /^[1-9][0-9]*$/ && $ARGV[0] <= 60 || + die "usage: enable-collection.pl none|"; + +$config{'collect_interval'} = $ARGV[0]; +&save_module_config(); +&setup_collectinfo_job(); diff --git a/system-status/postinstall.pl b/system-status/postinstall.pl new file mode 100755 index 000000000..58dde8429 --- /dev/null +++ b/system-status/postinstall.pl @@ -0,0 +1,13 @@ + +require 'system-status-lib.pl'; + +sub module_install +{ +# Create wrapper for system status setup script +if (&foreign_check("cron")) { + &foreign_require("cron"); + &cron::create_wrapper("$module_config_directory/enable-collection.pl", + $module_name, "enable-collection.pl"); + } +} + diff --git a/system-status/system-status-lib.pl b/system-status/system-status-lib.pl index 50635d04b..95fc3f6a7 100755 --- a/system-status/system-status-lib.pl +++ b/system-status/system-status-lib.pl @@ -1,10 +1,8 @@ # Functions for collecting general system info # -# XXX Use on main page of blue theme -# XXX Show package updates on blue theme main page # XXX Collect from Cloudmin # XXX Cloudmin should enable background collection -# XXX Check new Webmin version and module updates too? +# XXX Cloudmin should install using YUM BEGIN { push(@INC, ".."); }; eval "use WebminCore;"; @@ -54,7 +52,7 @@ if (&foreign_check("mount")) { } # Available package updates -if (&foreign_check("package-updates") && $config{'collect_pkgs'}) { +if (&foreign_installed("package-updates") && $config{'collect_pkgs'}) { &foreign_require("package-updates"); my @poss = &package_updates::list_possible_updates(2, 1); $info->{'poss'} = \@poss; @@ -94,15 +92,6 @@ my ($info) = @_; &close_tempfile(INFO); } -# refresh_startstop_status() -# Refresh regularly collected info on status of services -sub refresh_startstop_status -{ -my $info = &get_collected_info(); -$info->{'startstop'} = [ &get_startstop_links() ]; -&save_collected_info($info); -} - # refresh_possible_packages(&newpackages) # Refresh regularly collected info on available packages sub refresh_possible_packages @@ -110,7 +99,7 @@ sub refresh_possible_packages my ($pkgs) = @_; my %pkgs = map { $_, 1 } @$pkgs; my $info = &get_collected_info(); -if ($info->{'poss'} && &foreign_check("package-updates")) { +if ($info->{'poss'} && &foreign_installed("package-updates")) { &foreign_require("package-updates"); my @poss = &package_updates::list_possible_updates(2); $info->{'poss'} = \@poss;