You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.9 KiB

2 years ago
#!/bin/sh -eux
echo "reduce the grub menu time to 1 second"
sed -i -e 's/^GRUB_TIMEOUT=[0-9]\+$/GRUB_TIMEOUT=1/' /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
echo "Remove development and kernel source packages"
yum -y remove gcc cpp gc kernel-devel kernel-headers glibc-devel elfutils-libelf-devel glibc-headers kernel-devel kernel-headers
echo "remove orphaned packages"
yum -y autoremove
echo "Remove previous kernels that preserved for rollbacks"
if ! command -v package-cleanup >/dev/null 2>&1; then
yum -y install yum-utils
fi
package-cleanup --oldkernels --count=1 -y
# Avoid ~200 meg firmware package we don't need
# this cannot be done in the KS file so we do it here
echo "Removing extra firmware packages"
yum -y remove linux-firmware
echo "clean all package cache information"
yum -y clean all --enablerepo=\*;
# Clean up network interface persistence
rm -f /etc/udev/rules.d/70-persistent-net.rules;
mkdir -p /etc/udev/rules.d/70-persistent-net.rules;
rm -f /lib/udev/rules.d/75-persistent-net-generator.rules;
rm -rf /dev/.udev/;
for ndev in /etc/sysconfig/network-scripts/ifcfg-*; do
if [ "$(basename "$ndev")" != "ifcfg-lo" ]; then
sed -i '/^HWADDR/d' "$ndev";
sed -i '/^UUID/d' "$ndev";
fi
done
echo "truncate any logs that have built up during the install"
find /var/log -type f -exec truncate --size=0 {} \;
echo "remove the install log"
rm -f /root/anaconda-ks.cfg /root/original-ks.cfg
echo "remove the contents of /tmp and /var/tmp"
rm -rf /tmp/* /var/tmp/*
echo "Force a new random seed to be generated"
rm -f /var/lib/systemd/random-seed
echo "Wipe netplan machine-id (DUID) so machines get unique ID generated on boot"
truncate -s 0 /etc/machine-id
if test -f /var/lib/dbus/machine-id
then
truncate -s 0 /var/lib/dbus/machine-id # if not symlinked to "/etc/machine-id"
fi
echo "Clear the history so our install commands aren't there"
rm -f /root/.wget-hsts
export HISTSIZE=0