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" != "" ]]; thenecho "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 ] ; thendistro=`$lsbrel -i | $awk '{print $(NF)}'`nombre=`$lsbrel -c | $awk '{print $(NF)}'`release=`$lsbrel -r | $awk '{print $(NF)}' | cut -f1 -d"." `elseif [ -f /etc/redhat-release ] ; thendistro=`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" ]] ; thenrelease=`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'`fielif [ -f /etc/debian_version ] ; thendistro=`awk '{print $1}' /etc/issue`if [[ "$distro" == "Debian" ]] ; thenrelease=`awk '{print $3}' /etc/issue`nombre=`grep "VERSION=" /etc/os-release | sed -e "s/\"//g" -e 's/(//g' -e 's/)//g' | awk '{print $2}'`elserelease=`awk '{print $2}' /etc/issue`nombre=`awk '{print $1}' /etc/debian_version | cut -f1 -d'/'`fififi# Versiones de Debianversion=`echo $release | cut -f1 -d'.'`case $distro inDebian)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";;esacecho "$distro $nombre $version $release $family $package"# Salidaexit 0