Subversion Repositories camp_sysinfo_client_3

Rev

Rev 244 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
229 rodolico 1
#! /usr/bin/env perl
2
 
3
use warnings;
4
use strict;  
5
 
6
# find our location and use it for searching for libraries
7
BEGIN {
8
   use FindBin;
9
   use File::Spec;
10
   # use libraries from the directory this script is in
11
   use lib File::Spec->catdir($FindBin::Bin);
12
   # and its parent
13
   use lib File::Spec->catdir( $FindBin::Bin . '/../' );
14
   eval( 'use YAML::Tiny' );
15
}
16
 
17
use Cwd qw(abs_path);
18
use sysinfosetup;
19
 
20
our $DEBUG;
21
# $DEBUG = 1;
22
 
23
my $scriptDir = abs_path(File::Spec->catdir($FindBin::Bin) );
24
my $binDir = abs_path("$scriptDir/../"); # bin directory assumed to be above this one
242 rodolico 25
my $runPeriodicFlag = 'touch /tmp/sysinfo.firstrun'; # this is a flag that says to go ahead and run periodic scripts
229 rodolico 26
 
27
sub checkDirectory {
28
   my $directory = shift;
29
   print "In checkDirectory, looking in $directory\n";
30
   my @dirs;
31
 
32
   if ( -d $directory ) { # we found a modules directory
33
      opendir( my $dh, $directory ) || die "Could not read from $scriptDir/modules:$!\n";
34
      @dirs = grep { -f "$directory/$_" } readdir($dh);
35
      closedir $dh;
36
   }
37
   #die "dirs is " . join("\n", @dirs ) . "\n";
38
   while ( my $script = shift(@dirs) ) {
39
      next if $script =~ /\..+$/; # ignore anything with a period in it
40
      next if $script =~ /README/; # ignore readme
41
      print "Checking $directory/$script\n";
242 rodolico 42
      &runCommand( $runPeriodicFlag ); # ensure we will attempt to run all periodic scripts also
230 rodolico 43
      &runCommand( "chmod 755 $directory/$script" );
229 rodolico 44
      my $output = `$directory/$script $directory`;
45
      my $mod = $output ? '700' : '600';
46
      &runCommand( "chmod $mod $directory/$script" );
47
   }
48
}
49
 
50
# setting permissions
51
 
52
&runCommand( "chown -fR root:root $binDir" );
53
&runCommand( "chmod 700 $binDir/sysinfo-client" );
54
&runCommand( "chmod 700 $binDir/configure" );
55
 
56
&checkDirectory( "$binDir/modules" );