From 9c191bb994e0d3d202d67b949a9775aacc77b554 Mon Sep 17 00:00:00 2001 From: ceetav Date: Wed, 20 Jan 2016 01:29:26 +0300 Subject: [PATCH] simplify distro detection for RHEL-derivatives --- scripts/centos/cleanup.sh | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/scripts/centos/cleanup.sh b/scripts/centos/cleanup.sh index 1ffcc9334..4399e21ee 100644 --- a/scripts/centos/cleanup.sh +++ b/scripts/centos/cleanup.sh @@ -1,19 +1,12 @@ #!/bin/sh -eux -if [ -s /etc/oracle-release ]; then - distro='oracle' -elif [ -s /etc/enterprise-release ]; then - distro='oracle' -elif [ -s /etc/redhat-release ]; then - # should ouput 'centos' OR 'red hat' - distro=`cat /etc/redhat-release | sed 's/^\(CentOS\|Red Hat\).*/\1/i' | tr '[:upper:]' '[:lower:]'` -fi - +# should output one of 'redhat' 'centos' 'oraclelinux' +distro="`rpm -qf --queryformat '%{NAME}' /etc/redhat-release | cut -f 1 -d '-'`" # Remove development and kernel source packages yum -y remove gcc cpp kernel-devel kernel-headers perl; -if [ "$distro" != 'red hat' ]; then +if [ "$distro" != 'redhat' ]; then yum -y clean all; fi