"Fossies" - the Fresh Open Source Software Archive

Member "lynis/include/osdetection" (22 Jul 2021, 38558 Bytes) of package /linux/misc/lynis-3.0.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "osdetection": 3.0.5_vs_3.0.6.

    1 #!/bin/sh
    2 
    3 #################################################################################
    4 #
    5 #   Lynis
    6 # ------------------
    7 #
    8 # Copyright 2007-2013, Michael Boelen
    9 # Copyright 2007-2021, CISOfy
   10 #
   11 # Website  : https://cisofy.com
   12 # Blog     : http://linux-audit.com
   13 # GitHub   : https://github.com/CISOfy/lynis
   14 #
   15 # Lynis comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
   16 # welcome to redistribute it under the terms of the GNU General Public License.
   17 # See LICENSE file for usage of this software.
   18 #
   19 #################################################################################
   20 #
   21 # Operating System detection
   22 #
   23 #################################################################################
   24 #
   25     # Check operating system
   26     case $(uname) in
   27 
   28         # IBM AIX
   29         AIX)
   30             OS="AIX"
   31             OS_NAME="AIX"
   32             OS_VERSION=$(oslevel)
   33             OS_FULLNAME="AIX ${OS_VERSION}"
   34             CPU=$(uname -p)
   35             HARDWARE=$(uname -M)
   36             FIND_BINARIES="whereis -b"
   37             SYSCTL_READKEY=""
   38         ;;
   39 
   40         # Mac OS X and macOS
   41         Darwin)
   42             OS="macOS"
   43             if [ -x /usr/bin/sw_vers ]; then
   44                 OS_NAME=$(/usr/bin/sw_vers -productName)
   45                 OS_VERSION=$(/usr/bin/sw_vers -productVersion)
   46                 OS_VERSION_NAME="unknown"
   47                 OS_FULLNAME="macOS (unknown version)"
   48                 case ${OS_VERSION} in
   49                     10.0 | 10.0.[0-9]*) OS_FULLNAME="Mac OS X 10.0 (Cheetah)" ;;
   50                     10.1 | 10.1.[0-9]*) OS_FULLNAME="Mac OS X 10.1 (Puma)" ;;
   51                     10.2 | 10.2.[0-9]*) OS_FULLNAME="Mac OS X 10.2 (Jaguar)" ;;
   52                     10.3 | 10.3.[0-9]*) OS_FULLNAME="Mac OS X 10.3 (Panther)" ;;
   53                     10.4 | 10.4.[0-9]*) OS_FULLNAME="Mac OS X 10.4 (Tiger)" ;;
   54                     10.5 | 10.5.[0-9]*) OS_FULLNAME="Mac OS X 10.5 (Leopard)" ;;
   55                     10.6 | 10.6.[0-9]*) OS_FULLNAME="Mac OS X 10.6 (Snow Leopard)" ;;
   56                     10.7 | 10.7.[0-9]*) OS_FULLNAME="Mac OS X 10.7 (Lion)" ;;
   57                     10.8 | 10.8.[0-9]*) OS_FULLNAME="Mac OS X 10.8 (Mountain Lion)" ;;
   58                     10.9 | 10.9.[0-9]*) OS_FULLNAME="Mac OS X 10.9 (Mavericks)" ;;
   59                     10.10 | 10.10.[0-9]*) OS_FULLNAME="Mac OS X 10.10 (Yosemite)" ;;
   60                     10.11 | 10.11.[0-9]*) OS_FULLNAME="Mac OS X 10.11 (El Capitan)" ;;
   61                     10.12 | 10.12.[0-9]*) OS_FULLNAME="macOS Sierra (${OS_VERSION})" ;;
   62                     10.13 | 10.13.[0-9]*) OS_FULLNAME="macOS High Sierra (${OS_VERSION})" ;;
   63                     10.14 | 10.14.[0-9]*) OS_FULLNAME="macOS Mojave (${OS_VERSION})" ;;
   64                     10.15 | 10.15.[0-9]*) OS_FULLNAME="macOS Catalina (${OS_VERSION})" ;;
   65                     11 | 11.[0-9]*) OS_FULLNAME="macOS Big Sur (${OS_VERSION})" ;;
   66                     12 | 12.[0-9]*) OS_FULLNAME="macOS Monterey (${OS_VERSION})" ;;
   67                     *) echo "Unknown macOS version. Do you know what version it is? Create an issue at ${PROGRAM_SOURCE}" ;;
   68                 esac
   69             else
   70                 # Fall back to a fairly safe name
   71                 OS_NAME="macOS"
   72                 # uname -s -r shows Darwin 16.1.0
   73                 OS_FULLNAME=$(uname -s -r)
   74                 # shows 16.1.0 for Darwin's version, not macOS's
   75                 OS_VERSION=$(uname -r)
   76             fi
   77             HARDWARE=$(uname -m)
   78             HOMEDIRS="/Users"
   79             FIND_BINARIES="whereis"
   80             OS_KERNELVERSION=$(uname -r)
   81             SYSCTL_READKEY=""
   82         ;;
   83 
   84         # DragonFly BSD
   85         DragonFly)
   86             OS="DragonFly"
   87             OS_NAME="DragonFly BSD"
   88             OS_FULLNAME=$(uname -s -r)
   89             OS_VERSION=$(uname -r)
   90             HARDWARE=$(uname -m)
   91             HOMEDIRS="/home /root"
   92             FIND_BINARIES="whereis -q -a -b"
   93             OS_KERNELVERSION=$(uname -i)
   94             SYSCTL_READKEY="sysctl -n"
   95         ;;
   96 
   97         # FreeBSD
   98         FreeBSD)
   99             OS="FreeBSD"
  100             OS_NAME="FreeBSD"
  101             OS_FULLNAME=$(uname -s -r)
  102             OS_VERSION=$(uname -r)
  103             HARDWARE=$(uname -m)
  104             HOMEDIRS="/home /root"
  105             FIND_BINARIES="whereis -q -a -b"
  106             OS_KERNELVERSION=$(uname -i)
  107             SYSCTL_READKEY="sysctl -n"
  108 
  109             # TrueOS
  110             if [ -f /etc/defaults/trueos ]; then
  111                 OS_NAME="TrueOS"
  112                 LogText "Result: found TrueOS file, system is completely based on FreeBSD though. Only adjusting OS name."
  113             fi
  114         ;;
  115 
  116         # HP-UX
  117         HP-UX)
  118             OS="HP-UX"
  119             OS_NAME="HP-UX"
  120             OS_FULLNAME=$(uname -s -r)
  121             OS_VERSION=$(uname -r)
  122             HARDWARE=$(uname -m)
  123             FIND_BINARIES="whereis -b"
  124             SYSCTL_READKEY=""
  125             LOGDIR="/var/adm/syslog"
  126         ;;
  127 
  128         # Linux
  129         Linux)
  130             OS="Linux"
  131             OS_NAME="Linux"
  132             OS_FULLNAME=""
  133             OS_VERSION=$(uname -r)
  134             LINUX_VERSION=""
  135             HARDWARE=$(uname -m)
  136             HOMEDIRS="/home"
  137             FIND_BINARIES="whereis -b"
  138             OS_KERNELVERSION_FULL=$(uname -r)
  139             OS_KERNELVERSION=$(echo ${OS_KERNELVERSION_FULL} | sed 's/-.*//')
  140             if [ -e /dev/grsec ]; then GRSEC_FOUND=1; fi
  141 
  142             # Generic
  143             if [ -e /etc/os-release ]; then
  144                 OS_FULLNAME=$(awk -F= '/^PRETTY_NAME=/ {print substr($2,2,length($2)-2)}' /etc/os-release)
  145                 OS_ID=$(grep "^ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  146                 if [ -n "${OS_ID}" ]; then
  147                     case ${OS_ID} in
  148                         "almalinux")
  149                             LINUX_VERSION="AlmaLinux"
  150                             OS_NAME=$(grep "^PRETTY_NAME=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  151                             OS_REDHAT_OR_CLONE=1
  152                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  153                             OS_VERSION_FULL=$(grep "^VERSION=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')                           
  154                         ;;
  155                         "alpine")
  156                             LINUX_VERSION="Alpine Linux"
  157                             OS_NAME=$(grep "^PRETTY_NAME=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  158                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  159                             OS_VERSION_FULL=$(grep "^VERSION=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  160                         ;;
  161                         "amzn")
  162                             LINUX_VERSION="Amazon Linux"
  163                             OS_NAME="Amazon Linux"
  164                             OS_REDHAT_OR_CLONE=1
  165                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  166                         ;;
  167                         "arch")
  168                             LINUX_VERSION="Arch Linux"
  169                             OS_FULLNAME="Arch Linux"
  170                             OS_VERSION="Rolling release"
  171                         ;;
  172                         "arch32")
  173                             LINUX_VERSION="Arch Linux 32"
  174                             OS_FULLNAME="Arch Linux 32"
  175                             OS_VERSION="Rolling release"
  176                         ;;
  177                         "artix")
  178                             LINUX_VERSION="Artix Linux"
  179                             OS_FULLNAME="Artix Linux"
  180                             OS_VERSION="Rolling release"
  181                         ;;
  182                         "bunsenlabs")
  183                             LINUX_VERSION="BunsenLabs"
  184                             OS_NAME="BunsenLabs"
  185                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  186                             OS_VERSION_FULL=$(grep "^VERSION=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  187                         ;;  
  188                         "centos")
  189                             LINUX_VERSION="CentOS"
  190                             OS_NAME="CentOS Linux"
  191                             OS_REDHAT_OR_CLONE=1
  192                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  193                         ;;
  194                         "clear-linux-os")
  195                             LINUX_VERSION="Clear Linux OS"
  196                             OS_NAME="Clear Linux OS"
  197                             OS_REDHAT_OR_CLONE=1
  198                             OS_VERSION="Rolling release"
  199                         ;;
  200                         "cloudlinux")
  201                             LINUX_VERSION="CloudLinux"
  202                             OS_NAME="CloudLinux"
  203                             OS_REDHAT_OR_CLONE=1
  204                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  205                         ;;
  206                         "coreos")
  207                             LINUX_VERSION="CoreOS"
  208                             OS_NAME="CoreOS Linux"
  209                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  210                         ;;
  211                         "debian")
  212                             LINUX_VERSION="Debian"
  213                             OS_NAME="Debian"
  214                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  215                             OS_VERSION_FULL=$(grep "^VERSION=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  216                         ;;                     
  217                         "devuan")
  218                             LINUX_VERSION="Devuan"
  219                             OS_NAME="Devuan"
  220                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  221                             OS_VERSION_FULL=$(grep "^VERSION=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  222                         ;;
  223                         "elementary")
  224                             LINUX_VERSION="elementary OS"
  225                             OS_NAME="elementary OS"
  226                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  227                             OS_VERSION_FULL=$(grep "^VERSION=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  228                         ;;
  229                         "endeavouros")
  230                             LINUX_VERSION="EndeavourOS"
  231                             OS_NAME="EndeavourOS"
  232                             OS_VERSION="Rolling release"
  233                             OS_VERSION_FULL="Rolling release"
  234                         ;;
  235                         "fedora")
  236                             LINUX_VERSION="Fedora"
  237                             OS_NAME="Fedora Linux"
  238                             OS_REDHAT_OR_CLONE=1
  239                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  240                         ;;
  241                         "flatcar")
  242                             LINUX_VERSION="Flatcar"
  243                             LINUX_VERSION_LIKE="CoreOS"
  244                             OS_NAME="Flatcar Linux"
  245                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  246                         ;;
  247                         "garuda")
  248                             LINUX_VERSION="Garuda"
  249                             OS_FULLNAME="Garuda Linux"
  250                             OS_NAME="Garuda"
  251                             OS_VERSION="Rolling release"
  252                         ;;
  253                         "gentoo")
  254                             LINUX_VERSION="Gentoo"
  255                             OS_NAME="Gentoo Linux"
  256                             OS_VERSION="Rolling release"
  257                         ;;
  258                         "ipfire")
  259                             LINUX_VERSION="IPFire"
  260                             OS_NAME="IPFire"
  261                             OS_VERSION=$(grep "^VERSION=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  262                         ;;
  263                         "kali")
  264                             LINUX_VERSION="Kali"
  265                             LINUX_VERSION_LIKE="Debian"
  266                             OS_NAME="Kali Linux"
  267                             OS_VERSION="Rolling release"
  268                         ;;
  269                         "linuxmint")
  270                             LINUX_VERSION="Linux Mint"
  271                             LINUX_VERSION_LIKE="Ubuntu"
  272                             OS_NAME="Linux Mint"
  273                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  274                             OS_VERSION_FULL=$(grep "^VERSION=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  275                         ;;
  276                         "mageia")
  277                             LINUX_VERSION="Mageia"
  278                             OS_NAME="Mageia"
  279                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  280                             OS_VERSION_FULL=$(grep "^VERSION=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  281                         ;;
  282                         "manjaro" | "manjaro-arm")
  283                             LINUX_VERSION="Manjaro"
  284                             OS_FULLNAME="Manjaro Linux"
  285                             OS_NAME="Manjaro"
  286                             OS_VERSION="Rolling release"
  287                         ;;
  288                         "nethserver")
  289                             LINUX_VERSION="NethServer"
  290                             OS_NAME="NethServer"
  291                             OS_REDHAT_OR_CLONE=1
  292                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  293                         ;;
  294                         "nixos")
  295                             LINUX_VERSION="NixOS"
  296                             OS_NAME="NixOS"
  297                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  298                             OS_VERSION_FULL=$(grep "^VERSION=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  299                         ;;
  300                         "ol")
  301                             LINUX_VERSION="Oracle Linux"
  302                             OS_NAME="Oracle Linux"
  303                             OS_REDHAT_OR_CLONE=1
  304                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  305                         ;;
  306                         "opensuse-tumbleweed")
  307                             LINUX_VERSION="openSUSE Tumbleweed"
  308                             # It's rolling release but has a snapshot version (the date of the snapshot)
  309                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  310                             OS_NAME="openSUSE"
  311                         ;;
  312                         "opensuse-leap")
  313                             LINUX_VERSION="openSUSE Leap"
  314                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  315                             OS_NAME="openSUSE"
  316                         ;;
  317                         "opensuse-microos")
  318                             LINUX_VERSION="openSUSE MicroOS"
  319                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  320                             OS_NAME="openSUSE"
  321                         ;;
  322                         "parrot")
  323                             LINUX_VERSION="Parrot"
  324                             OS_NAME="Parrot GNU/Linux"
  325                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  326                             OS_VERSION_FULL=$(grep "^PRETTY_NAME=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  327                         ;;
  328                         "pop")
  329                             LINUX_VERSION="Pop!_OS"
  330                             LINUX_VERSION_LIKE="Ubuntu"
  331                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  332                             OS_VERSION_FULL=$(grep "^VERSION=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  333                             OS_NAME="Pop!_OS"
  334                         ;;
  335                         "pureos")
  336                             LINUX_VERSION="PureOS"
  337                             LINUX_VERSION_LIKE="Debian"
  338                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  339                             OS_VERSION_FULL=$(grep "^VERSION=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  340                             OS_NAME="PureOS"
  341                         ;;
  342                         "raspbian")
  343                             LINUX_VERSION="Raspbian"
  344                             LINUX_VERSION_LIKE="Debian"
  345                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  346                             OS_VERSION_FULL=$(grep "^VERSION=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  347                             OS_NAME="Raspbian"
  348                         ;;
  349                         "rhel")
  350                             LINUX_VERSION="RHEL"
  351                             OS_NAME="RHEL"
  352                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  353                             OS_VERSION_FULL=$(grep "^VERSION=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  354                             OS_FULLNAME="${OS_NAME} ${OS_VERSION_FULL}"
  355                             OS_REDHAT_OR_CLONE=1
  356                         ;;
  357                          "rocky")
  358                             LINUX_VERSION="Rocky Linux"
  359                             OS_NAME="Rocky Linux"
  360                             OS_REDHAT_OR_CLONE=1
  361                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  362                         ;;
  363                         "rosa")
  364                             LINUX_VERSION="ROSA Linux"
  365                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  366                             OS_VERSION_FULL=$(grep "^VERSION=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  367                             OS_NAME="ROSA Linux"
  368                         ;;
  369                         "slackware")
  370                             LINUX_VERSION="Slackware"
  371                             OS_NAME="Slackware Linux"
  372                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  373                             OS_VERSION_FULL=$(grep "^VERSION=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  374                         ;;
  375                         "sles")
  376                             LINUX_VERSION="SLES"
  377                             OS_NAME="openSUSE"
  378                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  379                             OS_VERSION_FULL=$(grep "^PRETTY_NAME=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  380                         ;;
  381                         "ubuntu")
  382                             LINUX_VERSION="Ubuntu"
  383                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  384                             OS_VERSION_FULL=$(grep "^VERSION=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  385                             OS_NAME="Ubuntu"
  386                         ;;
  387                         "void")
  388                             LINUX_VERSION="Void Linux"
  389                             OS_VERSION="Rolling release"
  390                             OS_NAME="Void Linux"
  391                         ;;
  392                         "zorin")
  393                             LINUX_VERSION="Zorin OS"
  394                             OS_NAME="Zorin OS"
  395                             OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  396                             OS_VERSION_FULL=$(grep "^VERSION=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  397                         ;;
  398                         *)
  399                             ReportException "OS Detection" "Unknown OS found in /etc/os-release - Please create an issue on GitHub and share the the contents (cat /etc/os-release): ${PROGRAM_SOURCE}"
  400                         ;;
  401                     esac
  402                 fi
  403             fi
  404 
  405             # Alpine
  406             if [ -e "/etc/alpine-release" ]; then LINUX_VERSION="Alpine Linux"; OS_VERSION=$(cat /etc/alpine-release); fi
  407 
  408             # Amazon
  409             if [ -z "${LINUX_VERSION}" -a -e "/etc/system-release" ]; then
  410                 FIND=$(grep "^Amazon" /etc/system-release)
  411                 if [ -n "${FIND}" ]; then
  412                     OS_REDHAT_OR_CLONE=1
  413                     OS_FULLNAME=$(grep "^Amazon" /etc/system-release)
  414                     OS_VERSION=$(grep "^Amazon" /etc/system-release | awk '{ if ($4=="release") { print $5 } }')
  415                     LINUX_VERSION="Amazon"
  416                 fi
  417             fi
  418 
  419             # Arch Linux
  420             if [ -z "${OS_FULLNAME}" -a -e "/etc/arch-release" ]; then
  421                 OS_FULLNAME="Arch Linux"
  422                 OS_VERSION="Unknown"
  423                 LINUX_VERSION="Arch Linux"
  424             fi
  425 
  426             # Chakra Linux
  427             if [ -e "/etc/chakra-release" ]; then
  428                 OS_FULLNAME=$(grep "^Chakra" /etc/chakra-release)
  429                 OS_VERSION=$(awk '/^Chakra/ { if ($3=="release") { print $4 }}' /etc/chakra-release)
  430                 LINUX_VERSION="Chakra Linux"
  431             fi
  432 
  433             # Cobalt
  434             if [ -e "/etc/cobalt-release" ]; then OS_FULLNAME=$(cat /etc/cobalt-release); fi
  435 
  436             # CPUBuilders Linux
  437             if [ -e "/etc/cpub-release" ]; then OS_FULLNAME=$(cat /etc/cpub-release); fi
  438 
  439             if [ -z "${LINUX_VERSION}" ] && [ -e "/etc/debian_version" ]; then
  440                 # Debian/Ubuntu (***) - Set first to Debian
  441                 OS_VERSION=$(cat /etc/debian_version)
  442                 OS_FULLNAME="Debian ${OS_VERSION}"
  443                 LINUX_VERSION="Debian"
  444 
  445                 # /etc/lsb-release does not exist on Debian
  446                 if [ -e /etc/lsb-release ]; then
  447                     OS_VERSION=$(cat /etc/debian_version)
  448                     FIND=$(grep "^DISTRIB_ID=" /etc/lsb-release | cut -d '=' -f2 | sed 's/"//g')
  449                     if [ "${FIND}" = "Ubuntu" ]; then
  450                         OS_VERSION=$(grep "^DISTRIB_RELEASE=" /etc/lsb-release | cut -d '=' -f2)
  451                         OS_FULLNAME="Ubuntu ${OS_VERSION}"
  452                         LINUX_VERSION="Ubuntu"
  453                     elif [ "${FIND}" = "elementary OS" ]; then
  454                         LINUX_VERSION="elementary OS"
  455                         LINUX_VERSION_LIKE="Ubuntu"
  456                         OS_VERSION=$(grep "^DISTRIB_RELEASE=" /etc/lsb-release | cut -d '=' -f2)
  457                         OS_FULLNAME=$(grep "^DISTRIB_DESCRIPTION=" /etc/lsb-release | cut -d '=' -f2 | sed 's/"//g')
  458                     else
  459                         # Catch all, in case it's unclear what specific release this is.
  460                         OS_FULLNAME="Debian ${OS_VERSION}"
  461                         LINUX_VERSION="Debian"
  462                     fi
  463                     # Ubuntu test (optional) $(grep "[Uu]buntu" /proc/version)
  464                 fi
  465             fi
  466 
  467             # Override for Linux Mint, as that is initially detected as Debian or Ubuntu
  468             if [ -x /usr/bin/lsb_release ]; then
  469                 FIND=$(lsb_release --id | awk -F: '{ print $2 }' | awk '{ print $1 }')
  470                 if [ "${FIND}" = "LinuxMint" ]; then
  471                     LINUX_VERSION="Linux Mint"
  472                     # LMDE (Linux Mint Debian Edition) should be detected as Debian
  473                     LINUX_VERSION_LIKE="Ubuntu"
  474                     OS_VERSION=$(lsb_release --release | awk '{ print $2 }')
  475                     OS_FULLNAME="Linux Mint ${OS_VERSION}"
  476                 fi
  477             fi
  478 
  479             # E-smith
  480             if [ -e "/etc/e-smith-release" ]; then OS_FULLNAME=$(cat /etc/e-smith-release); fi
  481 
  482             # Gentoo
  483             if [ -e "/etc/gentoo-release" ]; then LINUX_VERSION="Gentoo"; OS_FULLNAME=$(cat /etc/gentoo-release); fi
  484 
  485             # Red Hat and others
  486             if [ -z "${LINUX_VERSION}" -a -e "/etc/redhat-release" ]; then
  487                 OS_REDHAT_OR_CLONE=1
  488 
  489                 # CentOS
  490                 if grep "CentOS" /etc/redhat-release; then
  491                     OS_FULLNAME=$(grep "CentOS" /etc/redhat-release)
  492                     LINUX_VERSION="CentOS"
  493                     OS_VERSION="${OS_FULLNAME}"
  494                 fi
  495 
  496                 # ClearOS
  497                 FIND=$(grep "ClearOS" /etc/redhat-release)
  498                 if [ ! "${FIND}" = "" ]; then
  499                     OS_FULLNAME=$(grep "ClearOS" /etc/redhat-release)
  500                     LINUX_VERSION="ClearOS"
  501                     OS_VERSION="${OS_FULLNAME}"
  502                 fi
  503 
  504                 # Fedora
  505                 FIND=$(grep "Fedora" /etc/redhat-release)
  506                 if [ ! "${FIND}" = "" ]; then
  507                     OS_FULLNAME=$(grep "Fedora" /etc/redhat-release)
  508                     OS_VERSION="${OS_FULLNAME}"
  509                     LINUX_VERSION="Fedora"
  510                 fi
  511 
  512 
  513                 # Oracle Enterprise Linux
  514                 FIND=$(grep "Enterprise Linux Enterprise Linux Server" /etc/redhat-release)
  515                 if [ ! "${FIND}" = "" ]; then
  516                     LINUX_VERSION="Oracle Enterprise Linux"
  517                     OS_FULLNAME=$(grep "Enterprise Linux" /etc/redhat-release)
  518                     OS_VERSION="${OS_FULLNAME}"
  519                 fi
  520 
  521                 # Oracle Enterprise Linux
  522                 if [ -e /etc/oracle-release ]; then
  523                     FIND=$(grep "Oracle Linux Server" /etc/oracle-release)
  524                     if [ ! "${FIND}" = "" ]; then
  525                         LINUX_VERSION="Oracle Enterprise Linux"
  526                         OS_FULLNAME=$(grep "Oracle Linux" /etc/oracle-release)
  527                         OS_VERSION="${OS_FULLNAME}"
  528                     fi
  529                 fi
  530 
  531                 # Oracle VM Server
  532                 if [ -e /etc/ovs-release ]; then
  533                     FIND=$(grep "Oracle VM" /etc/ovs-release)
  534                     if [ ! "${FIND}" = "" ]; then
  535                         LINUX_VERSION="Oracle VM Server"
  536                         OS_FULLNAME=$(grep "Oracle VM" /etc/ovs-release)
  537                         OS_VERSION="${OS_FULLNAME}"
  538                     fi
  539                 fi
  540 
  541                 # Scientific
  542                 FIND=$(grep "Scientific" /etc/redhat-release)
  543                 if [ ! "${FIND}" = "" ]; then
  544                     OS_FULLNAME=$(grep "^Scientific" /etc/redhat-release)
  545                     OS_VERSION=$(grep "^Scientific" /etc/redhat-release | awk '{ if ($3=="release") { print $4 } }')
  546                     LINUX_VERSION="Scientific"
  547                 fi
  548 
  549                 if [ -z "${LINUX_VERSION}" ]; then
  550                     # Red Hat
  551                     FIND=$(grep "Red Hat" /etc/redhat-release)
  552                     if [ ! "${FIND}" = "" ]; then
  553                         OS_FULLNAME=$(grep "Red Hat" /etc/redhat-release)
  554                         OS_VERSION="${OS_FULLNAME}"
  555                         LINUX_VERSION="Red Hat"
  556                     fi
  557                 fi
  558 
  559             fi
  560 
  561             # PCLinuxOS
  562             if [ -f /etc/pclinuxos-release ]; then
  563                 FIND=$(grep "^PCLinuxOS" /etc/pclinuxos-release)
  564                 if [ ! "${FIND}" = "" ]; then
  565                     OS_FULLNAME="PCLinuxOS Linux"
  566                     LINUX_VERSION="PCLinuxOS"
  567                     OS_VERSION=$(grep "^PCLinuxOS" /etc/pclinuxos-release | awk '{ if ($2=="release") { print $3 } }')
  568                 fi
  569             fi
  570 
  571             # Sabayon Linux
  572             if [ -f /etc/sabayon-edition ]; then
  573                 FIND=$(grep "Sabayon Linux" /etc/sabayon-edition)
  574                 if [ ! "${FIND}" = "" ]; then
  575                     OS_FULLNAME="Sabayon Linux"
  576                     LINUX_VERSION="Sabayon"
  577                     OS_VERSION=$(awk '{ print $3 }' /etc/sabayon-edition)
  578                 fi
  579             fi
  580 
  581             if [ -f /etc/SLOX-release ]; then
  582                 OS_FULLNAME=$(grep "SuSE Linux" /etc/SLOX-release)
  583                 LINUX_VERSION="SuSE"
  584             fi
  585 
  586             # Slackware
  587             if [ -f /etc/slackware-version ]; then
  588                 LINUX_VERSION="Slackware"
  589                 OS_VERSION=$(grep "^Slackware" /etc/slackware-version | awk '{ if ($1=="Slackware") { print $2 } }')
  590                 OS_FULLNAME="Slackware Linux ${OS_VERSION}"
  591             fi
  592 
  593             # SuSE
  594             if [ -e "/etc/SuSE-release" ]; then
  595                 OS_VERSION=$(head -n 1 /etc/SuSE-release)
  596                 LINUX_VERSION="SuSE"
  597             fi
  598 
  599             # Turbo Linux
  600             if [ -e "/etc/turbolinux-release" ]; then OS_FULLNAME=$(cat /etc/turbolinux-release); fi
  601 
  602             # YellowDog
  603             if [ -e "/etc/yellowdog-release" ]; then OS_FULLNAME=$(cat /etc/yellowdog-release); fi
  604 
  605             # VMware
  606             if [ -e "/etc/vmware-release" ]; then
  607                 OS_FULLNAME=$(cat /etc/vmware-release)
  608                 OS_VERSION=$(uname -r)
  609                 IS_VMWARE_ESXI=$(vmware -vl | grep VMware ESXi)
  610                 if [ ! "${IS_VMWARE_ESXI}" = "" ]; then
  611                     OS_FULLNAME="VMware ESXi ${OS_VERSION}"
  612                 fi
  613             fi
  614 
  615             # ===================================================================
  616             # Set OS name to the discovered Linux version
  617             if [ ! "${LINUX_VERSION}" = "" -a "${OS_NAME}" = "Linux" ]; then
  618                 OS_NAME="${LINUX_VERSION}"
  619             fi
  620             # If Linux version (full name) is unknown, use uname value
  621             if [ "${OS_FULLNAME}" = "" ]; then OS_FULLNAME=$(uname -s -r); fi
  622             SYSCTL_READKEY="sysctl -n"
  623         ;;
  624 
  625         # NetBSD
  626         NetBSD)
  627             OS="NetBSD"
  628             OS_NAME="NetBSD"
  629             OS_FULLNAME=$(uname -s -r)
  630             OS_KERNELVERSION=$(uname -v)
  631             OS_VERSION=$(uname -r)
  632             HARDWARE=$(uname -m)
  633             FIND_BINARIES="whereis"
  634             SYSCTL_READKEY=""
  635         ;;
  636 
  637         # OpenBSD
  638         OpenBSD)
  639             OS="OpenBSD"
  640             OS_NAME="OpenBSD"
  641             OS_FULLNAME=$(uname -s -r)
  642             OS_KERNELVERSION=$(uname -v)
  643             OS_VERSION=$(uname -r)
  644             HARDWARE=$(uname -m)
  645             FIND_BINARIES="whereis"
  646             SYSCTL_READKEY=""
  647         ;;
  648 
  649         # Solaris / OpenSolaris / Ilumos ...
  650         SunOS)
  651             OS="Solaris"
  652             OS_KERNELVERSION=$(uname -v)
  653             OPENSOLARIS=0
  654 
  655             if [ -f /etc/os-release ]; then
  656                 OS_ID=$(grep "^ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  657                 OS_VERSION=$(grep "^VERSION=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
  658                 OS_FULLNAME=$(awk -F= '/^PRETTY_NAME=/ {print substr($2,2,length($2)-2)}' /etc/os-release)
  659                 case "${OS_ID}" in
  660                     "solaris")
  661                         OS_NAME="Oracle Solaris"
  662                         ;;
  663                     "omnios")
  664                         OS_NAME="OmniOS"
  665                         OPENSOLARIS=1
  666                         ;;
  667                     "tribblix")
  668                         OS_NAME="Tribblix"
  669                         OS_FULLNAME="Tribblix ${OS_VERSION}"
  670                         OPENSOLARIS=1 
  671                         ;;
  672                     "*")
  673                         ReportException "OS Detection" "Unknown OS found in /etc/os-release - Please create issue on GitHub project page: ${PROGRAM_SOURCE}"
  674                         ;;
  675                 esac
  676             elif [ "$(uname -o 2> /dev/null)" == "illumos" ]; then
  677                 OPENSOLARIS=1
  678         
  679                 # Solaris has a free form text file with release information
  680                 if grep "OpenIndiana" /etc/release > /dev/null; then
  681                     OS_NAME="OpenIndiana"
  682                     if grep "Hipster" /etc/release > /dev/null; then
  683                         OS_VERSION="$(tr ' ' '\n' < /etc/release  | grep '[[:digit:]]\.[[:digit:]]')"
  684                         OS_FULLNAME="OpenIndiana Hipster $OS_VERSION"
  685                     else
  686                         OS_VERSION="Unknown"
  687                         OS_FULLNAME="OpenIndiana (unknown edition)"
  688                     fi
  689                 elif grep "OmniOS" /etc/release > /dev/null; then
  690                     OS_NAME="OmniOS"
  691                     OS_VERSION="$(tr ' ' '\n' < /etc/release  | grep 'r[[:digit:]]')"
  692                     if grep "Community Edition" /etc/release > /dev/null; then
  693                         OS_FULLNAME="OmniOS Community Edition v11 $OS_VERSION"
  694                     fi
  695                 elif grep "SmartOS" /etc/release > /dev/null; then
  696                     OS_NAME="SmartOS"
  697                     OS_VERSION="-"
  698                     OS_FULLNAME="SmartOS"
  699                 else
  700                     OS_NAME="Unknown Illumos"
  701                 fi
  702             elif grep "SchilliX" /etc/release > /dev/null; then
  703                 OS_NAME="SchilliX"
  704                 OS_FULLNAME="$(head -n 1 /etc/release | xargs)"
  705                 OS_VERSION="$(echo "$OS_FULLNAME" | cut -d '-' -f 2)"
  706 
  707                 OPENSOLARIS=1
  708             elif head -n 1 < /etc/release | grep "Oracle Solaris" > /dev/null; then
  709                 OS_NAME="Oracle Solaris"
  710                 OS_FULLNAME="$(head -n 1 /etc/release | xargs)"
  711                 OS_VERSION="$(head -n 1 < /etc/release | xargs | cut -d ' ' -f 3)"
  712             elif head -n 1 < /etc/release | xargs | grep "^Solaris " > /dev/null; then
  713                 OS_NAME="Sun Solaris"
  714                 # Example of /etc/release:
  715                 #   Solaris 10 5/08
  716                 #   ...
  717                 #   Solaris 10 10/09 (Update 8)
  718                 # The first line does not contain the "Update" number,
  719                 # only if present.
  720                 if tail -1 < /etc/release | xargs | grep "^Solaris " > /dev/null; then
  721                     OS_FULLNAME=$(tail -1 < /etc/release | xargs)
  722                 else
  723                     OS_FULLNAME=$(head -1 < /etc/release | xargs)
  724                 fi
  725                 OS_VERSION=$(echo "$OS_FULLNAME" | cut -d ' ' -f 2,3)
  726             else  # Old behaviour
  727                 OS_NAME="Sun Solaris"
  728                 OS_FULLNAME=$(uname -s -r)
  729                 OS_VERSION=$(uname -r)
  730             fi
  731 
  732             HARDWARE=$(uname -m)
  733             if [ -x /usr/bin/isainfo ]; then
  734                 # Returns 32, 64
  735                 OS_MODE=$(/usr/bin/isainfo -b)
  736             fi
  737             SYSCTL_READKEY=""
  738         ;;
  739 
  740         # VMware products
  741         VMkernel)
  742             OS="VMware"
  743             OS_FULLNAME=""
  744             OS_VERSION=""
  745             HARDWARE=$(uname -m)
  746             if [ -e "/etc/vmware-release" ]; then
  747                 OS_FULLNAME=$(cat /etc/vmware-release)
  748                 OS_VERSION=$(uname -r)
  749             fi
  750             HAS_VMWARE_UTIL=$(which vmware 2> /dev/null | grep -v "no [^ ]* in ")
  751             if [ ! "${HAS_VMWARE_UTIL}" = "" ]; then
  752                 IS_VMWARE_ESXI=$(vmware -vl | grep VMware ESXi)
  753                 if [ ! "${IS_VMWARE_ESXI}" = "" ]; then
  754                     OS_NAME="VMware ESXi"
  755                     OS_FULLNAME="VMware ESXi ${OS_VERSION}"
  756                 fi
  757             fi
  758         ;;
  759 
  760 
  761         # Unknown or unsupported systems
  762         *)
  763             echo "[ ${WARNING}WARNING${NORMAL} ]"
  764             echo "${WARNING}Error${NORMAL}: ${WHITE}Unknown OS found. No support available yet for this OS or platform...${NORMAL}"
  765             echo "Please consult the README/documentation for more information."
  766             exit 1
  767         ;;
  768 
  769     esac
  770 
  771     # Set correct echo binary and parameters after detecting operating system
  772     ECHONB=""
  773 
  774     case ${OS} in
  775         "AIX")                           ECHOCMD="echo"; ECHONB="printf" ;;
  776         "DragonFly"|"FreeBSD"|"NetBSD")  ECHOCMD="echo -e"; ECHONB="echo -n" ;;
  777         "macOS" | "Mac OS X")                         ECHOCMD="echo"; ECHONB="/bin/echo -n" ;;
  778         "Solaris")                       ECHOCMD="echo" ; test -f /usr/ucb/echo && ECHONB="/usr/ucb/echo -n" ;;
  779         "Linux")
  780             # Check if dash is used (Debian/Ubuntu)
  781             DEFAULT_SHELL=$(ls -l /bin/sh | awk -F'>' '{print $2}')
  782             case ${DEFAULT_SHELL} in
  783                 " dash")                 ECHOCMD="/bin/echo -e" ;;
  784                 *)                       ECHOCMD="echo -e" ;;
  785             esac
  786         ;;
  787         *)                               ECHOCMD="echo -e" ;;
  788     esac
  789 
  790     # Check if we have full featured commands, or are using BusyBox as a shell
  791     if [ -x /bin/busybox ]; then
  792         if [ -L /bin/ps ]; then
  793             ShowSymlinkPath /bin/ps
  794             if [ "${SYMLINK}" = "/bin/busybox" ]; then
  795                 SHELL_IS_BUSYBOX=1
  796             fi
  797         fi
  798     fi
  799 
  800     # Specific checks for hardware
  801 
  802     # Detect if we are using a QNAP NAS
  803     if [ -d /share/CACHEDEV1_DATA/.qpkg ]; then
  804         QNAP_DEVICE=1
  805     fi
  806 
  807     # Check if this OS is end-of-life
  808     EOL=255
  809     EOL_DATE=""
  810     EOL_TIMESTAMP=0
  811     if [ -n "${OS_VERSION}" ]; then
  812         if [ -f "${DBDIR}/software-eol.db" ]; then
  813             FIND="${OS_FULLNAME}"
  814             EOL_TIMESTAMP=$(awk -v value="${FIND}" -F: '{if ($1=="os" && value ~ $2){print $4}}' ${DBDIR}/software-eol.db | head -n 1)
  815             if [ -n "${EOL_TIMESTAMP}" ]; then
  816                 EOL_DATE=$(awk -v value="${FIND}" -F: '{if ($1=="os" && value ~ $2){print $3}}' ${DBDIR}/software-eol.db | head -n 1)
  817                 if [ -n "${EOL_DATE}" ]; then
  818                     NOW=$(date "+%s")
  819                     if [ -n "${NOW}" ]; then
  820                         if [ ${NOW} -gt ${EOL_TIMESTAMP} ]; then
  821                             EOL=1
  822                         else
  823                             EOL=0
  824                         fi
  825                     fi
  826                 else
  827                     EOL=0
  828                 fi
  829             fi
  830         fi
  831     fi
  832 
  833 
  834 #================================================================================
  835 # Lynis - Security Auditing and System Hardening for Linux and UNIX - https://cisofy.com