首页 > 其他 > 详细

init_install_v2.sh

时间:2019-07-17 10:17:30      阅读:33      评论:0      收藏:0      [点我收藏+]

标签:kcon   ORC   prot   eth   etc   install   mes   NPU   true   

 1 #!/bin/bash
 2 set -o errexit 
 3 
 4 host_name="$1"
 5 interface_old_name=`ip addr|grep BROADCAST|awk {print $2}|sed s/://g`
 6 interface_new_name="eth0"
 7 ipaddr=`ip addr|grep inet|grep brd|grep global|awk {print $2}|grep -Eo ([0-9]{1,3}\.){3}[0-9]{1,3}`
 8 netmask="255.255.255.0"
 9 gateway="`ip addr|grep inet|grep brd|grep global|awk ‘{print $2}‘|grep -Eo ‘([0-9]{1,3}\.){3}‘`2"
10 
11 
12 
13 #hostname
14 if [[ -n ${host_name} ]];then
15     echo "${host_name}" > /etc/hostname
16 else
17     echo "please input $1..."
18     exit 4
19 fi
20 
21 # grub
22 set flag=0
23 grep -e "net.ifnames=0" /etc/default/grub  > /dev/null 2>&1 || flag=1
24 if [ ${flag}  -ne 0 ];then
25     s=`grep GRUB_CMDLINE_LINUX /etc/default/grub`
26     s2="${s%\"*} net.ifnames=0 biosdevname=0\""
27     sed -i "s#GRUB_CMDLINE_LINUX=.*#${s2}#g" /etc/default/grub
28     grub2-mkconfig -o /boot/grub2/grub.cfg
29     unset s
30     unset s2
31     flag=0
32 fi
33 
34 #修改网卡名,并配置
35 mv /etc/sysconfig/network-scripts/ifcfg-${interface_old_name} /etc/sysconfig/network-scripts/ifcfg-${interface_old_name}.bak || true
36 cat > /etc/sysconfig/network-scripts/ifcfg-${interface_new_name} << EOF
37 TYPE="Ethernet"
38 PROXY_METHOD="none"
39 BOOTPROTO="static"
40 NAME="${interface_new_name}"
41 DEVICE="${interface_new_name}"
42 ONBOOT="yes"
43 IPADDR="${ipaddr}"
44 GATEWAY="${gateway}"
45 NETMASK="${netmask}"
46 DNS1=8.8.8.8
47 EOF
48 
49 #disable networkmanager
50 systemctl stop NetworkManager || true
51 systemctl disable NetworkManager || true
52 sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
53 
54 yum -y update
55 echo "10s aftre reboot..."
56 sleep 10
57 
58 reboot

 

init_install_v2.sh

标签:kcon   ORC   prot   eth   etc   install   mes   NPU   true   

原文:https://www.cnblogs.com/zhj5551/p/11198330.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 bubuko.com 版权所有 鲁ICP备09046678号-4
打开技术之扣,分享程序人生!
             

鲁公网安备 37021202000002号