標籤:shell
#!/bin/sh
cat(){
echo -e "${AA} ===================================== ${RES}"
echo -e "${DD} ======== 1.mysql function look ====== ${RES}"
echo -e "${FF} ======== 2.samba function look ====== ${RES}"
echo -e "${CC} ======== 3.postfix function look ==== ${RES}"
echo -e "${GG} ======== 4.or please exit ======= ${RES}"
echo -e "${EE} ===================================== ${RES}"
}
user1(){
echo -e "${AA} ===================================== ${RES}"
echo -e "${DD} ======== 1.look mysql process ======= ${RES}"
echo -e "${DD} ======== 2.look mysql port ======= ${RES}"
echo -e "${DD} ======== 3.install mysql ======= ${RES}"
echo -e "${DD} ======== 4.or please exit ======= ${RES}"
echo -e "${EE} ===================================== ${RES}"
}
user2(){
echo -e "${AA} ===================================== ${RES}"
echo -e "${FF} ======== 1.look samba process ======= ${RES}"
echo -e "${FF} ======== 2.look samba port ======= ${RES}"
echo -e "${FF} ======== 3.install samba ======= ${RES}"
echo -e "${FF} ======== 4.or please exit ======= ${RES}"
echo -e "${EE} ===================================== ${RES}"
}
user3 (){
echo -e "${AA} ===================================== ${RES}"
echo -e "${CC} ======== 1.look postfix process ===== ${RES}"
echo -e "${CC} ======== 2.look postfix port ===== ${RES}"
echo -e "${CC} ======== 3.install postfix ===== ${RES}"
echo -e "${CC} ======== 4.or please exit ===== ${RES}"
echo -e "${EE} ===================================== ${RES}"
}
PD1(){
user1
for (( i=1;i<=5;i++ ))
do
read -p "請輸入MYSQL功能序號: " a1
expr $a1 + 1 &>/dev/null
if [ $? -eq 0 ]&&(($a1<=4));then
break
else
s=5
tg1=$(( $s - $i ))
echo -e "${DD}你輸入的數值$a1不滿足以下條件!${RES}"
echo -e "${DD}請輸入 {1|2|3|4} 之中的數字!${RES}"
echo -e "${DD}您已輸入第$i次,還有$tg1次輸入的機會!${RES}"&& continue
fi
done
expr $a1 + 1 &>/dev/null
if [ $? -eq 0 ];then
if [ $a1 -eq 1 ]&&[ -n $a1 ];then
NAT1=$(ps -ef | grep "mysql" | grep -v "root" |wc -l)
expr $NAT1 + 0 &>/dev/null
if [ $? -eq 0 ];then
ps -ef | grep "mysql"
echo -e "${DD}查看MYSQL進程成功!${RES}"
else
echo -e "${DD}查看MYSQL進程失敗!${RES}"
echo -e "${DD}MYSQL服務沒開啟!${RES}"
fi
elif [ $a1 -eq 2 ]&&[ -n $a1 ];then
NAT11=$(netstat -tlun | grep "3306" |wc -l)
expr $NAT11 + 0 &>/dev/null
if [ $? -eq 0 ];then
/bin/netstat -tlun | grep "3306"
echo -e "${DD}查看 MYSQL 3306 連接埠成功!${RES}"
else
echo -e "${DD}查看 MYSQL 3306 連接埠失敗!${RES}"
echo -e "${DD}MYSQL 3306 服務沒開啟!${RES}"
fi
elif [ $a1 -eq 3 ]&&[ -n $a1 ];then
echo -e "${DD}不好意思,沒設MYSQL安裝功能!${RES}"
elif [ $a1 -eq 4 ]&&[ -n $a1 ];then
echo -e "${AA} =======已退出MYSQL功能菜單介面!=======${RES}"
exit
else
echo -e "${DD}您輸入的不是 {1|2|3|4} 數字!${RES}"
fi
else
echo -e "${DD}您輸入的不是 {1|2|3|4} 數字!${RES}"
fi
}
PD2(){
user2
for (( ii=1;ii<=5;ii++ ))
do
read -p "請輸入SAMBA功能序號: " a2
expr $a2 + 1 &>/dev/null
if [ $? -eq 0 ]&&(($a2<=4));then
break
else
s=5
tg2=$(( $s - $ii ))
echo -e "${FF}你輸入的數值$a1不滿足以下條件!${RES}"
echo -e "${FF}請輸入 {1|2|3|4} 之中的數字!${RES}"
echo -e "${FF}您已輸入第$ii次,還有$tg2次輸入的機會!${RES}"&& continue
fi
done
expr $a2 + 1 &>/dev/null
if [ $? -eq 0 ];then
if [ $a2 -eq 1 ]&&[ -n $a2 ];then
NAT11=$(ps -ef| grep "smb"| grep -v "grep"|wc -l)
NAT12=$(ps -ef| grep "nmb"| grep -v "grep"|wc -l)
expr $NAT11 + $NAT12 + 0 &>/dev/null
if [ $? -eq 0 ];then
/bin/ps -ef| grep "smb"| grep -v "grep"
/bin/ps -ef| grep "nmb"| grep -v "grep"
echo -e "${FF}查看SAMBA進程成功!${RES}"
else
echo -e "${FF}查看SAMBA進程失敗!${RES}"
echo -e "${FF}SAMBA服務沒開啟!${RES}"
fi
elif [ $a2 -eq 2 ]&&[ -n $a2 ];then
NAT21=$(netstat -tlun | grep "445"|grep "0.0.0.0"|wc -l)
NAT22=$(netstat -tlun | grep "139"|grep "0.0.0.0"|wc -l)
NAT23=$(netstat -tlun | grep "138"|grep "0.0.0.0"|wc -l)
NAT24=$(netstat -tlun | grep "137"|grep "0.0.0.0"|wc -l)
expr $NAT21 + $NAT22 + $NAT23 + $NAT24 + 0 &>/dev/null
if [ $? -eq 0 ];then
netstat -tlun | grep "445"|grep "0.0.0.0"
netstat -tlun | grep "139"|grep "0.0.0.0"
netstat -tlun | grep "138"|grep "0.0.0.0"
netstat -tlun | grep "137"|grep "0.0.0.0"
echo -e "${FF}查看"445" "139" "138" "137" 連接埠成功!${RES}"
else
echo -e "${FF}查看"445" "139" "138" "137" 連接埠失敗!${RES}"
echo -e "${FF}SAMBA服務沒開啟!${RES}"
fi
elif [ $a2 -eq 3 ]&&[ -n $a2 ];then
echo -e "${FF}不好意思,沒設SAMBA安裝功能!${RES}"
elif [ $a2 -eq 4 ]&&[ -n $a2 ];then
echo -e "${AA} =======已退出SAMBA功能菜單介面!=======${RES}"
exit
else
echo -e "${FF}您輸入的不是 {1|2|3|4} 數字!${RES}"
fi
else
echo -e "${FF}您輸入的不是 {1|2|3|4} 數字!${RES}"
fi
}
PD3(){
user3
for (( iii=1;iii<=5;iii++ ))
do
read -p "請輸入POSTFIX功能序號: " a3
expr $a3 + 1 &>/dev/null
if [ $? -eq 0 ]&&(($a3<=4));then
break
else
sss=5
tg3=$(( $sss - $iii ))
echo -e "${CC}你輸入的數值$a1不滿足以下條件!${RES}"
echo -e "${CC}請輸入 {1|2|3|4} 之中的數字!${RES}"
echo -e "${CC}您已輸入第$iii次,還有$tg3次輸入的機會!${RES}"&& continue
fi
done
expr $a3 + 1 &>/dev/null
if [ $? -eq 0 ];then
if [ $a3 -eq 1 ];then
NAT3=$(ps -ef | grep postfix | grep -v "grep" |wc -l)
expr $NAT3 + 0 &>/dev/null
if [ $? -eq 0 ];then
/bin/ps -ef | grep postfix | grep -v "grep"
echo -e "${CC}查看POSTFIX進程成功!${RES}"
else
echo -e "${CC}查看POSTFIX進程失敗!${RES}"
fi
elif [ $a3 -eq 2 ];then
NAT33=$(netstat -tlun | grep "25"| grep "tcp"|wc -l)
expr $NAT33 + 0 &>/dev/null
if [ $? -eq 0 ];then
netstat -tlun | grep "25"| grep "tcp"
echo -e "${CC}查看 POSTFIX 25 號端成功!${RES}"
else
echo -e "${CC}查看 POSTFIX 25 號連接埠失敗!${RES}"
echo -e "${CC}POSTFIX 服務沒開起!${RES}"
fi
elif [ $a3 -eq 3 ];then
echo -e "${CC}不好意思,沒設POSTFIX安裝功能!${RES}"
elif [ $a3 -eq 4 ];then
echo -e "${AA} ======已退出POSTFIX功能菜單介面!======${RES}"
exit
else
echo -e "${CC}您輸入的不是 {1|2|3|4} 數字!${RES}"
fi
else
echo -e "${CC}您輸入的不是 {1|2|3|4} 數字!${RES}"
fi
}
PD4(){
echo -e "${AA} ==========已退出功能菜單介面!=========${RES}"
exit
}
本文出自 “12177655” 部落格,謝絕轉載!
shell菜單架構