linux系统初始化脚本

系统初始化脚本
vim teacher.sh
设置主机的IP地址、网关、dns域名

#!/bin/bash
read -p "输入你当前Linux的IP地址:"  LAST
ETH=` ifconfig  | head -1 | awk -F ":"  '{print $1}'`
GATE="`echo $LAST | awk -F "." '{print $1"."$2"."$3"."}'`2"
END=`echo $LAST | awk -F "." '{print $NF}'`

cat > /etc/sysconfig/network-scripts/ifcfg-$ETH <> /etc/rc.d/rc.local

mv /etc/yum.repos.d/*.repo  /tmp/yum.bak

touch /etc/yum.repos.d/base.repo

cat > /etc/yum.repos.d/base.repo << EOF
[base]
name=base
baseurl=file:///iso
enabled=1
gpgcheck=0
EOF

#关闭selinux
cat > /etc/selinux/config << EOF
SELINUX=disabled 
SELINUXTYPE=targeted 
EOF
#关闭防火墙
iptables -F
systemctl stop firewalld
systemctl disable  firewalld 
#关闭网络管理
systemctl  stop NetworkManager
systemctl  disable  NetworkManager
#重启
init 6

你可能感兴趣的:(Linux运维)