[TOC]
# 包含提示和确认的菜单
```
function GetInstallService() {
echo "---------------------------------"
echo "Select which component you want to install in this machine, you can select mulit -"
echo "---------------------------------"
echo "1). ALL SERVICES"
echo "2). RTC TRAN PROBE"
echo "---------------------------------"
read -p "Please select the components to install this machine -->" stmp;
read -p "you input is $stmp are you sure to go? [yes|no]: -->" yn
if [[ $yn =~ ^[y|Y].* ]]; then
echo "Starting................................"
else
exit;
fi
for items in ${stmp[@]}
do
case $items in
1)
echo "you select install ALL SERVICES component. -->";
. ./install.sh 2>&1 | tee -a install.log
;;
2)
echo "you select install RTC TRAN PROBE component. -->";
. ./install_rtc.sh 2>&1 | tee -a install.log
;;
*)
echo "Error! you give wrong component, so exit";
exit 1;
;;
esac
done
}
GetInstallService
```
# 安装脚本配合位置参数
```
while getopts ":albri:" opt;
do
case $opt in
a)
InitAndCheckEnv
echo "+++++++++++++++++++++++++++++Install All Server+++++++++++++++++++++++++++++"
InstallAllServer
;;
l)
echo "Backup (-b)"
echo "Restore (-r)"
echo "IMServer (-i IM)"
echo "WebServer (-i Web)"
echo "DBServer (-i DB)"
echo "UpLoginServer (-i Login)"
;;
b)
backup_interactive
;;
r)
restore_interactive
;;
i)
InitAndCheckEnv
case ${OPTARG} in
"IM")
echo "Install IM Server"
InstallIMServer
;;
"Login")
echo "Install Login Server"
InstallLOGINServer
;;
"Web")
echo "Install Web Server"
InstallWebServer
;;
"DB")
echo "Install DB Server"
InstallDBServer
;;
*)
echo "+++++++++++++++++++++++++++++仅支持以下服务单独安装+++++++++++++++++++++++++++++++++++++"
echo "++++++++++++++++++++++++++++++++IM Web DB Login++++++++++++++++++++++++++++++++++++++++"
;;
esac
;;
\?)
echo "+++++++++++++++++++安装程序仅支持-a -b -r -l -i -h命令+++++++++++++++++++"
;;
esac
done
```
# $?结果返回值后续操作
> 单命令执行
```
if [ $? -eq 0 ]; then
echo "unzip web_common successed."
else
echo "Error: unzip web_common failed."
return 1
fi
```
> 多级命令执行结果
```
if [ $? -eq 0 ]; then
echo "unzip tb_server successed."
modify_tb_server
if [ $? -eq 0 ]; then
echo "modify tb_server successed."
else
echo "modify tb_server failed."
fi
else
echo "Error: unzip tb_server failed."
return 1
fi
```