Script para determinar distribucion which_distro

Siempre ha sido un problema hacer scripts portables. En kuine es un dolor de cabeza asi que termine haciendo un script.  A continuación

#!/bin/bash

#************************************************************************
# Identifica que version se esta corriendo 
#
# CATEGORY      main
# PACKAGE       Kuine
# SUBPACKAGE
# AUTHOR        JEG <Esta dirección de correo electrónico está protegida contra spambots. Usted necesita tener Javascript activado para poder verla.;
# COPYRIGHT     2018 Skina Technologies Ltda.
# LICENSE       ./LICENSE.txt
# LINK          https://www.skinatech.com
# SINCE
#
# PARAM    Opciones
#
# SINTAXIS USE:       which_distro
#
# RETORNO: distro nombre version release family package
#
# DATE: Oct 2018
#***********************************************************************/
 
DEBUG=0   # 0 no debug 1 test 2 debug
 
#       *********************************************************
#       *               Variables Globales al archivo           *
#       *********************************************************
 
 
awk=`which awk`
lsbrel=`which lsb_release`
 
#       *********************************************************
#       *               Inclusion de libreria                   *
#       *********************************************************
 
 
#       *********************************************************
#       *                   Funciones                           *
#       *********************************************************
 
#       *********************************************************
#       *                        MAIN                           *
#       *********************************************************
 
 
if [[ "$1" != "" ]]; then
   echo "USE: which_distro "
   echo "Returns: distro nombre version release family package"
   echo "         distro:  Debian, RedHat, Ubuntu, etc .."
   echo "         nombre:  Wheezy, Stretch, Core, Lucy, etc"
   echo "         version: Number of version 8, 5, 8"
   echo "         family: debian, redhat, suse, etc "
   echo "         package: apt, rpm, etc "
fi
 
#------------------------------------------------------------------------------
############  Identifique version
#------------------------------------------------------------------------------
if [ -x $lsbrel ] ; then
   distro=`$lsbrel -i | $awk '{print $(NF)}'`
   nombre=`$lsbrel -c | $awk '{print $(NF)}'`
   release=`$lsbrel -r | $awk '{print $(NF)}' | cut -f1 -d"." `
else
   if [ -f /etc/redhat-release ] ; then
      distro=`awk '{print $1}'  /etc/redhat-release`
      release=`awk '{print $3}'  /etc/redhat-release`
      nombre=`awk '{print $4}'  /etc/redhat-release  | $awk '{print $(NF)}' | sed -e "s/\"//g" -e 's/(//g' -e 's/)//g'`
      if [[ "$release" == "release" ]] ; then
         release=`awk '{print $4}'  /etc/redhat-release `
         nombre=`awk '{print $5}'  /etc/redhat-release | $awk '{print $(NF)}' | sed -e "s/\"//g" -e 's/(//g' -e 's/)//g'`
      fi
   elif [ -f /etc/debian_version ] ; then
      distro=`awk '{print $1}'  /etc/issue`
      if [[ "$distro" == "Debian" ]] ; then
         release=`awk '{print $3}'  /etc/issue`
         nombre=`grep "VERSION=" /etc/os-release | sed -e "s/\"//g" -e 's/(//g' -e 's/)//g' | awk '{print $2}'`
      else
         release=`awk '{print $2}'  /etc/issue`
         nombre=`awk '{print $1}' /etc/debian_version | cut -f1 -d'/'`
      fi
   fi
fi
 
# Versiones de Debian
version=`echo $release | cut -f1 -d'.'`
case $distro in
   Debian)
family="debian" ; package="apt"  
       ;;
   Ubuntu)
family="ubuntu" ; package="apt"  
       ;;
   LinuxMint)
family="ubuntu" ; package="apt"  
       ;;
   Fedora)
family="redhat" ; package="yum"  
       ;;
   CentOS|RedHat|Scientific|RedHatEnterpriseServer)
         family="redhat" ; package="yum"  
       ;;
esac
 
echo "$distro $nombre $version $release $family $package"
 
# Salida
exit 0