菜单栏:
function menu1 {
clear
echo
echo -e "\t\033[43;31;1m 平台部署 \033[0m"
echo
echo -e "\t1. 配置manager节点IP地址"
echo
echo -e "\t2. 执行脚本"
echo
echo -e "\t3. 配置环境"
echo
echo -e "\t4. 配置操作系统参数"
echo
echo -e "\t5. 挂载硬盘"
echo
echo -e "\t6. 配置数据库"
echo
echo -e "\t7. 配置A"
echo
echo -e "\t8. 启动A"
echo
echo -e "\t9. 一键卸载"
echo
echo -e "\t0. Exit program\n\n"
echo
echo -en "\t输入选项(0-9):"
read -n 1 option1
}
普通函数:注意大括号与函数名之间的空格
function modifyManagerIP {
clear
echo "配置manager节点IP地址"
}
嵌套函数:注意函数调用函数的用法
function setExample {
function menu2 {
clear
echo
echo -e "\t1. 搭建##环境"
echo
echo -e "\t2. 启动##服务"
echo
echo -e "\t3. 关闭##服务"
echo
echo -e "\t0. 退出"
echo
echo -en "\t输入选项(0-3):"
read -n 1 option2
}
function makeA {
clear
echo "搭建##环境"
}
function startService {
clear
echo "启动##服务"
}
function stopService {
clear
echo "关闭##服务"
}
while [ 1 ]
do
menu2
case $option2 in
0)
break;;
1)
makeA;;
2)
startService;;
3)
stopService;;
*)
clear
echo "Sorry, wrong selection";;
esac
echo -en "\n\n\t\t\033[42;37m press any key to continue \033[0m"
read -n 1 line2
done
clear
}
函数入口:注意while后面中括号和数字之间的空格
while [ 1 ]
do
menu1
case $option1 in
0)
break;;
1)
modifyManagerIP;;
2)
installpy;;
3)
setA;;
4)
setOSParameter;;
5)
mountS;;
6)
setDB;;
7)
setB;;
8)
startB;;
9)
uninstall;;
*)
clear
echo "Sorry, wrong selection";;
esac
echo -en "\n\n\t\t\033[42;37m press any key to continue \033[0m"
read -n 1 line1
done
clear
echo颜色设置:
30黑色字
31红色字
32绿色字
33黄色字
34蓝色字
35 紫色字
36天蓝字
37白色字
40黑底
41红底
42 绿底
43 黄底
44蓝底
45 紫底
46 天蓝
47 白底
网友评论