标签:静态ip core 配置 otp lvm out console 网卡 输入
第一个脚本
1)安装autofs并启动
2)安装Tree
3)安装Vim
#!/bin/bash
#********************************************************************
#安装autofs并启动
[ -s /usr/bin/vim ] && echo vim exits || yum -y install vim && echo -e "\e[1;32mvim安装完成\e[0m"
[ -s /usr/lib64/autofs ] && echo autofs exits || yum -y install autofs
systemctl start autofs
systemctl enable autofs
echo -e "\e[1;32m提示信息加载完成\e[0m"
#检测并安装Tree
[ -s /usr/bin/tree ] && echo tree exits || yum -y install tree && echo -e "\e[1;32mTree已安装\e[0m"
#查询CentOS版本
CORE=`cat /etc/redhat-release |grep -o ‘[0-9]‘|head -n1`
echo "$CORE"
case $CORE in
7)
echo -e "\e[1;32m设置CentOS7PS1属性\e[0m"
PREPS1="\[\e[1;32m\][\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$ "
[ "$PS1" = "$PREPS1" ] || echo PS1="\"$PREPS1\"">> ~/.bashrc
;;
8)
echo -e "\e[1;32m设置CentOS8PS1属性\e[0m"
PREPS1="\[\e[1;32m\][\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]# "
[ "$PS1" = "$PREPS1" ] || echo PS1="\"$PREPS1\"" >> ~/.bashrc
;;
*)
echo "UnknownCore"
esac
echo -e "\e[1;32m颜色设置完成,请刷新.bashrc\e[0m"
第二个脚本
主要用于设置学习环境的静态IP,并关闭防火墙
#!/bin/bash
#********************************************************************
#更改grub文件
cat > /etc/sysconfig/grub <<@
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed ‘s, release .*$,,g‘ /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="spectre_v2=retpoline rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet net.ifnames=0"
GRUB_DISABLE_RECOVERY="true"
@
#加载
grub2-mkconfig -o /boot/grub2/grub.cfg
echo -e "\e[1;32mgrub文件更改完成\e[0m"
#移除原有网络配置文件至/data/netset,并建立自定义文件ifcfg-eth0,完成后可更改网卡名
NETSET=/data/netset
NET=/etc/sysconfig/network-scripts/
NETSELF=ifcfg-eth0
NETWORKSIZE=`ls /etc/sysconfig/network-scripts/`
[ -s $NETSET ] || mkdir $NETSET
[ -n "$NETWORKSIZE" ] && [ "$NETWORKSIZE" = $NETSELF ] || mv $NET* $NETSET
[ -s $NET$NETSELF ] && echo -e "\e[1;32m已有自定义文件\e[0m" ||read -p "输入IP后缀:" IPEND && cat > $NET$NETSELF <<@
DEVICE=eth0
NAME=eth0
IPADDR=10.0.0.$IPEND
PREFIX=24
GATEWAY=10.0.0.2
DNS1=180.76.76.76
DNS2=223.6.6.6
BOOTPROTO=static
@
echo -e "\e[1;32m已自定义静态IP文件\e[0m"
systemctl disable firewalld.service
echo -e "\e[1;32m已关闭防火墙\e[0m"
标签:静态ip core 配置 otp lvm out console 网卡 输入
原文地址:https://www.cnblogs.com/zy2271/p/12637138.html