More status collect / package updates integration
authorJamie Cameron <jcameron@webmin.com>
Tue, 6 Oct 2009 23:54:17 +0000 (16:54 -0700)
committerJamie Cameron <jcameron@webmin.com>
Tue, 6 Oct 2009 23:54:17 +0000 (16:54 -0700)
package-updates/config
package-updates/install_check.pl [new file with mode: 0755]
package-updates/module.info
package-updates/package-updates-lib.pl
package-updates/update.cgi
system-status/CHANGELOG [new file with mode: 0644]
system-status/enable-collection.pl [new file with mode: 0755]
system-status/postinstall.pl [new file with mode: 0755]
system-status/system-status-lib.pl

index 34e06be..595c276 100644 (file)
@@ -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 (executable)
index 0000000..08610f1
--- /dev/null
@@ -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;
+}
+
index 2f82c96..cf1ef12 100644 (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
index 871d5c0..9cdf748 100644 (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;";
index 05080bc..fcdaad8 100755 (executable)
@@ -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 (file)
index 0000000..e07aeef
--- /dev/null
@@ -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 (executable)
index 0000000..01b2b1b
--- /dev/null
@@ -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();
diff --git a/system-status/postinstall.pl b/system-status/postinstall.pl
new file mode 100755 (executable)
index 0000000..58dde84
--- /dev/null
@@ -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");
+       }
+}
+
index 50635d0..95fc3f6 100755 (executable)
@@ -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;