Updated variable names, Using Virtualization instead of chassis for KVM vs. VMware. Added logic for Rocky Linux 9.0. Added qemu guest tool install logic and better error code for unsupported OS
This commit is contained in:
36
update.sh
36
update.sh
@@ -14,18 +14,24 @@ fi
|
|||||||
|
|
||||||
# get OS ditro and version
|
# get OS ditro and version
|
||||||
OS=$(hostnamectl | awk '/Operating System/ {print $3}')
|
OS=$(hostnamectl | awk '/Operating System/ {print $3}')
|
||||||
Chassis=$(hostnamectl | awk '/Chassis/ {print $2}')
|
CHASSIS=$(hostnamectl | awk '/Chassis/ {print $2}')
|
||||||
|
VIRTUALIZATION=$(hostnamectl | awk '/Virtualization/ {print $2}')
|
||||||
if [ "${OS}" == "Ubuntu" ]; then
|
if [ "${OS}" == "Ubuntu" ]; then
|
||||||
OS_VER=$(hostnamectl | awk '/Operating System/ {print $4}')
|
OS_VERSION=$(hostnamectl | awk '/Operating System/ {print $4}')
|
||||||
else
|
else
|
||||||
OS_VER=$(hostnamectl | awk '/Operating System/ {print $5}')
|
OS_VERSION=$(hostnamectl | awk '/Operating System/ {print $5}')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${Chassis}" == "vm" ]; then
|
if [ "${VIRTUALIZATION}" == "vmware" ]; then
|
||||||
VM="true"
|
VM="true"
|
||||||
else
|
else
|
||||||
VM="false"
|
VM="false"
|
||||||
fi
|
fi
|
||||||
|
if [ "${VIRTUALIZATION}" == "kvm" ]; then
|
||||||
|
KVM="true"
|
||||||
|
else
|
||||||
|
KVM="false"
|
||||||
|
fi
|
||||||
|
|
||||||
# set custom bash settings system wide
|
# set custom bash settings system wide
|
||||||
cat <<EOF > /etc/profile.d/gaunt_custom_bash.sh
|
cat <<EOF > /etc/profile.d/gaunt_custom_bash.sh
|
||||||
@@ -49,6 +55,10 @@ if [ ${OS} == "Debian" ] || [ ${OS} == "Ubuntu" ]; then
|
|||||||
if [ "${VM}" == "true" ]; then
|
if [ "${VM}" == "true" ]; then
|
||||||
apt install -y open-vm-tools
|
apt install -y open-vm-tools
|
||||||
fi
|
fi
|
||||||
|
if [ "${KVM}" == "true" ]; then
|
||||||
|
apt install -y qemu-guest-agent
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# remove unneeded packages
|
# remove unneeded packages
|
||||||
apt autoremove -y
|
apt autoremove -y
|
||||||
@@ -62,9 +72,9 @@ if [ ${OS} == "Debian" ] || [ ${OS} == "Ubuntu" ]; then
|
|||||||
update-ca-certificates
|
update-ca-certificates
|
||||||
|
|
||||||
# CentOS OS
|
# CentOS OS
|
||||||
elif [ "${OS}" == "CentOS" ]; then
|
elif [ "${OS}" == "CentOS" ] || [ "${OS}" == "Rocky" ]; then
|
||||||
# Centos 7
|
# Centos 7
|
||||||
if [ "${OS_VER}" == "7" ]; then
|
if [ "${OS_VERSION}" == "7" ]; then
|
||||||
# upgrade all packages
|
# upgrade all packages
|
||||||
yum update -y
|
yum update -y
|
||||||
|
|
||||||
@@ -84,6 +94,9 @@ elif [ "${OS}" == "CentOS" ]; then
|
|||||||
if [ "${VM}" == "true" ]; then
|
if [ "${VM}" == "true" ]; then
|
||||||
yum install -y open-vm-tools
|
yum install -y open-vm-tools
|
||||||
fi
|
fi
|
||||||
|
if [ "${KVM}" == "true" ]; then
|
||||||
|
yum install -y qemu-guest-agent
|
||||||
|
fi
|
||||||
|
|
||||||
# modify yum-cron config to auto install security updates and enable/start the service
|
# modify yum-cron config to auto install security updates and enable/start the service
|
||||||
sed --in-place "s/^update_cmd\ =\ security/update_cmd\ =\ default/" /etc/yum/yum-cron.conf
|
sed --in-place "s/^update_cmd\ =\ security/update_cmd\ =\ default/" /etc/yum/yum-cron.conf
|
||||||
@@ -96,7 +109,7 @@ elif [ "${OS}" == "CentOS" ]; then
|
|||||||
systemctl enable uptimed
|
systemctl enable uptimed
|
||||||
fi
|
fi
|
||||||
# Centos 7
|
# Centos 7
|
||||||
if [ "${OS_VER}" == "8" ]; then
|
if [ "${OS_VERSION}" == "8" ] || [ "${OS_VERSION}" == "9.0" ]; then
|
||||||
# upgrade all packages
|
# upgrade all packages
|
||||||
dnf update -y
|
dnf update -y
|
||||||
|
|
||||||
@@ -123,6 +136,9 @@ elif [ "${OS}" == "CentOS" ]; then
|
|||||||
if [ "${VM}" == "true" ]; then
|
if [ "${VM}" == "true" ]; then
|
||||||
dnf install -y open-vm-tools
|
dnf install -y open-vm-tools
|
||||||
fi
|
fi
|
||||||
|
if [ "${KVM}" == "true" ]; then
|
||||||
|
dnf install -y qemu-guest-agent
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# modify ssh to allow root login and then restart the service
|
# modify ssh to allow root login and then restart the service
|
||||||
@@ -134,7 +150,11 @@ elif [ "${OS}" == "CentOS" ]; then
|
|||||||
update-ca-trust
|
update-ca-trust
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "Unable to determine linux distro"
|
echo "Unsupported OS detected."
|
||||||
|
echo "OS: ${OS}"
|
||||||
|
echo "OS Version: ${OS_VERSION}"
|
||||||
|
echo "VM: ${VM}"
|
||||||
|
echo "KVM: ${KVM}"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user