Subversion Repositories camp_sysinfo_client_3

Rev

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

Rev 16 Rev 18
Line 2... Line 2...
2
 
2
 
3
use warnings;
3
use warnings;
4
 
4
 
5
my $seedFile = 'sysinfo-client.seed';
5
my $seedFile = 'sysinfo-client.seed';
6
my $sysinfo2 = '/etc/sysinfo/sysinfo.conf';
6
my $sysinfo2 = '/etc/sysinfo/sysinfo.conf';
7
my $sysinfo3 = '/etc/camp/sysinfo-client.conf';
7
my $sysinfo3 = '/etc/camp/sysinfo-client/sysinfo-client.conf';
8
my $configPath = '/etc/camp';
8
my $configPath = '/etc/camp/sysinfo-client';
9
my $configFile = 'sysinfo-client.conf';
9
my $configFile = 'sysinfo-client.conf';
10
 
10
 
11
my $clientName = '';
11
my $clientName = '';
12
my $serialNumber = '';
12
my $serialNumber = '';
13
my $hostname;
13
my $hostname;
14
my @moduleDirs = ( '/opt/camp/sysinfo/modules', '/etc/camp/modules' );
14
my @moduleDirs = ( '/opt/camp/sysinfo-client/modules', '/etc/camp/sysinfo-client/modules' );
15
my @scriptDirs = ( '/opt/camp/sysinfo/scripts', '/etc/camp/scripts' );
15
my @scriptDirs = ( '/opt/camp/sysinfo-client/scripts', '/etc/camp/sysinfo-client/scripts' );
16
my $transports = {}; # holds transportation mechanisms
16
my $transports = {}; # holds transportation mechanisms
17
# the following are keys which are specific to the different transport channels
17
# the following are keys which are specific to the different transport channels
18
 
18
 
19
my %sendTypes = ( 
19
my %sendTypes = ( 
20
                  'SendEmail' =>    { 'sendScript' => 'sendEmailScript',
20
                  'SendEmail' =>    { 'sendScript' => 'sendEmailScript',
Line 188... Line 188...
188
   print "All IPFire specific modules have been enabled\n";
188
   print "All IPFire specific modules have been enabled\n";
189
}
189
}
190
 
190
 
191
# some debian specific things
191
# some debian specific things
192
sub debian {
192
sub debian {
-
 
193
   if ( &yesno( 'Add link to cron.daily' ) ) {
193
   `ln -s /opt/camp/sysinfo/sysinfo-client /etc/cron.daily/sysinfo` 
194
      `rm /etc/cron.daily/sysinfo` if -e '/etc/cron.daily/sysinfo';
194
      if &yesno( 'Add link to cron.daily' );
195
      `ln -s /opt/camp/sysinfo-client/sysinfo-client /etc/cron.daily/sysinfo`;
-
 
196
   }
195
   if ( `dpkg --get-selections | grep  sysinfo-client | grep install` 
197
   if ( `dpkg --get-selections | grep  sysinfo-client | grep install` 
196
      && &yesno ('It looks like sysinfo version 2 is installed via apt, should I remove it' ) ) {
198
      && &yesno ('It looks like sysinfo version 2 is installed via apt, should I remove it' ) ) {
197
      if ( &yesno( 'Back up old configuration? ') ) {
199
      if ( &yesno( 'Back up old configuration? ') ) {
198
         `tar -czvf /root/sysinfo.2.config.tgz /etc/sysinfo`;
200
         `tar -czvf /root/sysinfo.2.config.tgz /etc/sysinfo`;
199
         print "Old configuration copied to /root/sysinfo.2.config.tgz\n";
201
         print "Old configuration copied to /root/sysinfo.2.config.tgz\n";
200
      }
202
      }
201
      `apt-get -y --purge remove sysinfo-client`;
203
      `apt-get -y --purge remove sysinfo-client`;
202
      print "There may be some unused packages now. You can remove them with\napt-get autoremove\n\n";
204
      print "There may be some unused packages now. You can remove them with\napt-get autoremove\n\n";
203
   }
205
   }
-
 
206
   if ( &yesno( 'Would you like a link to /usr/local/bin/sysinfo-client' ) ) {
204
   `ln -s  /opt/camp/sysinfo/sysinfo-client /usr/local/bin/sysinfo-client` 
207
      `rm /usr/local/bin/sysinfo-client` if -e '/usr/local/bin/sysinfo-client';
205
      if &yesno( 'Would you like a link to /usr/local/bin/sysinfo-client' );
208
      `ln -s  /opt/camp/sysinfo/sysinfo-client /usr/local/bin/sysinfo-client`;
-
 
209
   }
-
 
210
 
206
   # set all modules with debian or unix in the name to run
211
   # set all modules with debian or unix in the name to run
207
   foreach my $directory ( @moduleDirs ) {
212
   foreach my $directory ( @moduleDirs ) {
208
      opendir ( $dh, $directory ) or die "Could not open directory [$directory]\n";
213
      opendir ( $dh, $directory ) or die "Could not open directory [$directory]\n";
209
      my @modules = grep { /^((dpkg)|(unix))/ } readdir $dh;
214
      my @modules = grep { /^((dpkg)|(unix))/ } readdir $dh;
210
      closedir $dh;
215
      closedir $dh;
Line 295... Line 300...
295
      $return .= "Old config copied to $filename.bak\n";
300
      $return .= "Old config copied to $filename.bak\n";
296
   }
301
   }
297
   open CONF,">$filename" or die "Could not write to $filename: $!\n";
302
   open CONF,">$filename" or die "Could not write to $filename: $!\n";
298
   print CONF $content;
303
   print CONF $content;
299
   close CONF;
304
   close CONF;
-
 
305
   `chmod 600 $filename`;
300
   $return .= "Configuration successfully written to $filename\n";
306
   $return .= "Configuration successfully written to $filename\n";
301
   return $return;
307
   return $return;
302
}
308
}
303
 
309
 
304
sub convertSysinfo2 {
310
sub convertSysinfo2 {
Line 371... Line 377...
371
&doTransports( $transports );
377
&doTransports( $transports );
372
 
378
 
373
print "The following is the configuration I'll write out\n" . '-'x40 . "\n";
379
print "The following is the configuration I'll write out\n" . '-'x40 . "\n";
374
print &showConf(  );
380
print &showConf(  );
375
print '-'x40 . "\n";
381
print '-'x40 . "\n";
376
#print &writeConfig( $configPath, $configFile, &showConf() ) if &yesno( "Write this configuration" );
382
print &writeConfig( $configPath, $configFile, &showConf() ) if &yesno( "Write this configuration" );
377
 
383
 
378
 
384
 
379
my $os = &getOperatingSystem();
385
my $os = &getOperatingSystem();
380
if ( $os && &yesno( "I recognize this system, may I automatically set up a few things" ) ) {
386
if ( $os && &yesno( "I recognize this system, may I automatically set up a few things" ) ) {
381
   &ipFire() if $os eq 'ipfire';
387
   &ipFire() if $os eq 'ipfire';