mirror of
https://github.com/dunwu/linux-tutorial.git
synced 2024-04-15 19:55:24 +08:00
update scripts
This commit is contained in:
parent
90908bb378
commit
2b73cbc127
@ -1,4 +1,4 @@
|
|||||||
# Linux 傻瓜式运维脚本
|
# Dunwu Shell 运维脚本
|
||||||
|
|
||||||
> **本项目脚本代码用于在 [CentOS](https://www.centos.org/) 机器上安装常用命令工具或开发软件。**
|
> **本项目脚本代码用于在 [CentOS](https://www.centos.org/) 机器上安装常用命令工具或开发软件。**
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
###################################################################################
|
# ---------------------------------------------------------------------------------
|
||||||
# 控制台颜色
|
# 控制台颜色
|
||||||
BLACK="\033[1;30m"
|
BLACK="\033[1;30m"
|
||||||
RED="\033[1;31m"
|
RED="\033[1;31m"
|
||||||
@ -10,11 +10,10 @@ BLUE="\033[1;34m"
|
|||||||
PURPLE="\033[1;35m"
|
PURPLE="\033[1;35m"
|
||||||
CYAN="\033[1;36m"
|
CYAN="\033[1;36m"
|
||||||
RESET="$(tput sgr0)"
|
RESET="$(tput sgr0)"
|
||||||
###################################################################################
|
# ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
printf "${BLUE}"
|
printf "${BLUE}\n"
|
||||||
cat << EOF
|
cat << EOF
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
# linux-tutorial 运维脚本工具集下载脚本
|
# linux-tutorial 运维脚本工具集下载脚本
|
||||||
# 下载 https://github.com/dunwu/linux-tutorial 中的所有脚本到当前服务器的
|
# 下载 https://github.com/dunwu/linux-tutorial 中的所有脚本到当前服务器的
|
||||||
@ -23,23 +22,27 @@ cat << EOF
|
|||||||
# @author: Zhang Peng
|
# @author: Zhang Peng
|
||||||
# See: https://github.com/dunwu/linux-tutorial
|
# See: https://github.com/dunwu/linux-tutorial
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
printf "${RESET}"
|
printf "${RESET}\n"
|
||||||
|
|
||||||
path=/home/scripts/linux-tutorial
|
root=/home/scripts/linux-tutorial
|
||||||
printf "\n${GREEN}>>>>>>>> Download linux-tutorial to ${path} begin.${RESET}\n"
|
printf "\n${GREEN}>>>>>>>> Download linux-tutorial to ${root} begin.${RESET}\n"
|
||||||
command -v yum > /dev/null 2>&1 || { printf "${RED}Not detected yum.${RESET}";
|
command -v yum > /dev/null 2>&1 || {
|
||||||
exit 1; }
|
printf "\n${RED}Not detected yum.${RESET}";
|
||||||
command -v git > /dev/null 2>&1 || { printf "${YELLOW}Not detected git. Install git.${RESET}\n";
|
exit 1;
|
||||||
yum -y install git; }
|
}
|
||||||
|
|
||||||
if [[ -d ${path} ]]; then
|
command -v git > /dev/null 2>&1 || {
|
||||||
cd ${path}
|
printf "\n${YELLOW}Not detected git. Install git.${RESET}\n";
|
||||||
|
yum install -y git;
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -d ${root} ]]; then
|
||||||
|
cd ${root}
|
||||||
git pull
|
git pull
|
||||||
else
|
else
|
||||||
mkdir -p ${path}
|
mkdir -p ${root}
|
||||||
git clone https://gitee.com/turnon/linux-tutorial.git ${path}
|
git clone https://gitee.com/turnon/linux-tutorial.git ${root}
|
||||||
fi
|
fi
|
||||||
chmod +x -R ${path}
|
chmod +x -R ${root}
|
||||||
printf "\n${GREEN}<<<<<<<< Download linux-tutorial to ${path} end.${RESET}\n"
|
printf "\n${GREEN}<<<<<<<< Download linux-tutorial to ${root} end.${RESET}\n"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
###################################################################################
|
# ---------------------------------------------------------------------------------
|
||||||
# 控制台颜色
|
# 控制台颜色
|
||||||
BLACK="\033[1;30m"
|
BLACK="\033[1;30m"
|
||||||
RED="\033[1;31m"
|
RED="\033[1;31m"
|
||||||
@ -10,82 +10,74 @@ BLUE="\033[1;34m"
|
|||||||
PURPLE="\033[1;35m"
|
PURPLE="\033[1;35m"
|
||||||
CYAN="\033[1;36m"
|
CYAN="\033[1;36m"
|
||||||
RESET="$(tput sgr0)"
|
RESET="$(tput sgr0)"
|
||||||
###################################################################################
|
# ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
# 打印头部信息
|
# 打印头部信息
|
||||||
printHeadInfo() {
|
printHeadInfo() {
|
||||||
printf "${BLUE}"
|
printf "${BLUE}\n"
|
||||||
cat << EOF
|
cat << EOF
|
||||||
|
###################################################################################
|
||||||
***********************************************************************************
|
# 欢迎使用 Dunwu Shell 运维脚本
|
||||||
* 欢迎使用 Linux CentOS 环境运维脚本
|
# 适用于 Linux CentOS 环境
|
||||||
* @author: Zhang Peng
|
# @author: Zhang Peng
|
||||||
***********************************************************************************
|
###################################################################################
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
printf "${RESET}"
|
printf "${RESET}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 打印尾部信息
|
# 打印尾部信息
|
||||||
printFootInfo() {
|
printFootInfo() {
|
||||||
printf "${BLUE}"
|
printf "${BLUE}\n"
|
||||||
cat << EOF
|
cat << EOF
|
||||||
|
###################################################################################
|
||||||
***********************************************************************************
|
# 脚本执行结束,感谢使用!
|
||||||
* 脚本执行结束,感谢使用!
|
###################################################################################
|
||||||
***********************************************************************************
|
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
printf "${RESET}"
|
printf "${RESET}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 检查操作系统环境
|
# 检查操作系统环境
|
||||||
checkOsVersion() {
|
checkOsVersion() {
|
||||||
if (($1 == 1)); then
|
if (($1 == 1)); then
|
||||||
echo -e "检查操作系统环境是否兼容本套脚本"
|
|
||||||
|
|
||||||
platform=`uname -i`
|
platform=`uname -i`
|
||||||
if [[ ${platform} != "x86_64" ]]; then
|
if [[ ${platform} != "x86_64" ]]; then
|
||||||
echo "脚本仅支持 64 位操作系统!"
|
printf "\n${RED}脚本仅支持 64 位操作系统!${RESET}\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
version=`cat /etc/redhat-release | awk '{print substr($4,1,1)}'`
|
version=`cat /etc/redhat-release | awk '{print substr($4,1,1)}'`
|
||||||
if [[ ${version} != 7 ]]; then
|
if [[ ${version} != 7 ]]; then
|
||||||
echo "脚本仅支持 CentOS 7!"
|
printf "\n${RED}脚本仅支持 CentOS 7!${RESET}\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "脚本可以在本环境运行!"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
menus=( "配置系统" "安装软件" "退出" )
|
menus=( "配置系统" "安装软件" "退出" )
|
||||||
main() {
|
selectAndExecTask() {
|
||||||
|
printHeadInfo
|
||||||
PS3="请输入命令编号:"
|
PS3="请输入命令编号:"
|
||||||
select item in "${menus[@]}"
|
select item in "${menus[@]}"
|
||||||
do
|
do
|
||||||
case ${item} in
|
case ${item} in
|
||||||
"配置系统")
|
"配置系统")
|
||||||
./dunwu-sys.sh
|
./dunwu-sys.sh
|
||||||
main ;;
|
selectAndExecTask ;;
|
||||||
"安装软件")
|
"安装软件")
|
||||||
./dunwu-soft.sh
|
./dunwu-soft.sh
|
||||||
main ;;
|
selectAndExecTask ;;
|
||||||
"退出")
|
"退出")
|
||||||
|
printFootInfo
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
*)
|
*)
|
||||||
printf "输入项不支持!\n"
|
printf "\n${RED}输入项不支持!${RESET}\n"
|
||||||
main ;;
|
selectAndExecTask ;;
|
||||||
esac
|
esac
|
||||||
break
|
break
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
######################################## MAIN ########################################
|
######################################## MAIN ########################################
|
||||||
path=$(cd "$(dirname "$0")";
|
checkOsVersion 1
|
||||||
pwd)
|
selectAndExecTask
|
||||||
printHeadInfo
|
|
||||||
checkOsVersion 0
|
|
||||||
main
|
|
||||||
printFootInfo
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
###################################################################################
|
# ---------------------------------------------------------------------------------
|
||||||
# 控制台颜色
|
# 控制台颜色
|
||||||
BLACK="\033[1;30m"
|
BLACK="\033[1;30m"
|
||||||
RED="\033[1;31m"
|
RED="\033[1;31m"
|
||||||
@ -10,22 +10,22 @@ BLUE="\033[1;34m"
|
|||||||
PURPLE="\033[1;35m"
|
PURPLE="\033[1;35m"
|
||||||
CYAN="\033[1;36m"
|
CYAN="\033[1;36m"
|
||||||
RESET="$(tput sgr0)"
|
RESET="$(tput sgr0)"
|
||||||
###################################################################################
|
# ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
printf "${BLUE}\n"
|
printf "${BLUE}\n"
|
||||||
cat << EOF
|
cat << EOF
|
||||||
|
###################################################################################
|
||||||
***********************************************************************************
|
# 欢迎使用 Dunwu Shell 软件安装脚本
|
||||||
* 欢迎使用 Linux CentOS 软件安装配置脚本
|
# 适用于 Linux CentOS 环境
|
||||||
* @author: Zhang Peng
|
# @author: Zhang Peng
|
||||||
***********************************************************************************
|
###################################################################################
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
printf "${RESET}\n"
|
||||||
|
|
||||||
# print menu
|
# print menu
|
||||||
|
printMenu() {
|
||||||
printf "${PURPLE}"
|
printf "${PURPLE}"
|
||||||
menus=( docker fastdfs gitlab jdk8 jenkins kafka maven mongodb mysql nacos nexus nginx nodejs redis rocketmq tomcat8
|
menus=( docker fastdfs gitlab jdk8 jenkins kafka maven mongodb mysql nacos nexus nginx nodejs redis rocketmq tomcat8 zookeeper zsh exit )
|
||||||
zookeeper zsh exit )
|
|
||||||
for i in "${!menus[@]}"; do
|
for i in "${!menus[@]}"; do
|
||||||
index=`expr ${i} + 1`
|
index=`expr ${i} + 1`
|
||||||
val=`expr ${index} % 2`
|
val=`expr ${index} % 2`
|
||||||
@ -34,28 +34,33 @@ for i in "${!menus[@]}"; do
|
|||||||
printf "\n"
|
printf "\n"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
printf "\n${RESET}请输入需要安装的软件编号:\n"
|
|
||||||
|
printf "\n\n${BLUE}请选择需要安装的软件:${RESET}"
|
||||||
|
}
|
||||||
|
|
||||||
# exec shell to install soft
|
# exec shell to install soft
|
||||||
doInstall() {
|
main() {
|
||||||
|
printMenu
|
||||||
read -t 30 index
|
read -t 30 index
|
||||||
if [[ -n ${index} ]]; then
|
if [[ -n ${index} ]]; then
|
||||||
no=`expr ${index} - 1`
|
no=`expr ${index} - 1`
|
||||||
len=${#menus[*]}
|
len=${#menus[*]}
|
||||||
if [[ ${index} -gt ${len} ]]; then
|
if [[ ${index} -gt ${len} ]]; then
|
||||||
echo "输入项不支持!"
|
printf "${RED}输入项不支持!\n${RESET}"
|
||||||
exit -1
|
exit -1
|
||||||
fi
|
fi
|
||||||
key=${menus[$no]}
|
key=${menus[$no]}
|
||||||
if [[ key == 'exit' ]]; then
|
if [[ ${key} == 'exit' ]]; then
|
||||||
|
printf "${GREEN}退出 Dunwu 软件安装脚本。\n${RESET}"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/${key}-install.sh | bash
|
sh soft/${key}-install.sh
|
||||||
doInstall
|
printf "\n"
|
||||||
|
main
|
||||||
else
|
else
|
||||||
echo "输入项不支持!"
|
printf "${RED}输入项不支持!\n${RESET}"
|
||||||
exit -1
|
exit -1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
doInstall
|
main
|
||||||
|
@ -1,13 +1,26 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
cat << EOF
|
# ---------------------------------------------------------------------------------
|
||||||
|
# 控制台颜色
|
||||||
|
BLACK="\033[1;30m"
|
||||||
|
RED="\033[1;31m"
|
||||||
|
GREEN="\033[1;32m"
|
||||||
|
YELLOW="\033[1;33m"
|
||||||
|
BLUE="\033[1;34m"
|
||||||
|
PURPLE="\033[1;35m"
|
||||||
|
CYAN="\033[1;36m"
|
||||||
|
RESET="$(tput sgr0)"
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
printf "${BLUE}\n"
|
||||||
|
cat << EOF
|
||||||
###################################################################################
|
###################################################################################
|
||||||
# Linux CentOS 环境初始化脚本(设置环境配置、安装基本的命令工具)
|
# 欢迎使用 Dunwu Shell 环境初始化脚本(设置环境配置、安装基本的命令工具)
|
||||||
|
# 适用于 Linux CentOS 环境
|
||||||
# @author: Zhang Peng
|
# @author: Zhang Peng
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
printf "${RESET}\n"
|
||||||
|
|
||||||
menus=( "替换yum镜像" "安装基本的命令工具" "安装常用libs" "系统配置" "全部执行" "退出" )
|
menus=( "替换yum镜像" "安装基本的命令工具" "安装常用libs" "系统配置" "全部执行" "退出" )
|
||||||
main() {
|
main() {
|
||||||
@ -16,27 +29,27 @@ main() {
|
|||||||
do
|
do
|
||||||
case ${item} in
|
case ${item} in
|
||||||
"替换yum镜像")
|
"替换yum镜像")
|
||||||
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/sys/change-yum-repo.sh | bash
|
sh ${root}/sys/change-yum-repo.sh
|
||||||
main ;;
|
main ;;
|
||||||
"安装基本的命令工具")
|
"安装基本的命令工具")
|
||||||
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/sys/install-tools.sh | bash
|
sh ${root}/sys/install-tools.sh
|
||||||
main ;;
|
main ;;
|
||||||
"安装常用libs")
|
"安装常用libs")
|
||||||
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/sys/install-libs.sh | bash
|
sh ${root}/sys/install-libs.sh
|
||||||
main ;;
|
main ;;
|
||||||
"系统配置")
|
"系统配置")
|
||||||
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/sys/sys-settings.sh | bash
|
sh ${root}/sys/sys-settings.sh ${root}/sys
|
||||||
main ;;
|
main ;;
|
||||||
"全部执行")
|
"全部执行")
|
||||||
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/sys/change-yum-repo.sh | bash
|
sh ${root}/sys/change-yum-repo.sh
|
||||||
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/sys/install-tools | bash
|
sh ${root}/sys/install-tools.sh
|
||||||
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/sys/install-libs.sh | bash
|
sh ${root}/sys/install-libs.sh
|
||||||
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/sys/sys-settings.sh | bash
|
sh ${root}/sys/sys-settings.sh ${root}/sys
|
||||||
printf "执行完毕,退出。\n" ;;
|
printf "${GREEN}执行完毕,退出。${RESET}\n" ;;
|
||||||
"退出")
|
"退出")
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
*)
|
*)
|
||||||
printf "输入项不支持!\n"
|
printf "${RED}输入项不支持!${RESET}\n"
|
||||||
main ;;
|
main ;;
|
||||||
esac
|
esac
|
||||||
break
|
break
|
||||||
@ -44,4 +57,5 @@ main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
######################################## MAIN ########################################
|
######################################## MAIN ########################################
|
||||||
|
root=$(pwd)
|
||||||
main
|
main
|
||||||
|
@ -1,15 +1,28 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
# 控制台颜色
|
||||||
|
BLACK="\033[1;30m"
|
||||||
|
RED="\033[1;31m"
|
||||||
|
GREEN="\033[1;32m"
|
||||||
|
YELLOW="\033[1;33m"
|
||||||
|
BLUE="\033[1;34m"
|
||||||
|
PURPLE="\033[1;35m"
|
||||||
|
CYAN="\033[1;36m"
|
||||||
|
RESET="$(tput sgr0)"
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
printf "${BLUE}\n"
|
||||||
cat << EOF
|
cat << EOF
|
||||||
###################################################################################
|
###################################################################################
|
||||||
# 本脚本用于替换 yum repo,使用国内 yum 仓库,加速下载
|
# 本脚本用于替换 yum repo,使用国内 yum 仓库,加速下载
|
||||||
# 要求:仅适用于 Linux CentOS 发行版本,并且环境必须已支持 yum 、lsb_release 命令
|
# 要求:仅适用于 Linux CentOS 发行版本,并且环境必须已支持 yum 、lsb_release 命令
|
||||||
# @author: Zhang Peng
|
# @author: Zhang Peng
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
printf "${RESET}\n"
|
||||||
|
|
||||||
echo -e "\n>>>>>>>>> 替换 yum repo 源"
|
printf "\n${GREEN}>>>>>>>>> 替换 yum repo 源开始${RESET}\n"
|
||||||
|
|
||||||
# 备份
|
# 备份
|
||||||
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
|
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
|
||||||
@ -18,8 +31,6 @@ cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
|
|||||||
# version=`lsb_release -r | awk '{print substr($2,1,1)}'` # 很多机器没有 lsb_release 命令
|
# version=`lsb_release -r | awk '{print substr($2,1,1)}'` # 很多机器没有 lsb_release 命令
|
||||||
version=`cat /etc/redhat-release | awk '{print substr($4,1,1)}'`
|
version=`cat /etc/redhat-release | awk '{print substr($4,1,1)}'`
|
||||||
|
|
||||||
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
|
|
||||||
|
|
||||||
# 根据发型版本选择相应 yum 镜像
|
# 根据发型版本选择相应 yum 镜像
|
||||||
if [[ ${version} == 5 ]]; then
|
if [[ ${version} == 5 ]]; then
|
||||||
# Cento5 已废弃,只能使用 http://vault.CentOS.org/ 替换,但由于是国外镜像,速度较慢
|
# Cento5 已废弃,只能使用 http://vault.CentOS.org/ 替换,但由于是国外镜像,速度较慢
|
||||||
@ -36,11 +47,11 @@ elif [[ ${version} == 6 ]]; then
|
|||||||
elif [[ ${version} == 7 ]]; then
|
elif [[ ${version} == 7 ]]; then
|
||||||
wget -N https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/sys/yum/Centos-7.repo -O /etc/yum.repos.d/CentOS-Base.repo
|
wget -N https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/sys/yum/Centos-7.repo -O /etc/yum.repos.d/CentOS-Base.repo
|
||||||
else
|
else
|
||||||
echo -e "版本不支持,替换 yum repo 失败"
|
printf "\n${RED}版本不支持,替换 yum repo 失败${RESET}\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 更新缓存
|
# 更新缓存
|
||||||
yum clean all
|
yum clean all
|
||||||
yum makecache
|
yum makecache
|
||||||
|
|
||||||
echo -e "\n>>>>>>>>> 替换 yum repo 源成功"
|
printf "\n${GREEN}<<<<<<<< 替换 yum repo 源结束${RESET}\n"
|
||||||
|
@ -1,29 +1,45 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
# 控制台颜色
|
||||||
|
BLACK="\033[1;30m"
|
||||||
|
RED="\033[1;31m"
|
||||||
|
GREEN="\033[1;32m"
|
||||||
|
YELLOW="\033[1;33m"
|
||||||
|
BLUE="\033[1;34m"
|
||||||
|
PURPLE="\033[1;35m"
|
||||||
|
CYAN="\033[1;36m"
|
||||||
|
RESET="$(tput sgr0)"
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
printf "${BLUE}\n"
|
||||||
|
cat << EOF
|
||||||
###################################################################################
|
###################################################################################
|
||||||
# 安装常见 lib
|
# 安装常见 lib
|
||||||
# @author: Zhang Peng
|
# 如果不知道命令在哪个 lib,可以使用 yum search xxx 来查找
|
||||||
#
|
# lib 清单如下:
|
||||||
# 如果不知道某个命令工具是由哪个包提供的,使用 yum provides xxx
|
|
||||||
# 或 yum whatprovides xxx 来查找
|
|
||||||
###################################################################################
|
|
||||||
|
|
||||||
###################################################################################
|
|
||||||
# 执行本脚本后支持的 lib 清单:
|
|
||||||
# gcc gcc-c++ kernel-devel libtool
|
# gcc gcc-c++ kernel-devel libtool
|
||||||
# openssl openssl-devel
|
# openssl openssl-devel
|
||||||
# zlib zlib-devel
|
# zlib zlib-devel
|
||||||
# pcre
|
# pcre
|
||||||
|
#
|
||||||
|
# @author: Zhang Peng
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
EOF
|
||||||
|
printf "${RESET}\n"
|
||||||
|
|
||||||
echo -e "\n>>>>>>>>> install gcc gcc-c++ kernel-devel libtool"
|
printf "\n${GREEN}>>>>>>>>> 安装常见 lib 开始${RESET}\n"
|
||||||
|
|
||||||
|
printf "\n${CYAN}>>>> install gcc gcc-c++ kernel-devel libtool${RESET}\n"
|
||||||
yum -y install make gcc gcc-c++ kernel-devel libtool
|
yum -y install make gcc gcc-c++ kernel-devel libtool
|
||||||
|
|
||||||
echo -e "\n>>>>>>>>> install openssl openssl-devel"
|
printf "\n${CYAN}>>>> install openssl openssl-devel${RESET}\n"
|
||||||
yum -y install make openssl openssl-devel
|
yum -y install make openssl openssl-devel
|
||||||
|
|
||||||
echo -e "\n>>>>>>>>> install zlib zlib-devel"
|
printf "\n${CYAN}>>>> install zlib zlib-devel${RESET}\n"
|
||||||
yum -y install make zlib zlib-devel
|
yum -y install make zlib zlib-devel
|
||||||
|
|
||||||
echo -e "\n>>>>>>>>> install pcre"
|
printf "\n${CYAN}>>>> install pcre${RESET}\n"
|
||||||
yum -y install pcre
|
yum -y install pcre
|
||||||
|
|
||||||
|
printf "\n${GREEN}<<<<<<<< 安装常见 lib 结束${RESET}\n"
|
||||||
|
@ -1,19 +1,22 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
# 控制台颜色
|
||||||
|
BLACK="\033[1;30m"
|
||||||
|
RED="\033[1;31m"
|
||||||
|
GREEN="\033[1;32m"
|
||||||
|
YELLOW="\033[1;33m"
|
||||||
|
BLUE="\033[1;34m"
|
||||||
|
PURPLE="\033[1;35m"
|
||||||
|
CYAN="\033[1;36m"
|
||||||
|
RESET="$(tput sgr0)"
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
printf "${BLUE}\n"
|
||||||
cat << EOF
|
cat << EOF
|
||||||
###################################################################################
|
###################################################################################
|
||||||
# 安装基本的命令工具
|
# 安装常用命令工具
|
||||||
# @author: Zhang Peng
|
# 命令工具清单如下:
|
||||||
#
|
|
||||||
# 如果不知道某个命令工具是由哪个包提供的,使用 yum provides xxx
|
|
||||||
# 或 yum whatprovides xxx 来查找
|
|
||||||
###################################################################################
|
|
||||||
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat << EOF
|
|
||||||
###################################################################################
|
|
||||||
# 执行本脚本后支持的命令工具清单:
|
|
||||||
# 核心工具:df、du、chkconfig
|
# 核心工具:df、du、chkconfig
|
||||||
# 网络工具:ifconfig、netstat、route、iptables
|
# 网络工具:ifconfig、netstat、route、iptables
|
||||||
# IP工具:ip、ss、ping、tracepath、traceroute
|
# IP工具:ip、ss、ping、tracepath、traceroute
|
||||||
@ -25,72 +28,78 @@ cat << EOF
|
|||||||
# 抓包工具:tcpdump
|
# 抓包工具:tcpdump
|
||||||
# 压缩工具:unzip、zip
|
# 压缩工具:unzip、zip
|
||||||
# 版本控制工具:git、subversion
|
# 版本控制工具:git、subversion
|
||||||
|
#
|
||||||
|
# @author: Zhang Peng
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
printf "${RESET}\n"
|
||||||
|
|
||||||
|
printf "\n${GREEN}>>>>>>>>> 安装常用命令工具开始${RESET}\n"
|
||||||
|
|
||||||
# 核心工具
|
# 核心工具
|
||||||
echo -e "\n>>>>>>>>> install coreutils(df、du)"
|
printf "\n${CYAN}>>>> install coreutils(df、du)${RESET}\n"
|
||||||
yum install -y coreutils
|
yum install -y coreutils
|
||||||
echo -e "\n>>>>>>>>> install chkconfig"
|
printf "\n${CYAN}>>>> install chkconfig${RESET}\n"
|
||||||
yum install -y chkconfig
|
yum install -y chkconfig
|
||||||
|
|
||||||
# 网络工具
|
# 网络工具
|
||||||
echo -e "\n>>>>>>>>> install net-tools(ifconfig、netstat、route)"
|
printf "\n${CYAN}>>>> install net-tools(ifconfig、netstat、route)${RESET}\n"
|
||||||
yum install -y net-tools
|
yum install -y net-tools
|
||||||
echo -e "\n>>>>>>>>> install iptables"
|
printf "\n${CYAN}>>>> install iptables${RESET}\n"
|
||||||
yum install -y iptables
|
yum install -y iptables
|
||||||
|
|
||||||
# IP工具
|
# IP工具
|
||||||
echo -e "\n>>>>>>>>> install iputils(ping、tracepath)"
|
printf "\n${CYAN}>>>> install iputils(ping、tracepath)${RESET}\n"
|
||||||
yum install -y iputils
|
yum install -y iputils
|
||||||
echo -e "\n>>>>>>>>> install traceroute"
|
printf "\n${CYAN}>>>> install traceroute${RESET}\n"
|
||||||
yum install -y traceroute
|
yum install -y traceroute
|
||||||
echo -e "\n>>>>>>>>> install iproute(ip、ss)"
|
printf "\n${CYAN}>>>> install iproute(ip、ss)${RESET}\n"
|
||||||
yum install -y iproute
|
yum install -y iproute
|
||||||
|
|
||||||
# 端口工具
|
# 端口工具
|
||||||
echo -e "\n>>>>>>>>> install lsof"
|
printf "\n${CYAN}>>>> install lsof${RESET}\n"
|
||||||
yum install -y lsof
|
yum install -y lsof
|
||||||
echo -e "\n>>>>>>>>> install nc"
|
printf "\n${CYAN}>>>> install nc${RESET}\n"
|
||||||
yum install -y nc
|
yum install -y nc
|
||||||
echo -e "\n>>>>>>>>> install netstat"
|
printf "\n${CYAN}>>>> install netstat${RESET}\n"
|
||||||
yum install -y netstat
|
yum install -y netstat
|
||||||
|
|
||||||
# DNS工具
|
# DNS工具
|
||||||
echo -e "\n>>>>>>>>> install bind-utils(dig、host、nslookup)"
|
printf "\n${CYAN}>>>> install bind-utils(dig、host、nslookup)${RESET}\n"
|
||||||
yum install -y bind-utils
|
yum install -y bind-utils
|
||||||
echo -e "\n>>>>>>>>> install whois"
|
printf "\n${CYAN}>>>> install whois${RESET}\n"
|
||||||
yum install -y whois
|
yum install -y whois
|
||||||
|
|
||||||
# 下载工具
|
# 下载工具
|
||||||
echo -e "\n>>>>>>>>> install curl"
|
printf "\n${CYAN}>>>> install curl${RESET}\n"
|
||||||
yum install -y curl
|
yum install -y curl
|
||||||
echo -e "\n>>>>>>>>> install wget"
|
printf "\n${CYAN}>>>> install wget${RESET}\n"
|
||||||
yum install -y wget
|
yum install -y wget
|
||||||
|
|
||||||
# 编辑工具
|
# 编辑工具
|
||||||
echo -e "\n>>>>>>>>> install emacs"
|
printf "\n${CYAN}>>>> install emacs${RESET}\n"
|
||||||
yum install -y emacs
|
yum install -y emacs
|
||||||
echo -e "\n>>>>>>>>> install vim"
|
printf "\n${CYAN}>>>> install vim${RESET}\n"
|
||||||
yum install -y vim
|
yum install -y vim
|
||||||
|
|
||||||
# 流量工具
|
# 流量工具
|
||||||
echo -e "\n>>>>>>>>> install iftop"
|
printf "\n${CYAN}>>>> install iftop${RESET}\n"
|
||||||
yum install -y iftop
|
yum install -y iftop
|
||||||
echo -e "\n>>>>>>>>> install nethogs"
|
printf "\n${CYAN}>>>> install nethogs${RESET}\n"
|
||||||
yum install -y nethogs
|
yum install -y nethogs
|
||||||
|
|
||||||
# 抓包工具
|
# 抓包工具
|
||||||
echo -e "\n>>>>>>>>> install tcpdump"
|
printf "\n${CYAN}>>>> install tcpdump${RESET}\n"
|
||||||
yum install -y tcpdump
|
yum install -y tcpdump
|
||||||
|
|
||||||
# 压缩工具
|
# 压缩工具
|
||||||
echo -e "\n>>>>>>>>> install unzip"
|
printf "\n${CYAN}>>>> install unzip${RESET}\n"
|
||||||
yum install -y unzip
|
yum install -y unzip
|
||||||
|
|
||||||
# 版本控制工具
|
# 版本控制工具
|
||||||
echo -e "\n>>>>>>>>> install git"
|
printf "\n${CYAN}>>>> install git${RESET}\n"
|
||||||
yum install -y git
|
yum install -y git
|
||||||
echo -e "\n>>>>>>>>> install subversion"
|
printf "\n${CYAN}>>>> install subversion${RESET}\n"
|
||||||
yum install -y subversion
|
yum install -y subversion
|
||||||
|
|
||||||
|
printf "\n${GREEN}<<<<<<<< 安装常用命令工具结束${RESET}\n"
|
||||||
|
@ -1,32 +1,36 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
# 控制台颜色
|
||||||
|
BLACK="\033[1;30m"
|
||||||
|
RED="\033[1;31m"
|
||||||
|
GREEN="\033[1;32m"
|
||||||
|
YELLOW="\033[1;33m"
|
||||||
|
BLUE="\033[1;34m"
|
||||||
|
PURPLE="\033[1;35m"
|
||||||
|
CYAN="\033[1;36m"
|
||||||
|
RESET="$(tput sgr0)"
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
# 在 /etc/resolv.conf 中设置 DNS 服务器
|
# 在 /etc/resolv.conf 中配置 DNS 服务器
|
||||||
# 在 /etc/hosts 中设置本机域名
|
# 在 /etc/hosts 中配置本机域名
|
||||||
# @author: Zhang Peng
|
# @author: Zhang Peng
|
||||||
###################################################################################
|
###################################################################################
|
||||||
ip='127.0.0.1'
|
|
||||||
function getDeviceIp() {
|
|
||||||
ip=$(ip addr | awk '/^[0-9]+: / {}; /inet.*global/ {print gensub(/(.*)\/(.*)/, "\\1", "g", $2)}')
|
|
||||||
}
|
|
||||||
|
|
||||||
function setDNSServer() {
|
printf "\n${GREEN}>>>>>>>>> 配置 DNS 开始${RESET}\n"
|
||||||
echo -e "设置DNS服务器"
|
|
||||||
|
printf "\n${CYAN}>>>> 配置 DNS 解析服务器${RESET}\n"
|
||||||
cat >> /etc/resolv.conf << EOF
|
cat >> /etc/resolv.conf << EOF
|
||||||
nameserver 114.114.114.114
|
nameserver 114.114.114.114
|
||||||
nameserver 8.8.8.8
|
nameserver 8.8.8.8
|
||||||
EOF
|
EOF
|
||||||
}
|
|
||||||
|
|
||||||
function setHosts() {
|
printf "\n${CYAN}>>>> 配置本机域名和IP映射${RESET}\n"
|
||||||
getDeviceIp
|
ip=$(ip addr | awk '/^[0-9]+: / {}; /inet.*global/ {print gensub(/(.*)\/(.*)/, "\\1", "g", $2)}')
|
||||||
host=`hostname`
|
host=`hostname`
|
||||||
cat >> /etc/hosts << EOF
|
cat >> /etc/hosts << EOF
|
||||||
${ip} ${host}
|
${ip} ${host}
|
||||||
EOF
|
EOF
|
||||||
}
|
|
||||||
|
|
||||||
######################################## MAIN ########################################
|
printf "\n${GREEN}<<<<<<<< 配置 DNS 结束${RESET}\n"
|
||||||
echo -e "\n>>>>>>>>> 配置系统环境"
|
|
||||||
setDNSServer
|
|
||||||
setHosts
|
|
||||||
|
@ -1,28 +1,42 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
# 控制台颜色
|
||||||
|
BLACK="\033[1;30m"
|
||||||
|
RED="\033[1;31m"
|
||||||
|
GREEN="\033[1;32m"
|
||||||
|
YELLOW="\033[1;33m"
|
||||||
|
BLUE="\033[1;34m"
|
||||||
|
PURPLE="\033[1;35m"
|
||||||
|
CYAN="\033[1;36m"
|
||||||
|
RESET="$(tput sgr0)"
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
# 使用 NTP 进行时间同步
|
# 使用 NTP 进行时间同步
|
||||||
# 参考:https://www.cnblogs.com/quchunhui/p/7658853.html
|
# 参考:https://www.cnblogs.com/quchunhui/p/7658853.html
|
||||||
# @author: Zhang Peng
|
# @author: Zhang Peng
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
|
||||||
echo -e "\n>>>>>>>>> 设置 ntp"
|
printf "\n${GREEN}>>>>>>>>> 设置 NTP 开始${RESET}\n"
|
||||||
|
|
||||||
echo -e "先安装时钟同步工具 ntp"
|
printf "\n${CYAN}>>>> 安装 NTP 服务${RESET}\n"
|
||||||
yum -y install ntp
|
yum -y install ntp
|
||||||
|
|
||||||
ip=$(ip addr | awk '/^[0-9]+: / {}; /inet.*global/ {print gensub(/(.*)\/(.*)/, "\\1", "g", $2)}')
|
ip=$(ip addr | awk '/^[0-9]+: / {}; /inet.*global/ {print gensub(/(.*)\/(.*)/, "\\1", "g", $2)}')
|
||||||
/sbin/iptables -A INPUT -p UDP -i eth0 -s ${ip}/24 --dport 123 -j ACCEPT
|
/sbin/iptables -A INPUT -p UDP -i eth0 -s ${ip}/24 --dport 123 -j ACCEPT
|
||||||
|
|
||||||
echo -e "启动 NTP 服务"
|
printf "\n${CYAN}>>>> 启动 NTP 服务${RESET}\n"
|
||||||
systemctl start ntpd.service
|
systemctl start ntpd.service
|
||||||
|
|
||||||
echo -e "立即执行时间同步"
|
printf "\n${CYAN}>>>> 立即执行时间同步${RESET}\n"
|
||||||
/usr/sbin/ntpdate ntp.sjtu.edu.cn
|
/usr/sbin/ntpdate ntp.sjtu.edu.cn
|
||||||
|
|
||||||
echo -e "自动定时同步时间"
|
printf "\n${CYAN}>>>> 自动定时同步时间${RESET}\n"
|
||||||
echo "* 3 * * * /usr/sbin/ntpdate ntp.sjtu.edu.cn" >> /etc/crontab
|
echo "* 3 * * * /usr/sbin/ntpdate ntp.sjtu.edu.cn" >> /etc/crontab
|
||||||
systemctl restart crond.service
|
systemctl restart crond.service
|
||||||
|
|
||||||
echo -e "同步后系统时间:"
|
printf "\n${CYAN}>>>> 同步结束,当前系统时间:${RESET}\n"
|
||||||
date
|
date
|
||||||
|
|
||||||
|
printf "\n${GREEN}<<<<<<<< 设置 NTP 结束${RESET}\n"
|
||||||
|
@ -1,10 +1,23 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
# 控制台颜色
|
||||||
|
BLACK="\033[1;30m"
|
||||||
|
RED="\033[1;31m"
|
||||||
|
GREEN="\033[1;32m"
|
||||||
|
YELLOW="\033[1;33m"
|
||||||
|
BLUE="\033[1;34m"
|
||||||
|
PURPLE="\033[1;35m"
|
||||||
|
CYAN="\033[1;36m"
|
||||||
|
RESET="$(tput sgr0)"
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
# 彻底关闭防火墙
|
# 关闭防火墙
|
||||||
# 参考:https://www.cnblogs.com/moxiaoan/p/5683743.html
|
# 参考:https://www.cnblogs.com/moxiaoan/p/5683743.html
|
||||||
# @author: Zhang Peng
|
# @author: Zhang Peng
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
|
||||||
systemctl stop firewalld
|
systemctl stop firewalld
|
||||||
systemctl disable firewalld
|
systemctl disable firewalld
|
||||||
|
printf "\n${GREEN}<<<<<<<< 已关闭防火墙${RESET}\n"
|
||||||
|
@ -1,13 +1,26 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
# 控制台颜色
|
||||||
|
BLACK="\033[1;30m"
|
||||||
|
RED="\033[1;31m"
|
||||||
|
GREEN="\033[1;32m"
|
||||||
|
YELLOW="\033[1;33m"
|
||||||
|
BLUE="\033[1;34m"
|
||||||
|
PURPLE="\033[1;35m"
|
||||||
|
CYAN="\033[1;36m"
|
||||||
|
RESET="$(tput sgr0)"
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
printHeadInfo() {
|
printHeadInfo() {
|
||||||
|
printf "${BLUE}\n"
|
||||||
cat << EOF
|
cat << EOF
|
||||||
###################################################################################
|
###################################################################################
|
||||||
# Linux Centos7 系统配置脚本(根据需要选择)
|
# Linux Centos7 系统配置脚本(根据需要选择)
|
||||||
# @author: Zhang Peng
|
# @author: Zhang Peng
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
printf "${RESET}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
setLimit() {
|
setLimit() {
|
||||||
@ -24,14 +37,13 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
closeShutdownShortkey() {
|
closeShutdownShortkey() {
|
||||||
echo "关闭 Ctrl+Alt+Del 快捷键防止重新启动"
|
printf "\n${CYAN}>>>> 关闭 Ctrl+Alt+Del 快捷键防止重新启动${RESET}\n"
|
||||||
sed -i 's#exec /sbin/shutdown -r now#\#exec /sbin/shutdown -r now#' /etc/init/control-alt-delete.conf
|
sed -i 's#exec /sbin/shutdown -r now#\#exec /sbin/shutdown -r now#' /etc/init/control-alt-delete.conf
|
||||||
}
|
}
|
||||||
|
|
||||||
closeSelinux() {
|
closeSelinux() {
|
||||||
echo "关闭 selinux"
|
|
||||||
|
|
||||||
# see http://blog.51cto.com/13570193/2093299
|
# see http://blog.51cto.com/13570193/2093299
|
||||||
|
printf "\n${CYAN}>>>> 关闭 selinux${RESET}\n"
|
||||||
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
|
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,13 +55,13 @@ setBootMode() {
|
|||||||
# 5. 通常不用,在一些特殊情况下可以用它来做一些事情
|
# 5. 通常不用,在一些特殊情况下可以用它来做一些事情
|
||||||
# 6. X11,即进到 X-Window 系统
|
# 6. X11,即进到 X-Window 系统
|
||||||
# 7. 重新启动 (记得不要把 initdefault 配置为 6,因为这样会使 Linux 不断地重新启动)
|
# 7. 重新启动 (记得不要把 initdefault 配置为 6,因为这样会使 Linux 不断地重新启动)
|
||||||
echo "设置 Linux 启动模式"
|
printf "\n${CYAN}>>>> 配置 Linux 启动模式${RESET}\n"
|
||||||
sed -i 's/id:5:initdefault:/id:3:initdefault:/' /etc/inittab
|
sed -i 's/id:5:initdefault:/id:3:initdefault:/' /etc/inittab
|
||||||
}
|
}
|
||||||
|
|
||||||
# 配置 IPv4
|
# 配置 IPv4
|
||||||
configIpv4() {
|
configIpv4() {
|
||||||
echo "配置 ipv4"
|
printf "\n${CYAN}>>>> 配置 IPv4${RESET}\n"
|
||||||
|
|
||||||
cat >> /etc/sysctl.conf << EOF
|
cat >> /etc/sysctl.conf << EOF
|
||||||
net.ipv4.tcp_tw_reuse = 1
|
net.ipv4.tcp_tw_reuse = 1
|
||||||
@ -78,7 +90,7 @@ EOF
|
|||||||
|
|
||||||
# 关闭 IPv6
|
# 关闭 IPv6
|
||||||
closeIpv6() {
|
closeIpv6() {
|
||||||
echo "关闭 ipv6"
|
printf "\n${CYAN}>>>> 关闭 IPv6${RESET}\n"
|
||||||
|
|
||||||
cat > /etc/modprobe.d/ipv6.conf << EOF
|
cat > /etc/modprobe.d/ipv6.conf << EOF
|
||||||
alias net-pf-10 off
|
alias net-pf-10 off
|
||||||
@ -91,34 +103,29 @@ EOF
|
|||||||
# 入口函数
|
# 入口函数
|
||||||
main() {
|
main() {
|
||||||
PS3="请选择要执行的操作:"
|
PS3="请选择要执行的操作:"
|
||||||
select ITEM in "设置 DNS" "设置 NTP" "关闭防火墙" "配置 IPv4" "关闭 IPv6" "全部执行"
|
select ITEM in "配置 DNS" "配置 NTP" "关闭防火墙" "配置 IPv4" "关闭 IPv6" "全部执行"
|
||||||
do
|
do
|
||||||
|
|
||||||
case ${ITEM} in
|
case ${ITEM} in
|
||||||
"设置 DNS")
|
"配置 DNS")
|
||||||
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/sys/set-dns.sh | bash
|
sh ${root}/set-dns.sh ;;
|
||||||
;;
|
"配置 NTP")
|
||||||
"设置 NTP")
|
sh ${root}/set-ntp.sh ;;
|
||||||
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/sys/set-ntp.sh | bash
|
|
||||||
;;
|
|
||||||
"关闭防火墙")
|
"关闭防火墙")
|
||||||
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/sys/stop-firewall.sh | bash
|
sh ${root}/stop-firewall.sh ;;
|
||||||
;;
|
|
||||||
"配置 IPv4")
|
"配置 IPv4")
|
||||||
configIpv4
|
configIpv4 ;;
|
||||||
;;
|
|
||||||
"关闭 IPv6")
|
"关闭 IPv6")
|
||||||
closeIpv6
|
closeIpv6 ;;
|
||||||
;;
|
|
||||||
"全部执行")
|
"全部执行")
|
||||||
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/sys/set-dns.sh | bash
|
sh ${root}/set-dns.sh
|
||||||
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/sys/set-ntp.sh | bash
|
sh ${root}/set-ntp.sh
|
||||||
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/sys/stop-firewall.sh | bash
|
sh ${root}/stop-firewall.sh
|
||||||
configIpv4
|
configIpv4
|
||||||
closeIpv6
|
closeIpv6
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo -e "输入项不支持!"
|
printf "\n${RED}输入项不支持${RESET}\n"
|
||||||
main
|
main
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -127,8 +134,10 @@ main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
######################################## MAIN ########################################
|
######################################## MAIN ########################################
|
||||||
filepath=$(cd "$(dirname "$0")";
|
root=$(pwd)
|
||||||
pwd)
|
if [[ -n $1 ]]; then
|
||||||
|
root=$1
|
||||||
|
fi
|
||||||
|
|
||||||
printHeadInfo
|
printHeadInfo
|
||||||
main
|
main
|
||||||
|
Loading…
Reference in New Issue
Block a user