diff --git a/packer_templates/scripts/rhel/cleanup_dnf.sh b/packer_templates/scripts/rhel/cleanup_dnf.sh index 2fa9737d8..7f8ddd206 100644 --- a/packer_templates/scripts/rhel/cleanup_dnf.sh +++ b/packer_templates/scripts/rhel/cleanup_dnf.sh @@ -31,12 +31,14 @@ 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 +if test -f /etc/sysconfig/network-scripts/ifcfg-*; then + 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 +fi echo "truncate any logs that have built up during the install" find /var/log -type f -exec truncate --size=0 {} \; diff --git a/packer_templates/scripts/rhel/cleanup_yum.sh b/packer_templates/scripts/rhel/cleanup_yum.sh index 6dd7cf34e..077319234 100644 --- a/packer_templates/scripts/rhel/cleanup_yum.sh +++ b/packer_templates/scripts/rhel/cleanup_yum.sh @@ -31,13 +31,14 @@ 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 +if test -f /etc/sysconfig/network-scripts/ifcfg-*; then + for ndev in /etc/sysconfig/network-scripts/ifcfg-*; do + if [ "$(basename "$ndev")" != "ifcfg-lo" ]; then + sed -i '/^UUID/d' "$ndev"; + fi + done +fi echo "truncate any logs that have built up during the install" find /var/log -type f -exec truncate --size=0 {} \;