Subversion Repositories camp_sysinfo_client_3

Rev

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

Rev 45 Rev 53
Line 19... Line 19...
19
our @EXPORT = qw( $clientName $serialNumber $hostname @moduleDirs @scriptDirs 
19
our @EXPORT = qw( $clientName $serialNumber $hostname @moduleDirs @scriptDirs 
20
                  $transports $sysinfo3 %sendTypes $binDir $moduleDir
20
                  $transports $sysinfo3 %sendTypes $binDir $moduleDir
21
                  $scriptDir $confDir $binName $confName
21
                  $scriptDir $confDir $binName $confName
22
                  &showConf &transportsToConfig &getAnswer &yesno  
22
                  &showConf &transportsToConfig &getAnswer &yesno  
23
                  &writeConfig &processParameters $TESTING &checkDirectoryExists
23
                  &writeConfig &processParameters $TESTING &checkDirectoryExists
24
                  &runCommand &setDryRun &enableModules &makeConfig
24
                  &runCommand &setDryRun &enableModules &makeConfig &findConf
25
                );
25
                );
26
 
26
 
27
our $TESTING = 0;
27
our $TESTING = 0;
28
our $dryRun;
28
our $dryRun;
29
our $clientName = '';
29
our $clientName = '';
30
our $serialNumber = '';
30
our $serialNumber = '';
31
our $hostname = '';
31
our $hostname = '';
-
 
32
 
-
 
33
my @installDirs = ( '/opt/camp/sysinfo-client', '/usr/local/opt/camp/sysinfo-client' );
-
 
34
my @confDirs =    ( '/etc/camp/sysinfo-client', '/usr/local/etc/camp/sysinfo-client' );
-
 
35
 
-
 
36
 
32
our @moduleDirs = ( '/opt/camp/sysinfo-client/modules', '/etc/camp/sysinfo-client/modules' );
37
our @moduleDirs = ( '/opt/camp/sysinfo-client/modules', '/etc/camp/sysinfo-client/modules' );
33
our @scriptDirs = ( '/opt/camp/sysinfo-client/scripts', '/etc/camp/sysinfo-client/scripts' );
38
our @scriptDirs = ( '/opt/camp/sysinfo-client/scripts', '/etc/camp/sysinfo-client/scripts' );
34
our $transports = {}; # holds transportation mechanisms
39
our $transports = {}; # holds transportation mechanisms
35
# the following are keys which are specific to the different transport channels
40
# the following are keys which are specific to the different transport channels
36
 
41
 
37
our $sysinfo3 = '/etc/camp/sysinfo-client/sysinfo-client.conf';
42
our $sysinfo3 = 'sysinfo-client.conf';
38
 
43
 
39
our $binDir = '/opt/camp/sysinfo-client';
44
our $binDir = '/opt/camp/sysinfo-client';
40
our $moduleDir = $binDir . '/modules';
45
our $moduleDir = $binDir . '/modules';
41
our $scriptDir = $binDir . '/scripts';
46
our $scriptDir = $binDir . '/scripts';
42
our $confDir = '/etc/camp/sysinfo-client';
47
our $confDir = '/etc/camp/sysinfo-client';
Line 106... Line 111...
106
   $conf .= "\$clientName = '" .   ( defined( $$configuration{'clientName'}   ) ? $$configuration{'clientName'}   : '' ) . "';\n";
111
   $conf .= "\$clientName = '" .   ( defined( $$configuration{'clientName'}   ) ? $$configuration{'clientName'}   : '' ) . "';\n";
107
   $conf .= "\$serialNumber = '" . ( defined( $$configuration{'serialNumber'} ) ? $$configuration{'serialNumber'} : '' ) . "';\n";
112
   $conf .= "\$serialNumber = '" . ( defined( $$configuration{'serialNumber'} ) ? $$configuration{'serialNumber'} : '' ) . "';\n";
108
   $conf .= "\$hostname = '" .     ( defined( $$configuration{'hostname'}     ) ? $$configuration{'hostname'}     : '' ) . "';\n";
113
   $conf .= "\$hostname = '" .     ( defined( $$configuration{'hostname'}     ) ? $$configuration{'hostname'}     : '' ) . "';\n";
109
   $conf .= "\@moduleDirs = ('" . join( "','", @{ $$configuration{ 'moduleDirs' } } ) . "');\n";
114
   $conf .= "\@moduleDirs = ('" . join( "','", @{ $$configuration{ 'moduleDirs' } } ) . "');\n";
110
   $conf .= "\@scriptDirs = ('" . join( "','", @{ $$configuration{ 'scriptDirs' } } ) . "');\n";
115
   $conf .= "\@scriptDirs = ('" . join( "','", @{ $$configuration{ 'scriptDirs' } } ) . "');\n";
111
   $conf .= &transportsToConfig( $$configuration{ 'transports' } );
116
   $conf .= &transportsToConfig( $$configuration{ 'transports' } ) if defined( $$configuration{ 'transports' } );
112
   return $conf;
117
   return $conf;
113
}
118
}
114
 
119
 
115
sub transportsToConfig {
120
sub transportsToConfig {
116
   my $transports = shift;
121
   my $transports = shift;
Line 146... Line 151...
146
   }
151
   }
147
   unless ( $hostname ) {
152
   unless ( $hostname ) {
148
      $hostname = `hostname -f`;
153
      $hostname = `hostname -f`;
149
      chomp $hostname;
154
      chomp $hostname;
150
   }
155
   }
-
 
156
   unless ( $serialNumber ) {
-
 
157
      $serialNumber = `dmidecode -t 1 | grep 'Serial Number' | cut -d':' -f2` if `which dmidecode`;
-
 
158
      chomp $serialNumber;
-
 
159
      $serialNumber =~ s/\s//gi;
-
 
160
   }
151
 
161
 
152
 
162
 
153
   $config{'clientName'} = $clientName;
163
   $config{'clientName'} = $clientName;
154
   $config{'serialNumber'} = $serialNumber;
164
   $config{'serialNumber'} = $serialNumber;
155
   $config{'hostname'} = $hostname;
165
   $config{'hostname'} = $hostname;
Line 252... Line 262...
252
         exit;
262
         exit;
253
      }
263
      }
254
   } # while
264
   } # while
255
}
265
}
256
 
266
 
-
 
267
sub findConf {
-
 
268
   my $confName = shift;
-
 
269
   my @confDirs =    ( '/etc/camp/sysinfo-client', '/usr/local/etc/camp/sysinfo-client' );
-
 
270
   for ( my $i = 0; $i < @confDirs; $i++ ) {
-
 
271
      if ( -d $confDirs[ $i ] ) {
-
 
272
         return $confDirs[$i] . '/' . $confName;
-
 
273
      }
-
 
274
   }
257
 
275
}
-
 
276
   
258
 
277
 
259
1;
278
1;