
IFCONFIG=`which ifconfig 2>/dev/null||echo /sbin/ifconfig`
ADDR=`$IFCONFIG lo |grep inet6 | awk '{print $3}'`
CONF=/etc/sysctl.conf 

if [ "$ADDR" == "::1/128" ]; then
    echo Disable IPV6
    echo "Disable IPv6 as $CONF"
    sed -i '/net.ipv6.conf.all.disable_ipv6/d' $CONF
    sed -i '/net.ipv6.conf.default.disable_ipv6/d' $CONF
    echo 'net.ipv6.conf.all.disable_ipv6 = 1' >> /etc/sysctl.conf
    echo 'net.ipv6.conf.default.disable_ipv6 = 1' >> /etc/sysctl.conf
    sysctl -p
else
    echo IPV6 is already disabled
fi

echo Fix localhost at /etc/hosts

sed -i /^::1/d /etc/hosts
echo '127.0.0.1       localhost' >>/etc/hosts

if [ `sestatus | grep 'SELinux status' | awk '{print $3}'` == "enabled" ]; then 
    echo Disable SELINUX
    setenforce Permissive
    sed -i /etc/selinux/config -e 's/^SELINUX=.*$/SELINUX=disabled/'
else
    echo SELINUX is already disabled
fi
