十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
能用,有待完善
CentOS7测试
创新互联公司服务项目包括思礼网站建设、思礼网站制作、思礼网页制作以及思礼网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,思礼网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到思礼省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
哈哈
reset2.0.sh(20190906)
#!/bin/bash
#**
#Author: 28
#QQ: ×××
#Date: 2019-08-01
#FileName: reset.sh
#URL: https://blog.51cto.com/14012942
#Description: The test script
#Copyright (C): 2019 Copyright © 站点名称 版权所有
#****
#set -e
RED="\033[0;31m"
GREEN="\033[0;32m"
NO_COLOR="\033[0m"
modify_alias() {
cat >> ~/.bashrc <
alias editnet='vim /etc/sysconfig/network-scripts/ifcfg-ens33'
alias rm='rm -i'
alias scandisk="echo ' - - - ' > /sys/class/scsi_host/host0/scan;echo ' - - - ' > /sys/class/scsi_host/host1/scan;echo ' - - - ' > /sys/class/scsi_host/host2/scan"
EOF
}
modify_PS1() {
echo 'PS1="[\e[1;34m][\u@\h \W]\$[\e[0m] "' >> /etc/profile.d/env.sh
}
install_software() {
yum install gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel zlib-devel vim lrzsz tree screen lsof tcpdump wget ntpdate net-tools iotop bc zip unzip nfs-utils -y
}
replace_yum() {
#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
#wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum makecache
}
modify_vimrc() {
cat > ~/.vimrc <
set cursorline
set autoindent
set ai
autocmd BufNewFile *.sh exec ":call SetTitle()"
func SetTitle()
if expand("%:e") == 'sh'
call setline(1,"#!/bin/bash")
call setline(2,"#**")
call setline(3,"#Author: Linus")
call setline(4,"#QQ: ×××")
call setline(5,"#Date: ".strftime("%Y-%m-%d"))
call setline(6,"#FileName: ".expand("%"))
call setline(7,"#URL: https://blog.51cto.com/14012942")
call setline(8,"#Description: Initialize the new server")
call setline(9,"#Copyright (C): ".strftime("%Y")." Copyright © 站点名称 版权所有")
call setline(10,"#****")
call setline(11,"")
endif
endfunc
autocmd BufNewFile * normal G
EOF
}
iptables_selinux_stop() {
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
systemctl stop firewalld
systemctl disable firewalld
}
judge_root() {
[ $(id -u) != "0" ] && { echo -e "${RED}Error:${NO_COLOR} You must be root to run this script."; exit 1; }
}
Check_release() {
if [ -f /etc/redhat-release ];then
release="centos"
version=sed -r 's/.* ([0-9]+)\..*/\1/' /etc/redhat-release
if [ "$version" = "7" ];then
echo "Current release: CentOS7."
else {
echo -e "[${RED}Error${NO_COLOR}] This script can only be running on CentOS7."
exit 1
}
fi
else {
echo -e "[${RED}Error${NO_COLOR}] This script can only be running on CentOS7."
exit 1
}
fi
}
########################时区调整########################
timezone_adjust(){
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
}
#修改网卡为eth0
modify_eth_card() {
ip a | grep -q eth0
if [ "$?" -eq 1 ];then
sed -ri '/^GRUB_CMDLINE/s/(.*)"/\1 net.ifnames=0"/' /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
fi
}
#自动补全
bash_completion() {
yum install bash-completion -y
source /usr/share/bash-completion/bash_completion
}
#时间同步
time_sync(){
yum install chrony -y
sed '/^server/s/^/#/' /etc/chrony.conf -i
sed '1a server ntp.aliyun.com iburst' /etc/chrony.conf -i
sed '1a server 0.cn.pool.ntp.org iburst' /etc/chrony.conf -i
sed '1a server ntp1.aliyun.com iburst' /etc/chrony.conf -i
systemctl restart chronyd
systemctl enable chronyd
}
#ssh调优
ssh_adjust(){
cp /etc/ssh/sshd_config{,_bak}
sed '/^GSSAPIAuthentication/d' /etc/ssh/sshd_config -i
sed '/^UseDNS/d' /etc/ssh/sshd_config -i
echo "GSSAPIAuthentication no" >> /etc/ssh/sshd_config
echo "UseDNS no" >> /etc/ssh/sshd_config
systemctl restart sshd
}
#最大文件打开数
limits_tune(){
echo '
root soft nofile 128000
root hard nofile 256000
' >> /etc/security/limits.conf
}
main() {
judge_root
Check_release
replace_yum
install_software
iptables_selinux_stop
modify_alias
modify_vimrc
timezone_adjust
time_sync
limits_tune
ssh_adjust
modify_PS1
modify_eth_card
bash_completion
}
main
reset1.0.sh(20190808)
#!/bin/bash
#**
#Author: 28
#QQ: ×××
#Date: 2019-08-01
#FileName: reset.sh
#URL: https://blog.51cto.com/14012942
#Description: The test script
#Copyright (C): 2019 Copyright © 站点名称 版权所有
#****
#set -e
RED="\033[0;31m"
GREEN="\033[0;32m"
NO_COLOR="\033[0m"
modify_alias() {
cat >> ~/.bashrc <
alias editnet='vim /etc/sysconfig/network-scripts/ifcfg-ens33'
alias rm='rm -i'
alias scandisk="echo ' - - - ' > /sys/class/scsi_host/host0/scan;echo ' - - - ' > /sys/class/scsi_host/host1/scan;echo ' - - - ' > /sys/class/scsi_host/host2/scan"
EOF
}
modify_PS1() {
echo 'PS1="[\e[1;34m][\u@\h \W]\$[\e[0m] "' >> /etc/profile.d/env.sh
}
install_software() {
yum install gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel zlib-devel vim lrzsz tree screen lsof tcpdump wget ntpdate net-tools iotop bc zip unzip nfs-utils -y
}
replace_yum() {
#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
#wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum makecache
}
modify_vimrc() {
cat > ~/.vimrc <
set cursorline
set autoindent
set ai
autocmd BufNewFile *.sh exec ":call SetTitle()"
func SetTitle()
if expand("%:e") == 'sh'
call setline(1,"#!/bin/bash")
call setline(2,"#**")
call setline(3,"#Author: Linus")
call setline(4,"#QQ: ×××")
call setline(5,"#Date: ".strftime("%Y-%m-%d"))
call setline(6,"#FileName: ".expand("%"))
call setline(7,"#URL: https://blog.51cto.com/14012942")
call setline(8,"#Description: Initialize the new server")
call setline(9,"#Copyright (C): ".strftime("%Y")." Copyright © 站点名称 版权所有")
call setline(10,"#****")
call setline(11,"")
endif
endfunc
autocmd BufNewFile * normal G
EOF
}
iptables_selinux_stop() {
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
systemctl stop firewalld
systemctl disable firewalld
}
judge_root() {
[ $(id -u) != "0" ] && { echo -e "${RED}Error:${NO_COLOR} You must be root to run this script."; exit 1; }
}
Check_release() {
if [ -f /etc/redhat-release ];then
release="centos"
version=sed -r 's/.* ([0-9]+)\..*/\1/' /etc/redhat-release
if [ "$version" = "7" ];then
echo "Current release: CentOS7."
else {
echo -e "[${RED}Error${NO_COLOR}] This script can only be running on CentOS7."
exit 1
}
fi
else {
echo -e "[${RED}Error${NO_COLOR}] This script can only be running on CentOS7."
exit 1
}
fi
}
########################时区调整########################
timezone_adjust(){
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
}
#修改网卡为eth0
modify_eth_card() {
ip a | grep -q eth0
if [ "$?" -eq 1 ];then
sed -ri '/^GRUB_CMDLINE/s/(.*)"/\1 net.ifnames=0"/' /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
fi
}
#自动补全
bash_completion() {
yum install bash-completion -y
source /usr/share/bash-completion/bash_completion
}
main() {
judge_root
Check_release
replace_yum
install_software
iptables_selinux_stop
modify_alias
modify_vimrc
timezone_adjust
modify_PS1
modify_eth_card
bash_completion
}
main