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

print "*---------------------------------------------------\n";
print "* (C) MICROBOTICA, S.L.  AGOSTO 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 "DESINSTALACION 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 desinstall");
    if ($p!=0) {
      print "DESINSTALACION ABORTADA.\n";
      exit 1;
    }
    chdir("../..");
  }
}

`rm -r /opt/microbotica/$ARGV[0]`;
`rm -f /usr/man/man1/cttools.1`;

print "\n";
print "DESINSTALACION FINALIZADA\n\n";


