/[cvs]/jonen/perl/scripts/sysTools/debian/apt-get_remote.pl
ViewVC logotype

Annotation of /jonen/perl/scripts/sysTools/debian/apt-get_remote.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Mon Feb 3 10:04:56 2003 UTC (21 years, 5 months ago) by jonen
Branch: MAIN
File MIME type: text/plain
+ first init

1 jonen 1.1 #!/usr/bin/perl
2     ######################################
3     # $Id$
4     ######################################
5     # $Log$
6     #
7     ######################################
8    
9    
10     =pod
11    
12     =head2 apt-get_remote.pl - remote apt-get via mail, web etc.
13    
14     Sebastian Utz S<seut@netfrag.org>
15    
16     B<last changes>
17    
18     $Id$
19    
20     =head3 Description
21    
22     Currently, it generates only filtered output of 'apt-get update; apt-get --dry-run upgrade' to e.g. mail via cronjob to some user.
23    
24     =head3 ToDo
25    
26     o generates html output and replace 'o' with e.g. a 'checkbox'
27     o add action to do a upgrade to all packages
28     o make this available via http
29     o get response via mail, http, etc. and check selected packages
30     o install selected packages
31     o some more functions:
32     o generate list of all installed packages
33     o generate list of all not-installed packages
34     o generate list of all 'old' packages
35     o generate list of all '-dev' and unused packages
36    
37    
38     =cut
39    
40    
41     use strict;
42     use warnings;
43    
44     use Data::Dumper;
45     use Sys::Hostname;
46    
47     my $hostname = hostname();
48    
49     my $apt_get = "/usr/bin/apt-get";
50     my $apt_update = $apt_get . " update";
51     my $apt_upgrade = $apt_get . " -y upgrade";
52     my $apt_dry_upgrade = $apt_get . " --dry-run upgrade";
53    
54     my $result = `$apt_dry_upgrade`;
55    
56     my @raw_data = split("\n", $result);
57    
58     my @new_lines;
59    
60     push @new_lines, "Checking for upgrade available packages for '". $hostname . "':\n";
61    
62     my $count_lines = $#raw_data;
63     my $cnt = 1;
64     foreach(@raw_data) {
65     if($_ =~ /^\s\s/ ) {
66     s/^\s\s/ /;
67     my @packages = split(" ", $_);
68     foreach(@packages) {
69     push @new_lines, " o " . $_;
70     }
71     }
72     elsif($_ =~ /packages upgraded,/ ) {
73     push @new_lines, $_;
74     if($raw_data[$cnt] =~ /or removed\.$/) {
75     push @new_lines, $raw_data[$cnt];
76     splice(@raw_data, $cnt, 1);
77     }
78     push @new_lines, "\n";
79     push @new_lines, "New Packages available for upgrade:";
80     }
81     elsif( $_ =~ /^Inst/ ) {
82     push @new_lines, " o " . $_;
83     }
84     elsif( $_ !~ /^Conf/ ) {
85     push @new_lines, " o " . $_;
86     }
87     if($cnt == $count_lines) {
88     push @new_lines, "\n\n";
89     }
90     $cnt++;
91     }
92    
93    
94     print join("\n", @new_lines);

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed