#!/bin/bash
Echo"Enter The old IP:"$1
Echo"Enter The new IP:"$2
if[[ $1==""]];then
Echo"Usage: + $ Enter the new ip:$1"
Echo"Usage: $ Enter the old ip:$2"
Exit0
Fi
I=0
forLineinch' Ls/etc/sysconfig/network-scripts | Grep-e"Ifcfg-em|ifcfg-eth"`
Do
strip= ' cat/etc/sysconfig/network-scripts/$line | Grep-i" $"`
strboot= ' cat/etc/sysconfig/network-scripts/$line | Grep-i"^onboot"| Awk-f'=''{print $}'| Grep-i"Yes"`
if[-N"$strip"-a-n"$strboot"];then
Echo $line
file= $line
Echo $strip
Echo $strboot
ipfile="/etc/sysconfig/network-scripts/$file"
hostnamefile="/etc/sysconfig/network"
Sed-i's/^ipaddr/#IPADDR/g'$ipfile
#sed-I.'s/^netmask/#NETMASK/g'$ipfile
Sed-i's/^gateway/#GATEWAY/g'$ipfile
Sed-i's/^hostname/#HOSTNAME/g'$ipfile
Sed-i's/^hostname/#HOSTNAME/g'$hostnamefile
newip=$2
newgateway=
Newhostname=
Cat >> $ipfile <<eof
Ipaddr="$newip"
gateway="$newgateway"
Eof
Echo"hostname=\ "$newhostname \"">> $hostnamefile
Hostname"$newhostname"
Echo"OK"
Else
Echo $line
Echo $strip
Echo $strboot
Echo"Error"
Fi
Done