(file) Return to dcstab.pl CVS log (file) (dir) Up to [Development] / JSOC / proj / datacapture / scripts

File: [Development] / JSOC / proj / datacapture / scripts / dcstab.pl (download)
Revision: 1.3, Thu Nov 6 18:31:09 2008 UTC (14 years, 6 months ago) by production
Branch: MAIN
CVS Tags: Ver_LATEST, Ver_9-5, Ver_9-41, Ver_9-4, Ver_9-3, Ver_9-2, Ver_9-1, Ver_9-0, Ver_8-8, Ver_8-7, Ver_8-6, Ver_8-5, Ver_8-4, Ver_8-3, Ver_8-2, Ver_8-12, Ver_8-11, Ver_8-10, Ver_8-1, Ver_8-0, Ver_7-1, Ver_7-0, Ver_6-4, Ver_6-3, Ver_6-2, Ver_6-1, Ver_6-0, Ver_5-9, Ver_5-8, Ver_5-7, Ver_5-6, Ver_5-5, Ver_5-3, Ver_5-2, Ver_5-14, Ver_5-13, Ver_5-12, Ver_5-11, Ver_5-10, Ver_5-1, Ver_5-0, HEAD
Changes since 1.2: +11 -4 lines
also cp to j0

#!/usr/bin/perl
#/home/production/cvs/JSOC/proj/datacapture/scripts/dcstab.pl
#
#Display or change the file:
#/home/production/cvs/JSOC/proj/datacapture/scripts/dsctab.txt
#which assigns the AIA and HMI processing to a datacapture machine
#hostname like so:
#
#AIA=dcs0
#HMI=dcs1
#
#The offsite dcs3 machine is typically assigned like so:
#AIA=dcs3
#HMI=dcs3

sub usage {
  print "Display or change the datacapture system assignment file.\n";
  print "Usage: dcstab [-h][-l][-e]\n";
  print "       -h = print this help message\n";
  print "       -l = list the current file contents\n";
  print "       -e = edit with vi the current file contents\n";
  exit(1);
}

$DCSTABDIR = "/home/production/cvs/JSOC/proj/datacapture/scripts";
$DCSTABFILE = "$DCSTABDIR/dcstab.txt";

$list = $editflg = 0;

while ($ARGV[0] =~ /^-/) {
  $_ = shift;
  if (/^-h(.*)/) {
    &usage;
    exit(0);
  }
  if (/^-l(.*)/) {
    $list = 1;
  }
  if (/^-e(.*)/) {
    $editflg = 1;
  }
}
if($list && $editflg) {
  print "Error: Only one option (-l or -e) can be given\n";
  exit(1);
}
if(!$list && !$editflg) {
  &usage;
  exit(1);
}
if($list) {
  @table = `cat $DCSTABFILE`;
  while($x = shift(@table)) {
    print "$x";
  }
  exit(0);
}
$cmd = "vi $DCSTABFILE";
system($cmd);

$thishost = `hostname -s`;
chomp($thishost);
print "This host = $thishost\n";
if($thishost eq 'dcs3') {
  print "Assignment complete on dcs3\n";
  exit(0);
}

if($thishost eq 'dcs0') {
  @hosts = (dcs1,dcs2,j0);
}
elsif($thishost eq 'dcs1') {
  @hosts = (dcs0,dcs2,j0);
}
elsif($thishost eq 'dcs2') {
  @hosts = (dcs0,dcs1,j0);
}

print "\nNow attempt to replicate this file other datacapture machines\n";
while($x = shift(@hosts)) {
  $cmd = "scp $DCSTABFILE $x:$DCSTABDIR";
  print "$cmd\n";
  if(system($cmd)) {
    if($x eq "j0") {
      print "\n***FATAL ERROR: file must be copied to j0\n";
    }
    else {
      print "*Looks like $x is off line?\n\n";
    }
  }
}

Karen Tian
Powered by
ViewCVS 0.9.4