2 # Check for and install updates
5 require './package-updates-lib.pl';
7 if ($ARGV[0] eq "--debug" || $ARGV[0] eq "-debug") {
11 # See what needs doing
12 @todo = &list_possible_updates();
14 $a->{'level'} = $a->{'security'} ? 1 : 2;
17 # Install packages that are needed
21 next if ($already{$t->{'update'}});
22 if ($t->{'level'} <= $config{'sched_action'}) {
24 $body .= "An update to $t->{'name'} from $t->{'oldversion'} to $t->{'version'} is needed.\n";
25 ($out, $done) = &capture_function_output(
26 \&package_install, $t->{'update'});
28 $body .= "This update has been successfully installed.\n\n";
31 $body .= "However, this update could not be installed! Try the update manually\nusing the Package Updates module.\n\n";
38 # Just tell the user about it
39 $body .= "An update to $t->{'name'} from $t->{'oldversion'} to $t->{'version'} is available.\n\n";
46 &get_miniserv_config(\%miniserv);
47 $proto = $miniserv{'ssl'} ? 'https' : 'http';
48 $port = $miniserv{'port'};
49 $url = $proto."://".&get_system_hostname().":".$port."/$module_name/";
50 $body .= "Updates can be installed at $url\n\n";
54 if ($config{'sched_email'} && $body) {
55 &foreign_require("mailboxes", "mailboxes-lib.pl");
56 my $from = &mailboxes::get_from_address();
57 my $mail = { 'headers' =>
59 [ 'To', $config{'sched_email'} ],
60 [ 'Subject', "Package updates on ".
61 &get_system_hostname() ] ],
63 [ { 'headers' => [ [ 'Content-type', 'text/plain' ] ],
64 'data' => $body } ] };
65 &mailboxes::send_mail($mail, undef, 1, 0);