Subversion Repositories camp_sysinfo_client_3

Rev

Rev 18 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18 Rev 20
Line 1... Line 1...
1
#!/usr/bin/env perl
1
#!/usr/bin/env perl
2
 
2
 
3
use warnings;
3
use warnings;
4
 
4
 
-
 
5
$main::VERSION = '1.0';
-
 
6
 
-
 
7
my %installedVersions;
-
 
8
 
5
my $thisDir = `pwd`;
9
my $thisDir = `pwd`;
6
chomp $thisDir;
10
chomp $thisDir;
7
 
11
 
8
my $targetDir = '/opt/camp/sysinfo-client';
12
my $targetDir = '/opt/camp/sysinfo-client';
9
my $modulesDir = $targetDir . '/modules';
13
my $modulesDir = $targetDir . '/modules';
10
my $scriptsDir = $targetDir . '/scripts';
14
my $scriptsDir = $targetDir . '/scripts';
11
my $confDir = '/etc/camp/sysinfo-client';
15
my $confDir = '/etc/camp/sysinfo-client';
12
 
16
 
-
 
17
 
-
 
18
sub getVersion {
-
 
19
   my $file = shift;
-
 
20
   my $version .= `md5sum $file`;
-
 
21
   chomp $version;
-
 
22
   $version =~ m/^([a-f0-9]+)/;
-
 
23
   $version = "$1\t";
-
 
24
   $version .= `$file -v`;
-
 
25
   chomp $version;
-
 
26
   $installedVersions{$file} = $version;
-
 
27
}
-
 
28
   
-
 
29
 
13
# an extremely basic installer for sysinfo-client
30
# an extremely basic installer for sysinfo-client
14
 
31
 
15
for $dir ( $targetDir, $modulesDir, $scriptsDir, $confDir, $confDir . '/modules', $confDir . '/scripts' ) {
32
for $dir ( $targetDir, $modulesDir, $scriptsDir, $confDir, $confDir . '/modules', $confDir . '/scripts' ) {
16
   next if -d $dir;
33
   next if -d $dir;
17
   `mkdir -p $dir`;
34
   `mkdir -p $dir`;
Line 36... Line 53...
36
   `chmod 0600 $targetDir/$file`;
53
   `chmod 0600 $targetDir/$file`;
37
   `chown root:root $targetDir/$file`;
54
   `chown root:root $targetDir/$file`;
38
}
55
}
39
 
56
 
40
# Set permissions
57
# Set permissions
-
 
58
for my $file ( "$targetDir/sysinfo-client", "$targetDir/configure.pl", "$targetDir/uninstall.pl" ) {
41
`chmod 0700 $targetDir/sysinfo-client`;
59
   `chmod 0700 $file`;
42
`chmod 0700 $targetDir/configure.pl`;
60
   &getVersion( $file );
-
 
61
}
-
 
62
 
-
 
63
open LOG, ">$targetDir/versions" or die "could not open $targetDir/versions for write: $!\n";
43
`chmod 0700 $targetDir/uninstall.pl`;
64
foreach my $file ( keys %installedVersions ) {
-
 
65
   print LOG "$file\t$installedVersions{$file}\n";
-
 
66
}
-
 
67
close LOG;
44
 
68
 
45
exec( "$thisDir/configure.pl" );
69
exec( "$thisDir/configure.pl" );
46
 
70
 
47
 
71
 
48
 
72