码迷,mamicode.com
首页 > 其他好文 > 详细

centos7自动配置脚本

时间:2018-10-01 01:03:12      阅读:442      评论:0      收藏:0      [点我收藏+]

标签:stop   netmask   evel   config   awk   conf   browser   mask   fir   

#!/bin/bash

currentTime=$(date +"%Y-%m-%d_%H:%M:%S")

echo "blacklist i2c_piix4"  >> /etc/modprobe.d/blacklist.conf
echo "blacklist pcspkr" >> /etc/modprobe.d/blacklist.conf

##network_config
host_name="centos7"
domain_name="local"
host_ip="192.168.127.20"
gateway="192.168.127.254"
dns1="114.114.114.114"
dns2="8.8.8.8"
netmask="24"

net_device_name=$(nmcli dev status | sed -n 2p | awk '{print $1}')
net_conf='/etc/sysconfig/network-scripts/ifcfg-'$net_device_name
net_device_uuid=$(cat $net_conf | grep UUID)

echo "$host_ip      $host_name      $host_name.$domain_name" >> /etc/hosts

mv $net_conf $net_conf'.bak'$currentTime

cat > $net_conf <<EOF
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=$net_device_name
$net_device_uuid
DEVICE=$net_device_name
ONBOOT=yes
IPADDR=$host_ip
PREFIX=$netmask
GATEWAY=$gateway
DNS1=$dns1
DNS2=$dns2
EOF

hostnamectl set-hostname $host_name'.'$domain_name

##sys_config
sed -i '/UseDNS yes/s/^/#/' /etc/ssh/sshd_config
sed -i '/#UseDNS yes/a UseDNS no' /etc/ssh/sshd_config

sed -i '/SELINUX=enforcing/s/^/#/' /etc/selinux/config
sed -i '/#SELINUX=enforcing/a SELinux=disabled' /etc/selinux/config

systemctl stop firewalld
systemctl disable firewalld

yum -y update
yum -y groupinstall "Development Tools"
yum -y install vim wget


centos7自动配置脚本

标签:stop   netmask   evel   config   awk   conf   browser   mask   fir   

原文地址:https://www.cnblogs.com/javaite/p/9733853.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!