I need to get the release of the SO to know if it is 5 or 6 or 7 Then preform some work on it based on if it is one of those releases.
if its 5 then do bal bla bla
else its 6 do this
else 7 do this and so on.
We have different release of code that we need to install OS specific so I need to know the release to know which code to install.
subset of the script.
# Validate OS level
rhlevel=`cut -c 41 /etc/redhat-release`
#typeset -i rhlevel
echo "$rhlevel"
# Make logical volume
vg_space=`vgdisplay |grep Free |cut -c 30`
echo "$vg_space"
if [[ $vg_space -le 3 ]]; then
lvcreate -n xxxlv-L 512M /dev/mapper/rootvg
else
lvcreate -n xxxlv-L 2G /dev/mapper/rootvg
fi
#Check OS level
echo "$rhlevel"
if (( $rhlevel == 5 )); then
# Make Rhel 5 fs
mkfs -t ext3 /dev/rootvg/xxxlv
mount /dev/mapper/rootvg-xxxxvg /opt/xxx
# If version 5 get this file
cd /tmp
wget http://myserver.com/mycode-6.0.314.1579 ... x86_64.rpm
rpm -i /tmp/mycode-6.0.314.1579-1.rhe5.x86_64.rpm
elif (( $rhlevel == 6 )); then
# Make Rhel 6 fs
mkdir -p /opt/xxx
mkfs -t ext4 /dev/rootvg/xxx
mount /dev/mapper/rootvg-xxx /opt/xxx
cp /etc/fstab /etc/fstab.pre
echo "/dev/mapper/rootvg-xxx /opt/xxx ext4 defaults 0 0" >> /etc/fstab
# If version 6 get this file
cd /tmp/
wget http://myserver.com/pub/mycode-6.0.314. ... x86_64.rpm
rpm -i /tmp/mysq-6.0.314.1579-1.rhe6.x86_64.rpm
elif (( $rhlevel == 7 )); then
# Rhel 7
mkfs.xfs -d su=64k,sw=4 /dev/rootvg/xxxx
mount /dev/mapper/rootvg-xxx /opt/xxx
I had to sanitize the code im sure you understand but you get the idea of why i need the oslevel now.
script question
Re: script question
rpm -qf --qf '%{VERSION}\n' /etc/redhat-release should work on all and be portable to any RHEL clone.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Re: script question
Thank you I will review your command
Re: script question
As will all script is lead to a bigger can of worms.
Thank you for that last command. I will use that one.
Thank you for that last command. I will use that one.