images/elements/rocky-minimal-yum/post-install.d/80-cleanup-locales-etc

53 lines
1.1 KiB
Plaintext
Raw Normal View History

2023-11-21 21:29:12 +00:00
#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# Stay compatible
echo 'container' > /etc/dnf/vars/infra
#Generate installtime file record
/bin/date +%Y%m%d_%H%M > /etc/BUILDTIME
# Limit languages to help reduce size.
LANG="en_US"
echo "%_install_langs $LANG" > /etc/rpm/macros.image-language-conf
# https://bugzilla.redhat.com/show_bug.cgi?id=1727489
echo 'LANG="C.UTF-8"' > /etc/locale.conf
for dir in $(ls -d /usr/share/locale/* | grep -v 'en_US\|all_languages\|locale\.alias'); do rm -fr $dir; done
rm -fr /usr/share/man
# Cleanup caches left by chroot
rm -fr /usr/lib64/python*/__pycache__/
rm -fr /var/cache/dnf/*
rm -fr /run
rm -fr /home/ansible/
# systemd fixes
:> /etc/machine-id
systemd-tmpfiles --create --boot
# mask mounts and login bits
systemctl mask \
console-getty.service \
dev-hugepages.mount \
getty.target \
sys-fs-fuse-connections.mount \
systemd-logind.service \
systemd-remount-fs.service
# Cleanup the image
rm -fv /etc/udev/hwdb.bin
rm -rfv /usr/lib/udev/hwdb.d/ \
/boot /var/lib/dnf/history.* \
"/tmp/*" "/tmp/.*" /var/log/* || true
ls /dev/ -artlh