shell脚本一键部署——装机设置
shell脚本一键部署——装机设置
#!/bin/bash #---------------modify hostname-------------------- echo "Modify Hostname" hostnamectl set-hostname $1 #----------modify network static ip---------- echo "Modify network static ip" sed -i 's/dhcp/static/' /etc/sysconfig/network-scripts/ifcfg-ens33 echo "IPADDR=$2" >> /etc/sysconfig/network-scripts/ifcfg-ens33 echo "NETMASK=255.255.255.0" >> /etc/sysconfig/network-scripts/ifcfg-ens33 echo "GATEWAY=${2%.*}.2" >> /etc/sysconfig/network-scripts/ifcfg-ens33 echo "DNS1=114.114.114.114" >> /etc/sysconfig/network-scripts/ifcfg-ens33 echo "DNS2=8.8.8.8" >> /etc/sysconfig/network-scripts/ifcfg-ens33 systemctl restart network #--------------------modify hosts file----------- echo "Modify Hosts file" echo "$2 $1" >> /etc/hosts #----------------modify firewalld--------------- echo "Close Firewalld" systemctl stop firewalld systemctl disabled firewalld #------------modify selinux----------- sed -i 's/SELINUX=enforcing/SELINUX=disabled\n/' /etc/selinux/config #-------------modify yum source--------- echo "Modify Yum Source" yum install -y wget net-tools cd /etc/yum.repos.d/ mv CentOS-Base.repo CentOS-Base.repo_bak wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo yum clean all yum makecache
将本人在工作学习中的一些知识记录并分享