Skip to content

Commit

Permalink
Fix new-style device naming from Network Manager on RHEL/CentOS 7
Browse files Browse the repository at this point in the history
  • Loading branch information
legal90 committed Jun 20, 2016
1 parent 12f434b commit d0c2e56
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions scripts/centos/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,36 @@ for ndev in `ls -1 /etc/sysconfig/network-scripts/ifcfg-*`; do
fi
done

# new-style network device naming for centos7
if grep -q -i "release 7" /etc/redhat-release ; then
# radio off & remove all interface configration
nmcli radio all off
/bin/systemctl stop NetworkManager.service
for ifcfg in `ls /etc/sysconfig/network-scripts/ifcfg-* |grep -v ifcfg-lo` ; do
rm -f $ifcfg
done
rm -rf /var/lib/NetworkManager/*

echo "==> Setup /etc/rc.d/rc.local for CentOS7"
cat <<_EOF_ | cat >> /etc/rc.d/rc.local
#BENTO-BEGIN
LANG=C
# delete all connection
for con in \`nmcli -t -f uuid con\`; do
if [ "\$con" != "" ]; then
nmcli con del \$con
fi
done
# add gateway interface connection.
gwdev=\`nmcli dev | grep ethernet | egrep -v 'unmanaged' | head -n 1 | awk '{print \$1}'\`
if [ "\$gwdev" != "" ]; then
nmcli c add type eth ifname \$gwdev con-name \$gwdev
fi
sed -i "/^#BENTO-BEGIN/,/^#BENTO-END/d" /etc/rc.d/rc.local
chmod -x /etc/rc.d/rc.local
#BENTO-END
_EOF_
chmod +x /etc/rc.d/rc.local
fi

rm -f VBoxGuestAdditions_*.iso VBoxGuestAdditions_*.iso.?;

0 comments on commit d0c2e56

Please sign in to comment.