# Show scheduled report form
print "<hr>\n";
print &ui_form_start("save_sched.cgi");
+print &ui_hidden("all", $in{'all'});
+print &ui_hidden("mode", $in{'mode'});
+print &ui_hidden("search", $in{'search'});
print &ui_table_start($text{'index_header'}, undef, 2);
$job = &find_cron_job();
if ($job) {
$sched = $job->{'hours'} eq '*' ? 'h' :
$job->{'days'} eq '*' && $job->{'weekdays'} eq '*' ? 'd' :
- $job->{'days'} eq '*' && $job->{'weekdays'} eq '0' ? 'w' :
- undef;
+ $job->{'days'} eq '*' && $job->{'months'} eq '*' ? 'w' :
+ undef;
}
else {
$sched = "d";
}
+
+# When to run
print &ui_table_row($text{'index_sched'},
&ui_radio("sched_def", $job ? 0 : 1,
[ [ 1, $text{'index_sched1'} ],
[ 'd', $text{'index_schedd'} ],
[ 'w', $text{'index_schedw'} ] ]));
+# Send email to
print &ui_table_row($text{'index_email'},
&ui_textbox("email", $config{'sched_email'}, 40));
+# Install or just notify?
print &ui_table_row($text{'index_action'},
&ui_radio("action", int($config{'sched_action'}),
[ [ 0, $text{'index_action0'} ],
#
# XXX cron job to collect .. actually use webmin module collector
# XXX re-check after package update
-# XXX test automatic notification
# XXX show on system information page?
BEGIN { push(@INC, ".."); };
# Filter out dupes and sort by name
@rv = &filter_duplicates(\@rv);
- local $incwebmin = &include_webmin_modules();
- if ($incwebmin) {
- # Add installed Webmin modules
- foreach my $minfo (&get_all_module_infos()) {
- push(@rv, { 'name' => $minfo->{'dir'},
- 'update' => $minfo->{'dir'},
- 'desc' => &text('index_webmin',
- $minfo->{'desc'}),
- 'version' => $minfo->{'version'},
- 'system' => 'webmin',
- 'updateonly' => 1,
- });
- }
-
- # Add installed Webmin themes
- foreach my $tinfo (&webmin::list_themes()) {
- push(@rv, { 'name' => $tinfo->{'dir'},
- 'update' => $tinfo->{'dir'},
- 'desc' => &text('index_webmintheme',
- $tinfo->{'desc'}),
- 'version' => $tinfo->{'version'},
- 'system' => 'webmin',
- 'updateonly' => 1,
- });
- }
-
- # Add an entry for Webmin itself, but only if this was
- # a tar.gz install
- if ($incwebmin != 2) {
- push(@rv, { 'name' => 'webmin',
- 'update' => 'webmin',
- 'desc' => 'Webmin Package',
- 'version' => &get_webmin_version(),
- 'system' => 'tgz',
- 'updateonly' => 1,
- });
- }
- else {
- # Remove Webmin from the list, as YUM sometimes
- # includes it in the 'yum list' output even though
- # it cannot actual do an update!
- @rv = grep { $_->{'name'} ne 'webmin' } @rv;
- }
-
- # If Usermin is installed from a tgz, add it too
- if (&include_usermin_modules() == 1) {
- push(@rv, { 'name' => 'usermin',
- 'update' => 'usermin',
- 'desc' => 'Usermin Package',
- 'version' =>
- &usermin::get_usermin_version(),
- 'system' => 'tgz',
- 'updateonly' => 1,
- });
- }
- else {
- @rv = grep { $_->{'name'} ne 'usermin' } @rv;
- }
- }
-
&write_cache_file($current_cache_file, \@rv);
return @rv;
}
$pkg->{'desc'} =~ s/^\Q$pkg->{'update'}\E\s+\-\s+//;
}
-# include_webmin_modules()
-# Returns 1 if we should include all Webmin modules and the program itself in
-# the list of updates. Returns 2 if only non-core modules should be included.
-# The first case is selected when you have a tar.gz install, while the second
-# corresponds to a rpm or deb install with Virtualmin modules added.
-sub include_webmin_modules
-{
-return 0 if (&webmin::shared_root_directory());
-local $type = &read_file_contents("$root_directory/install-type");
-chop($type);
-if (!$type) {
- # Webmin tar.gz install
- return 1;
- }
-else {
- # How was virtual-server installed?
- return 0 if (!&foreign_check("virtual-server"));
- local $vtype = &read_file_contents(
- &module_root_directory("virtual-server")."/install-type");
- chop($vtype);
- if (!$vtype) {
- # A tar.gz install ... which we may be able to update
- return 2;
- }
- return 0;
- }
-}
-
-# include_usermin_modules()
-# Returns 1 if Usermin was installed from a tar.gz, 2 if installed from an
-# RPM but virtualmin-specific modules were from a tar.gz
-sub include_usermin_modules
-{
-if (&foreign_installed("usermin")) {
- &foreign_require("usermin", "usermin-lib.pl");
- local $type = &usermin::get_install_type();
- if (!$type) {
- # Usermin tar.gz install
- return 1;
- }
- else {
- # How was virtual-server-theme installed?
- local %miniserv;
- &usermin::get_usermin_miniserv_config(\%miniserv);
- local $vtype = &read_file_contents(
- "$miniserv{'root'}/virtual-server-theme/install-type");
- chop($vtype);
- if (!$vtype) {
- # A tar.gz install ... which we may be able to update
- return 2;
- }
- return 0;
- }
- }
-return 0;
-}
-
# installation_candiate(&package)
# Returns 1 if some package can be installed, even when it currently isn't.
# Always true for now.
$job->{'mins'} = $job->{'hours'} = $job->{'days'} =
$job->{'months'} = $job->{'weekdays'} = '*';
if ($in{'sched'} eq 'h') {
- $job->{'mins'} = '0';
+ $job->{'mins'} = int(rand()*60);
}
elsif ($in{'sched'} eq 'd') {
- $job->{'mins'} = '0';
- $job->{'hours'} = '0';
+ $job->{'mins'} = int(rand()*60);
+ $job->{'hours'} = int(rand()*24);
}
elsif ($in{'sched'} eq 'w') {
- $job->{'mins'} = '0';
- $job->{'hours'} = '0';
- $job->{'weekdays'} = '0';
+ $job->{'mins'} = int(rand()*60);
+ $job->{'hours'} = int(rand()*24);
+ $job->{'weekdays'} = int(rand()*7);
}
&lock_file(&cron::cron_file($job));
if ($oldjob) {
print "$msg<p>\n";
-&ui_print_footer("", $text{'index_return'});
&webmin_log("sched", undef, $in{'sched_def'} ? 0 : 1);
+&ui_print_footer("index.cgi?all=$in{'all'}&mode=$in{'mode'}&search=".
+ &urlize($in{'search'}), $text{'index_return'});
$no_acl_check++;
require './package-updates-lib.pl';
+if ($ARGV[0] eq "--debug" || $ARGV[0] eq "-debug") {
+ $debug = 1;
+ }
+
# See what needs doing
-@current = &list_current(1);
-@avail = &list_available(1);
+@current = &list_all_current(1);
+@avail = &list_available(1, 1);
foreach $c (sort { $a->{'name'} cmp $b->{'name'} } @current) {
($a) = grep { $_->{'name'} eq $c->{'name'} &&
$_->{'system'} eq $c->{'system'} } @avail;
# An update is available
push(@todo, { 'name' => $c->{'name'},
'update' => $a->{'update'},
+ 'oldversion' => $c->{'version'},
'version' => $a->{'version'},
- 'desc' => "New version released",
'level' => $a->{'security'} ? 1 : 2 });
}
}
foreach $t (@todo) {
if ($t->{'level'} <= $config{'sched_action'}) {
# Can install
- $body .= "An update to $t->{'name'} $t->{'version'} is needed : $t->{'desc'}\n";
+ $body .= "An update to $t->{'name'} from $t->{'oldversion'} to $t->{'version'} is needed.\n";
($out, $done) = &capture_function_output(
\&package_install, $t->{'update'});
if (@$done) {
$body .= "This update has been successfully installed.\n\n";
}
else {
- $body .= "However, this update could not be installed! Try the update manually\nusing the Security Updates module.\n\n";
+ $body .= "However, this update could not be installed! Try the update manually\nusing the Package Updates module.\n\n";
}
}
else {
# Just tell the user about it
- $body .= "An update to $t->{'name'} $t->{'version'} is available : $t->{'desc'}\n\n";
+ $body .= "An update to $t->{'name'} from $t->{'oldversion'} to $t->{'version'} is available.\n\n";
$tellcount++;
}
}
local $mail = { 'headers' =>
[ [ 'From', $from ],
[ 'To', $config{'sched_email'} ],
- [ 'Subject', "Security updates" ] ],
+ [ 'Subject', "Package updates on ".
+ &get_system_hostname() ] ],
'attach' =>
[ { 'headers' => [ [ 'Content-type', 'text/plain' ] ],
'data' => $body } ] };
&mailboxes::send_mail($mail, undef, 1, 0);
+ if ($debug) {
+ print STDERR $body;
+ }
}