More status collect / package updates integration

This commit is contained in:
Jamie Cameron
2009-10-06 16:54:17 -07:00
parent 6ad7c83976
commit 3e47e62e66
9 changed files with 49 additions and 21 deletions

View File

@@ -1 +1 @@
cache_time=1
cache_time=6

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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;";

View File

@@ -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 });

2
system-status/CHANGELOG Normal file
View File

@@ -0,0 +1,2 @@
---- Changes since 1.490 ----
First version of this module, for collecting system information using a background Cron job.

View File

@@ -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|<mins>";
$config{'collect_interval'} = $ARGV[0];
&save_module_config();
&setup_collectinfo_job();

13
system-status/postinstall.pl Executable file
View File

@@ -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");
}
}

View File

@@ -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;