OK I've come up with the below script and tested on CentOS with the indicated errors...I have NO idea what to do here to fix this my understanding is that is it shou;d be finding at least one "CenntOS" out there and firing the CentOS section...I've obviously commented out the patching and reboot for testing - taking down a server alot is sort of job limiting
#!/bin/bash
#
value=$( grep -ic "CentOS" /etc/*release* )
value1=$( grep -ic "Ubuntu" /etc/*release* )
#
# CentOS
#
if [ $value -ge 1 ]
then
echo "I found CerntOS"
# yum -y update
sleep 3
# reboot
#
# Ubuntu
#
elif [ $value1 -ge 1 ]
then
echo "I found Ubuntu"
#
# apt-get update
sleep 3
# apt-get -y dist-upgrade
sleep 3
# apt-get -y autoremove
sleep 3
# reboot
#
else
echo "Neither CentOS or Ubuntu Found"
#
fi
[root@stadmnwksdb01 ~]# cat ./ossupdate.sh
#!/bin/bash
#
value=$( grep -ic "CentOS" /etc/*release* )
value1=$( grep -ic "Ubuntu" /etc/*release* )
#
# CentOS
#
if [ $value -ge 1 ]
then
echo "I found CerntOS"
# yum -y update
sleep 3
# reboot
#
# Ubuntu
#
elif [ $value1 -ge 1 ]
then
echo "I found Ubuntu"
#
# apt-get update
sleep 3
# apt-get -y dist-upgrade
sleep 3
# apt-get -y autoremove
sleep 3
# reboot
#
else
echo "Neither CentOS or Ubuntu Found"
#
fi
[root@stadmnwksdb01 ~]# ./ossupdate.sh
./ossupdate.sh: line 8: [: too many arguments
./ossupdate.sh: line 17: [: too many arguments
Neither CentOS or Ubuntu Found
[root@stadmnwksdb01 ~]# cat /etc/*release*
CentOS release 6.3 (Final)
cat: /etc/lsb-release.d: Is a directory
CentOS release 6.3 (Final)
CentOS release 6.3 (Final)
cpe:/o:centos:linux:6:GA