————————————————

CentOS7初始化脚本

#!/bin/bash
#CentOS7初始化脚本,需要自行修改部分参数(此脚本适合虚拟机部署使用,业务场景尽量不建议使用)
# set ip 
nmcli connection modify ens33 ipv4.addresses 192.168.35.30/24
nmcli connection modify ens33 ipv4.gateway 192.168.35.2
nmcli connection modify ens33 ipv4.dns 114.114.114.114
nmcli connection modify ens33 ipv4.method manual
nmcli connection up ens33 
echo -e "\033[32m-----------------------------------ip_ipaddrss changed !!!--------------------------------------\033[0m" 

#set hostname
ipaddress=` ifconfig ens33 |grep -w inet |tr -s " "|cut -d " " -f3`
last_num=`echo  $ipaddress |cut -d "." -f4`
hostname=`hostnamectl set-hostname host$last_num`
echo -e "hostname: `hostname`"
echo -e  "\033[32m-----------------------------------hostname changed !!!--------------------------------------\033[0m" 

#set yum source
cd /etc/yum.repos.d
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
wget -O /etc/yum.repos.d/CentOS-Base.repo  http://mirrors.163.com/.help/CentOS7-Base-163.repo
yum clean all && yum clean metadata && yum clean dbcache && yum makecache  
yum -y install tree nmap dos2unix lrzsz nc lsof wget tcpdump htop iftop iotop sysstat nethogs vim -y
				   
echo -e "\033[32m -----------------------------------yum repo changed !!!--------------------------------------\033[0m"

#stop firewalld 
systemctl stop firewalld 
systemctl disable firewalld
echo -e "\033[32m -----------------------------------firewalld status changed !!!--------------------------------------\033[0m"

#disable selinux
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/sysconfig/selinux
sed -i 's/^SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
echo -e "\033[32m -----------------------------------selinux status changed !!!--------------------------------------\033[0m"

posted @   Tjane'Blogs  阅读(48)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
点击右上角即可分享
微信分享提示