2018-02-23 15:42:53 +08:00
|
|
|
|
#!/usr/bin/env bash
|
2018-02-01 16:34:02 +08:00
|
|
|
|
|
2019-03-04 20:41:51 +08:00
|
|
|
|
# 打印头部信息
|
|
|
|
|
printHeadInfo() {
|
2018-02-01 16:34:02 +08:00
|
|
|
|
cat << EOF
|
2019-03-04 20:41:51 +08:00
|
|
|
|
|
2018-02-01 16:34:02 +08:00
|
|
|
|
***********************************************************************************
|
2019-03-04 20:41:51 +08:00
|
|
|
|
* 欢迎使用 Linux CentOS 环境运维脚本
|
2018-02-01 16:34:02 +08:00
|
|
|
|
* Author: Zhang Peng
|
|
|
|
|
***********************************************************************************
|
2019-03-04 20:41:51 +08:00
|
|
|
|
|
2018-02-01 16:34:02 +08:00
|
|
|
|
EOF
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-04 20:41:51 +08:00
|
|
|
|
# 打印尾部信息
|
|
|
|
|
printFootInfo() {
|
2018-02-01 16:34:02 +08:00
|
|
|
|
cat << EOF
|
2019-03-04 20:41:51 +08:00
|
|
|
|
|
2018-02-01 16:34:02 +08:00
|
|
|
|
***********************************************************************************
|
2019-03-04 20:41:51 +08:00
|
|
|
|
* 脚本执行结束,感谢使用!
|
2018-02-01 16:34:02 +08:00
|
|
|
|
***********************************************************************************
|
2019-03-04 20:41:51 +08:00
|
|
|
|
|
2018-02-01 16:34:02 +08:00
|
|
|
|
EOF
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-04 20:41:51 +08:00
|
|
|
|
# 检查操作系统环境
|
|
|
|
|
checkOsVersion(){
|
|
|
|
|
if(($1 == 1)); then
|
|
|
|
|
echo -e "检查操作系统环境是否兼容本套脚本"
|
|
|
|
|
|
2018-02-01 16:34:02 +08:00
|
|
|
|
platform=`uname -i`
|
2019-03-01 10:36:45 +08:00
|
|
|
|
if [[ ${platform} != "x86_64" ]]; then
|
2019-03-04 20:41:51 +08:00
|
|
|
|
echo "脚本仅支持 64 位操作系统!"
|
|
|
|
|
exit 1
|
2018-02-01 16:34:02 +08:00
|
|
|
|
fi
|
|
|
|
|
|
2019-03-04 20:41:51 +08:00
|
|
|
|
version=`cat /etc/redhat-release | awk '{print substr($4,1,1)}'`
|
|
|
|
|
if [[ ${version} != 7 ]]; then
|
|
|
|
|
echo "脚本仅支持 CentOS 7!"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2018-02-01 16:34:02 +08:00
|
|
|
|
|
2019-03-04 20:41:51 +08:00
|
|
|
|
echo -e "脚本可以在本环境运行!"
|
|
|
|
|
fi
|
2018-02-01 16:34:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-04 20:41:51 +08:00
|
|
|
|
# 入口函数
|
|
|
|
|
main() {
|
|
|
|
|
PS3="请选择要执行的脚本分类:"
|
|
|
|
|
select item in "配置系统" "安装服务"
|
|
|
|
|
do
|
|
|
|
|
case ${item} in
|
|
|
|
|
"配置系统")
|
|
|
|
|
${path}/sys/main.sh
|
|
|
|
|
;;
|
|
|
|
|
"安装服务")
|
|
|
|
|
${path}/service/main.sh
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
echo -e "输入项不支持!"
|
|
|
|
|
main
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
break
|
|
|
|
|
done
|
2018-02-01 16:34:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
######################################## MAIN ########################################
|
2019-03-04 20:41:51 +08:00
|
|
|
|
path=$(cd "$(dirname "$0")"; pwd)
|
|
|
|
|
|
2018-02-09 14:28:04 +08:00
|
|
|
|
printHeadInfo
|
2018-02-01 16:34:02 +08:00
|
|
|
|
checkOsVersion 0
|
2019-03-04 20:41:51 +08:00
|
|
|
|
main
|
2018-02-09 14:28:04 +08:00
|
|
|
|
printFootInfo
|