#!/usr/bin/bash
#################################################
# Script de desinstalacion 
#------------------------------------------------
# MICROBOTICA, S.L.  JULIO 2000
#------------------------------------------------
# www.microbotica.es
# info@microbotica.es
#################################################

name=ctdetect      # Nombre de la aplicacion

echo ------------------------------------------------
echo -  $1  $name MICROBOTICA.SL, Julio 2000  
echo - DESINSTALACION DEL PAQUETE        
echo ------------------------------------------------
echo
#----------------------------------------------
# Comprobar si se tiene privilegios de root  
#----------------------------------------------
if [ $(id | grep -c root) == 0 ]
then
  echo "NO TIENES PRIVILEGIOS DE ROOT"
  exit 1
fi
#----------------------------------------------------------
# Comprobar si se ha pasado como parametro el directorio
#----------------------------------------------------------
if [ $# != 1 ]
then
  echo "Numero de parametros incorrecto"
  exit 1
fi 

#--------------------------------------------------------
# Crear una variable con el directorio destino de 
# desinstalacion                                           
#--------------------------------------------------------
DIRDESINSTALA="/opt/microbotica/"$1

#-------------------------------------------------
# Comprobar si existe el paquete indicado
#-------------------------------------------------
if [ -d $DIRDESINSTALA ]
then
  rm -f $DIRDESINSTALA/bin/$name
  rm -f $DIRDESINSTALA/man/$name.1
  rm -f /usr/bin/$name
  rm -f /usr/man/man1/$name.1
else
  echo "No existe el directorio: "$DIRDESINSTALA
  exit 1
fi

echo "DESINSTALACION DE $name COMPLETADA"


