Skip to content

Commit

Permalink
Fix new-style Network Device Naming on CentOS7
Browse files Browse the repository at this point in the history
  • Loading branch information
tai-ga committed Dec 22, 2014
1 parent 090ed72 commit be4174e
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions script/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,42 @@ if [ -f /etc/sysconfig/network-scripts/ifcfg-eth0 ] ; then
sed -i "/^UUID/d" /etc/sysconfig/network-scripts/ifcfg-eth0
fi

# 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
#BOXCUTTER-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 -e "/^#BOXCUTTER-BEGIN/,/^#BOXCUTTER-END/{s/^/# /}" /etc/rc.d/rc.local
chmod -x /etc/rc.d/rc.local
#BOXCUTTER-END
_EOF_
chmod +x /etc/rc.d/rc.local
fi

echo "==> Cleaning up yum cache of metadata and packages to save space"
yum -y clean all

Expand Down

0 comments on commit be4174e

Please sign in to comment.