commit ea1c562f329a3023675cda9157d2312f52e9bac4 Author: wzj <244142824@qq.com> Date: Mon Nov 14 12:36:17 2022 +0800 first commit diff --git a/fwd.sh b/fwd.sh new file mode 100644 index 0000000..bbfea91 --- /dev/null +++ b/fwd.sh @@ -0,0 +1,143 @@ +#bin/bash +#version 1.5 +#date 2022年11月14日 +#################### +VERSION="1.5" + +if [ -z $3 ];then + : +else + echo "wrong grammer!" + exit +fi + + +if [ -z $1 ];then + echo -n "Useage: -a to ADD port or -r to REMOVE port or -l to LIST ports !" +fi + +if [ -z $2 ];then + : +else + if [ $2 -gt 0 ]&&[ $2 -lt 65535 ];then + PORT=$2 + else + echo "please use a correct port!" + fi +fi + +CheckPort (){ +if [ -z ${PORT} ];then + echo " you set no port!" + exit +fi +} +OpenTcp (){ + echo "adding..." + firewall-cmd --zone=public --add-port=${PORT}/tcp --permanent + echo "reloading..." + firewall-cmd --reload +} +OpenUdp (){ + echo "adding..." + firewall-cmd --zone=public --add-port=${PORT}/udp --permanent + echo "reloading..." + firewall-cmd --reload +} +CloseTcp (){ + echo "removinging..." + firewall-cmd --zone=public --remove-port=${PORT}/tcp --permanent + echo "reloading..." + firewall-cmd --reload +} +CloseUdp (){ + echo "removinging..." + firewall-cmd --zone=public --remove-port=${PORT}/udp --permanent + echo "reloading..." + firewall-cmd --reload +} +GetVersion (){ +LOCAL_VERSION=${VERSION} +REMOTE_VERSION=`curl -s https://mirror.liuyan.wang/shell/fwd.sh|grep "VERSION="|awk -F\" 'NR==1 {print $2}'` +} +Update (){ +GetVersion +if [ "${LOCAL_VERSION}" != "${REMOTE_VERSION}" ];then +wget -O /usr/bin/fwd https://mirror.liuyan.wang/shell/fwd.sh && chmod +x /usr/bin/fwd +exit +else +echo "already newest version" +exit +fi +} + +Help (){ +cat<