first commit
This commit is contained in:
commit
ba848e218d
1001 changed files with 152333 additions and 0 deletions
34
shell/tools/open-ports.sh
Normal file
34
shell/tools/open-ports.sh
Normal file
|
@ -0,0 +1,34 @@
|
|||
#!/bin/bash
|
||||
|
||||
## 开放端口
|
||||
# 未判断端口是否是数字
|
||||
# /usr/bin/firewall-cmd --zone=work --add-port=xx/tcp --permanent
|
||||
|
||||
if [ $# -eq 0 ];then
|
||||
echo -e "\033[32;1mUSGE:$0 [port]\033[0m"
|
||||
exit 1
|
||||
else
|
||||
while [ $# -gt 0 ]; do
|
||||
read -p "$1: TCP or UDP[default TCP]:" protocol
|
||||
: ${protocol:=tcp}
|
||||
case $protocol in
|
||||
tcp|TCP)
|
||||
protocol="tcp"
|
||||
;;
|
||||
udp|UDP)
|
||||
protocol="udp"
|
||||
;;
|
||||
*)
|
||||
echo -e "\033[31;1mCan not recognization the $protocol\033[0m"
|
||||
;;
|
||||
esac
|
||||
port=`/usr/bin/firewall-cmd --zone=work --list-port | grep -o $1/$protocol`
|
||||
if [[ -n $port ]];then
|
||||
echo -e "\033[31;1m$1/$protocol opened already! \033[0m"
|
||||
else
|
||||
/usr/bin/firewall-cmd --zone=work --add-port=$1/$protocol --permanent
|
||||
fi
|
||||
shift
|
||||
done
|
||||
/usr/bin/firewall-cmd --reload
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue