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:
80
update.sh
80
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,41 +72,44 @@ 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
|
||||||
|
|
||||||
# install the epel for other packages and wget
|
# install the epel for other packages and wget
|
||||||
yum install -y elrepo-release epel-release yum-utils
|
yum install -y elrepo-release epel-release yum-utils
|
||||||
|
|
||||||
# clean the yum cache
|
# clean the yum cache
|
||||||
yum clean all
|
yum clean all
|
||||||
|
|
||||||
# remove unneeded packages
|
# remove unneeded packages
|
||||||
yum autoremove -y
|
yum autoremove -y
|
||||||
|
|
||||||
# install the packages
|
# install the packages
|
||||||
yum install -y sudo rsync tar nano htop nload iperf iperf3 bind-utils yum-cron unzip bzip2 nfs-utils git wget uptimed net-tools make realmd oddjob oddjob-mkhomedir sssd adcli mlocate
|
yum install -y sudo rsync tar nano htop nload iperf iperf3 bind-utils yum-cron unzip bzip2 nfs-utils git wget uptimed net-tools make realmd oddjob oddjob-mkhomedir sssd adcli mlocate
|
||||||
|
|
||||||
# install vm tools
|
# install vm tools
|
||||||
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
|
||||||
sed --in-place "s/^apply_updates\ =\ no/apply_updates\ =\ yes/" /etc/yum/yum-cron.conf
|
sed --in-place "s/^apply_updates\ =\ no/apply_updates\ =\ yes/" /etc/yum/yum-cron.conf
|
||||||
systemctl enable yum-cron
|
systemctl enable yum-cron
|
||||||
systemctl restart yum-cron
|
systemctl restart yum-cron
|
||||||
|
|
||||||
# start and enable uptimed
|
# start and enable uptimed
|
||||||
systemctl start uptimed
|
systemctl start uptimed
|
||||||
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