Skip to content

Commit

Permalink
rhel: Check for networking-scripts before removal (chef#1532)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rendanic authored and raykrist committed Aug 17, 2024
1 parent 5197b53 commit 40a6e3f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
14 changes: 8 additions & 6 deletions packer_templates/scripts/rhel/cleanup_dnf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 {} \;
Expand Down
13 changes: 7 additions & 6 deletions packer_templates/scripts/rhel/cleanup_yum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 {} \;

Expand Down

0 comments on commit 40a6e3f

Please sign in to comment.