【#yyds干货盘点#文件初始化脚本】当筵意气临九霄,星离雨散不终朝。这篇文章主要讲述#yyds干货盘点#文件初始化脚本相关的知识,希望能为你提供帮助。
文件初始化脚本
[root@c7-147 ~]#cat /scripts/init.sh
#!/bin/bash
realeaseNo=`cat /etc/redhat-release |sed -rn s/.*([[:digit:]]+)\\..*\\..*/\\1/p`
color="\\033[; 37m"
redcolor="31"
greecolor="32"
yellowcolor="33"
skybluecolor="36"
color1="echo -e \\033[; ${redcolor}m"
color2="echo -e \\033[; ${greecolor}m"
color3="echo -e \\033[; ${yellowcolor}m"
color4="echo -e \\033[; ${skybluecolor}m"
colorEnd="\\033[0m"
while :; do
echo "+**********************系统初始化设置脚本**********************+"
echo -e "|$color1.别名和提示符设置\\033[0m|"
echo -e "|$color2.生成脚本基本格式\\033[0m|"
echo -e "|$color3.显示当前主机信息\\033[0m|"
echo -e "|$color4.网卡更名为eth0\\033[0m|"
echo -e "|$color5.关闭SELINUX\\033[0m|"
echo -e "|$color6.编译安装apache\\033[0m|"
echo -e "|$color7.制作光盘yum源\\033[0m|"
echo -e "|$color8.安装阿里云epel源\\033[0m|"
echo -e "|$color9.自建CA并授权\\033[0m|"
echo -e "|$color10.修改网段的主机password\\033[0m|"
echo -e "|$color11.修改ssh端口号\\033[0m|"
echo -e "|$color12.将本机秘钥分发到远程主机\\033[0m|"
echo -e "|$color0.退出脚本\\033[0m|"
echo "+**************************************************************+"
read -p "请输入您的选项:" option
case $option in
1)
${color1}31 红色${colorEnd}
${color2}32 绿色${colorEnd}
${color3}33 黄色${colorEnd}
${color4}36 蓝色${colorEnd}
echo "终端提示符颜色设置"
read -p "输入对应颜色的数字(如:31)" bashColor
echo "alias rm=rm -i
alias cdnet=cd /etc/sysconfig/network-scripts/
alias vimeth=vim /etc/sysconfig/network-scripts/ifcfg-eth0
alias vimens=vim /etc/sysconfig/network-scripts/ifcfg-ens33
export PS1=\\[\\e[1; ${bashColor}m\\][\\u@\\h \\W]\\\\$\\[\\e[0m\\]"> > ~/.bashrc
echo -e "\\033[; ${bashColor}msuccess:别名和提示符设置成功!!\\033[0m"
; ;
2)
[ -e .vimrc ] ||(echo "请准备.vimrc文件" & & exit 1)
\\cp .vimrc ~
echo -e "\\033[; 33msuccess:脚本格式设置成功!!\\033[0m"
; ;
3)
echo "主机名:`hostname`"
echo "IP地址:`ifconfig eth0|sed -rn/inet\\> /s/[^0-9]+([0-9.]+).*/\\1/p`"
echo "系统版本:`cat /etc/redhat-release |cut -d. -f1-2`"
echo "内核版本:`uname -r`"
echo "CPU型号:`lscpu |grep 型号名称:|tr -s|grep -o.*`"
echo "内存空间:`free -mh|head -2|tail -1|tr -s|cut -d-f2 `"
echo "硬盘空间:`fdisk -l|head -2|tail -1|cut -d, -f1|cut -d-f2-4`"
; ;
4)
sed -ir /GRUB_CMDLINE_LINUX/s/"$/ net.ifnames=0"/p /etc/default/grub
grub2-mkconfig -o /etc/grub2.cfg
echo 设置完成请重新启动系统
; ;
5)
sed -i s/SELINUX=enforcing/SELINUX=disabled/ /etc/selinux/config
setenforce 0
; ;
6)
test -f "httpd-2.4.25.tar.gz"||wget http://archive.apache.org/dist/httpd/httpd-2.4.25.tar.gz
tar xvf httpd-2.4.25.tar.gz
cd httpd-2.4.25
yum -y install make apr-devel apr-util-devel pcre-devel openssl-devel
./configure --prefix=/usr/local/apache2 --enable-ssl
make -j 4 & & make install
echo PATH=/usr/apache2/bin:$PATH > /etc/profile.d/apache.sh
id apache & > /dev/null || useradd -r -s /sbin/nologin apache
sed -i -e s/^User daemon$/User apache/ -e s/^Group daemon$/Group apache/ /usr/local/apache2/conf推荐阅读
- #yyds干货盘点#linux命令--Hostname 显示主机名
- 性能分析之子锁存器(latch)到SQL
- docker如何迁移数据目录
- 第十四周
- k8s实战课程笔记
- NFS共享服务
- 文本处理sed&软件管理
- 十三周
- 0到1快速掌握Java全栈开发,玩转微信生态