From e38909bce0bdba03628724e27046975cc675495c Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Thu, 16 Nov 2023 17:50:50 +0100 Subject: [PATCH] Adding script files/postinstall --- files/postinstall | 136 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 files/postinstall diff --git a/files/postinstall b/files/postinstall new file mode 100644 index 0000000..ef3ec2e --- /dev/null +++ b/files/postinstall @@ -0,0 +1,136 @@ +#!/bin/bash + +printf "Current host FQDN: " +hostname -f + +echo +echo "All installed packages:" +echo "-----------------------" +rpm -qa | sort + +echo +echo "All filesystems:" +echo "----------------" +df -m -a -T + +for ks_cfg in "/root/original-ks.cfg" "/root/anaconda-ks.cfg" ; do + echo + echo "-----------------------------------------------------------" + if [ -f "${ks_cfg}" ] ; then + echo "Moving ${ks_cfg} => /var/log/anaconda/ ..." + mv -v "${ks_cfg}" /var/log/anaconda/ + else + echo "File ${ks_cfg} not found." >&2 + fi +done + +echo +echo "Removing /var/log/anaconda ..." +echo "------------------------------" +rm -rfv /var/log/anaconda + +if [ -x /sbin/subscription-manager ] ; then + echo + echo "Unregistring current host from Red Hat Subscription Management ..." + /sbin/subscription-manager unregister --no-progress-messages + sleep 2 +fi + +echo +for f in '/var/log/audit/audit.log' + '/var/log/boot.log' + '/var/log/cloud-init.log' + '/var/log/cloud-init-output.log' + '/var/log/cron' + '/var/log/dnf*.log' + '/var/log/grubby*' + '/var/log/hawkey.log' + '/var/log/messages' + '/var/log/secure' + '/var/log/tuned/tuned.log' + '/var/log/wtmp' + '/var/log/vmware-*.log*' + '/var/log/yum*.log' + '/var/log/rhsm/*.log' + ; do + if [ -f "${f}" ] ; then + echo "Truncating ${f} ..." + cp /dev/null "${f}" + fi +done + +echo +echo "-----------------------------------------------------------" +echo "Clearing journal log ..." +journalctl --flush +journalctl -m --vacuum-time=1s + +echo +echo "-----------------------------------------------------------" +echo "Truncating /var/log/*tmp ..." +cp -v /dev/null /var/log/btmp +cp -v /dev/null /var/log/wtmp + +echo +echo "-----------------------------------------------------------" +echo "Remaining files in /var/log:" +find /var/log -type f | xargs ls -l -S + +echo +echo "-----------------------------------------------------------" +echo "Current network configuration:" +echo +/usr/sbin/ip address show +echo +echo "Current routing configuration:" +echo +/usr/sbin/ip route show + +echo +echo "NetworkManager connections:" +echo +/bin/nmcli connection show + +echo +echo "-----------------------------------------------------------" +echo "Networking config files:" +echo +echo "Searching for file like /etc/sysconfig/network-scripts/ifcfg-* ..." +for f in /etc/sysconfig/network-scripts/ifcfg-* ; do + if [ ! -f "${f}" ] ; then + continue + fi + base_name=$( basename "${f}" ) + if [ "${base_name}" = 'ifcfg-lo' ] ; then + continue + fi + echo "${f}:" + ls -l "${f}" + echo + echo "Content:" + echo "---------- snip ----------" + cat "${f}" + echo "---------- snip ----------" + echo "Removing ${f} ..." + rm -vf "${f}" +done +echo +echo "DHCP leases:" +echo +echo "Searching for file like /var/lib/dhclient/*.leases ..." +for f in /var/lib/dhclient/*.leases ; do + if [ ! -f "${f}" ] ; then + continue + fi + echo "${f}:" + ls -l "${f}" + echo + echo "Content:" + echo "---------- snip ----------" + cat "${f}" + echo "---------- snip ----------" + echo "Removing ${f} ..." + rm -vf "${f}" +done + +# vim: ts=4 list -- 2.39.5