Tag:quit Settings tin lap run dhcp ipa egrep pat
#!/bin/bashifo () {read-p "Configure $line Network Card (' Yes ' or ' no ')?" CDN </dev/tty if ["${cdn}" = = yes];then add_d else echo "quiting" Exit Fi}net_w () {while:;d ostr= ' cat/etc/udev/rules.d/70-persistent-net.rules | grep subsystem= | cut-d ' -f7 | cut-d=-f2 | Sed ' s/'//g ' echo ' $STR | While read Line;doecho $linedoneecho "Please input configure network card?" Read nameline= $nameIFOcontinuedone}ipc () {echo $ | grep-op ' ((\d) +.) {3}\d+ ' &>/dev/nulluntil [$?-eq 0];d oecho-e "\033[33MIP address error! Please run again...\033[0m "Exit 4done}cat_c () {boot_d= ' cat/etc/sysconfig/network-scripts/ifcfg-$line | grep bootproto | Awk-f ' = ' {print $} ' if [$BOOT _d = = DHCP];then echo-e ' Now ' \033[31m$boot_d\033[0m Type ' elif [$BOOT _d = n One];then echo-e "now is \033[31m$boot_d\033[0m Type" elif [$BOOT _d = static];then echo-e "Now is \033[ 31m$boot_d\033[0m Type "Else echo "option error ..." Fi}add_d () {[-f/etc/sysconfig/network-scripts/ifcfg-$line] && echo-e "Configure network card:\033[1;34m $line \033[0m "If [$-eq 1];thenecho-e" #######################\nnot found $line configure file\n###### ############################# "continueficat_d= ' cat/etc/sysconfig/network-scripts/ifcfg-$line | Grep-v "#" | Egrep "ipaddr| netmask| GATEWAY "| | echo "Parameter is null" ' Echo-e "\033[31m*******************************\033[0m\033[1;34m\na total Of\n$str\n\nnow Ncurrent netwrok $line: \n$cat_d\033[0m "cat_cecho-e" \033[31m*************************************\033[0m "Read-p" Please input ipaddr: "II </dev/ttyipc $II read-p" Please input GATEWAY: "GA </dev/ttyipc $GAread-P" please input NETMASK: "NE </dev/ttyipc $NE iii=" ipaddr= $II "gaa=" gateway= $GA "nee=" netmask= $NE "path1="/etc/sy sconfig/network-scripts/ifcfg-$line "ipaddr_d= ' cat/etc/sysconfig/network-scripts/ifcfg-$line | grep "ipaddr=" ' netmask_d= ' cat/etc/sysconfig/network-scripts/ifcfg-$line | grep "netmask=" ' gateway_d= ' cat/etc/sysconfig/network-scripts/ifcfg-$line | grep "gateway=" ' Sed-i "s/$IPADDR _d/$III/g" $PATH 1 &>/dev/null | | echo $III >> $PATH 1sed-i "s/$NETMASK _d/$NEE/g" $PATH 1 &>/dev/null | | echo $NEE >> $PATH 1 sed-i "s/$GATEWAY _d/$GAA/g" $PATH 1 &>/dev/null | | echo $GAA >> $PATH 1 sed-i ' s/onboot=no/onboot=yes/g '/etc/sysconfig/network-scripts/ifcfg-$line sed- I ' s/nm_controlled=yes/nm_controlled=no/g '/etc/sysconfig/network-scripts/ifcfg-$linesed-i ' s/BOOTPROTO=dhcp/ Bootproto=static/g '/etc/sysconfig/network-scripts/ifcfg-$linesed-i ' s/bootproto=none/bootproto=static/g '/etc/ sysconfig/network-scripts/ifcfg-$line ifdown $line && ifup $line &>/dev/null && echo "Restar T network card finished "asa= ' cat/etc/sysconfig/network-scripts/ifcfg-$line ' echo-e" \033[35m$asa\033[0m "}NET_W
Pure practiced hand set IP address script