Subversion Repositories camp_sysinfo_client_3

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
16 rodolico 1
#!/usr/bin/env perl
8 rodolico 2
 
16 rodolico 3
use warnings;
4
 
20 rodolico 5
$main::VERSION = '1.0';
6
 
7
my %installedVersions;
8
 
13 rodolico 9
my $thisDir = `pwd`;
10
chomp $thisDir;
11
 
12
my $targetDir = '/opt/camp/sysinfo-client';
13
my $modulesDir = $targetDir . '/modules';
14
my $scriptsDir = $targetDir . '/scripts';
18 rodolico 15
my $confDir = '/etc/camp/sysinfo-client';
13 rodolico 16
 
20 rodolico 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
 
11 rodolico 30
# an extremely basic installer for sysinfo-client
9 rodolico 31
 
13 rodolico 32
for $dir ( $targetDir, $modulesDir, $scriptsDir, $confDir, $confDir . '/modules', $confDir . '/scripts' ) {
33
   next if -d $dir;
11 rodolico 34
   `mkdir -p $dir`;
35
   `chmod 0700 $dir`;
36
   `chown root:root $dir`;
10 rodolico 37
}
8 rodolico 38
 
11 rodolico 39
for $dir ( 'modules', 'scripts' ) {
13 rodolico 40
   `cp -av $dir $targetDir`;
18 rodolico 41
   `rm -fR $targetDir/$dir/.svn`;
42
   `chmod 0700 $targetDir/$dir`;
43
   if ( $dir eq 'scripts' ) {
44
      `chmod -fR 0700 $targetDir/$dir/*`;
45
   } else {
46
      `chmod -fR 0600 $targetDir/$dir/*`;
47
   }
48
   `chown -fR root:root $targetDir/$dir`;
10 rodolico 49
}
50
 
18 rodolico 51
for $file ( 'sysinfo-client','notes', 'sysinfo-client.conf.template','configure.pl', 'uninstall.pl' ) {
13 rodolico 52
   `cp $file $targetDir`;
53
   `chmod 0600 $targetDir/$file`;
54
   `chown root:root $targetDir/$file`;
8 rodolico 55
}
56
 
18 rodolico 57
# Set permissions
20 rodolico 58
for my $file ( "$targetDir/sysinfo-client", "$targetDir/configure.pl", "$targetDir/uninstall.pl" ) {
59
   `chmod 0700 $file`;
60
   &getVersion( $file );
61
}
8 rodolico 62
 
20 rodolico 63
open LOG, ">$targetDir/versions" or die "could not open $targetDir/versions for write: $!\n";
64
foreach my $file ( keys %installedVersions ) {
65
   print LOG "$file\t$installedVersions{$file}\n";
66
}
67
close LOG;
68
 
13 rodolico 69
exec( "$thisDir/configure.pl" );
8 rodolico 70
 
13 rodolico 71
 
72
 
73
# rm -fRv /opt/camp/sysinfo-client/ /etc/camp/modules/ /etc/camp/scripts/ /usr/local/bin/sysinfo-client