#!/usr/bin/perl
# -------------------------------------------------------------------------
# -  (c) MICROBITCA, S.L.           ENERO 2000                            -
# - Scrip de instalacion de las CTTOOLS                                   -
# -------------------------------------------------------------------------

print "*---------------------------------------------------\n";
print "* (C) MICROBOTICA, S.L.  ENERO 2000                *\n";
print "*---------------------------------------------------\n";
print "Instalacion de las CTTOOLS\n\n";

$user=`id | grep -c  root`; 
if ($user != 1) {
  print "No tienes privilegios de root!!\n";
  print "INSTALACION ABORTADA.\n";
  exit 1;
}

@fich=`ls`;             # Leer todos los ficheros del directorio
$numfich=@fich;

for ($i=0; $i<$numfich; $i++) {      # Recorrer todos los ficheros
  chomp($fich[$i]);
  if (-d $fich[$i]) {                # Si es un directorio
    chdir("$fich[$i]/src");          # Ejecutar script de instalacion
    $p=system("make install");
    if ($p!=0) {
      print "INSTALACION ABORTADA.\n";
      exit 1;
    }
    chdir("../..");
  }
}

`cp ./cttools.1 /opt/microbotica/$ARGV[0]/man`;
`ln -s /opt/microbotica/$ARGV[0]/man/cttools.1 /usr/man/man1/cttools.1 2> /dev/null`;
`cp ./README /opt/microbotica/$ARGV[0]/doc`;


print "\n";
print "INSTALACION FINALIZADA\n\n";
print "Teclee man cttools para obtener ayuda\n";


