From cab35c7c28f5868b0f36a4de0015d15b48a8c9eb Mon Sep 17 00:00:00 2001 From: hiCasper Date: Fri, 9 Dec 2022 21:50:36 +0800 Subject: [PATCH] Fix iptables detection --- class/core/firewall_api.py | 12 ++++++------ scripts/install/alma.sh | 4 ++-- scripts/install/amazon.sh | 4 ++-- scripts/install/arch.sh | 4 ++-- scripts/install/centos.sh | 4 ++-- scripts/install/fedora.sh | 4 ++-- scripts/install/freebsd.sh | 4 ++-- scripts/install/opensuse.sh | 4 ++-- scripts/install/rocky.sh | 4 ++-- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/class/core/firewall_api.py b/class/core/firewall_api.py index b77010990..1b21e4451 100755 --- a/class/core/firewall_api.py +++ b/class/core/firewall_api.py @@ -352,8 +352,8 @@ class firewall_api: elif self.__isMac: pass else: - mw.execShell('/etc/init.d/iptables save') - mw.execShell('/etc/init.d/iptables stop') + mw.execShell('service iptables save') + mw.execShell('service iptables stop') else: if self.__isUfw: mw.execShell("echo 'y'| ufw enable") @@ -363,8 +363,8 @@ class firewall_api: elif self.__isMac: pass else: - mw.execShell('/etc/init.d/iptables save') - mw.execShell('/etc/init.d/iptables restart') + mw.execShell('service iptables save') + mw.execShell('service iptables restart') return mw.returnData(True, '设置成功!') @@ -437,8 +437,8 @@ class firewall_api: elif self.__isMac: pass else: - mw.execShell('/etc/init.d/iptables save') - mw.execShell('/etc/init.d/iptables restart') + mw.execShell('service iptables save') + mw.execShell('service iptables restart') def getFwStatus(self): if self.__isUfw: diff --git a/scripts/install/alma.sh b/scripts/install/alma.sh index f253817d0..d164588f5 100755 --- a/scripts/install/alma.sh +++ b/scripts/install/alma.sh @@ -20,7 +20,7 @@ if [ ! -d /root/.acme.sh ];then curl https://get.acme.sh | sh fi -if [ -f /etc/init.d/iptables ];then +if [ -f /usr/sbin/iptables ];then iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT @@ -41,7 +41,7 @@ if [ -f /etc/init.d/iptables ];then fi -if [ ! -f /etc/init.d/iptables ];then +if [ ! -f /usr/sbin/iptables ];then yum install firewalld -y systemctl enable firewalld systemctl start firewalld diff --git a/scripts/install/amazon.sh b/scripts/install/amazon.sh index 4be1e34b0..d6202acfd 100755 --- a/scripts/install/amazon.sh +++ b/scripts/install/amazon.sh @@ -28,7 +28,7 @@ if [ ! -d /root/.acme.sh ];then curl https://get.acme.sh | sh fi -if [ -f /etc/init.d/iptables ];then +if [ -f /usr/sbin/iptables ];then iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT @@ -49,7 +49,7 @@ if [ -f /etc/init.d/iptables ];then fi -if [ ! -f /etc/init.d/iptables ];then +if [ ! -f /usr/sbin/iptables ];then yum install firewalld -y systemctl enable firewalld #取消服务锁定 diff --git a/scripts/install/arch.sh b/scripts/install/arch.sh index f88564df1..2a4e36598 100644 --- a/scripts/install/arch.sh +++ b/scripts/install/arch.sh @@ -59,7 +59,7 @@ if [ ! -d /root/.acme.sh ];then curl https://get.acme.sh | sh fi -if [ -f /etc/init.d/iptables ];then +if [ -f /usr/sbin/iptables ];then iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT @@ -80,7 +80,7 @@ if [ -f /etc/init.d/iptables ];then fi -if [ ! -f /etc/init.d/iptables ];then +if [ ! -f /usr/sbin/iptables ];then echo y | pacman -Sy firewalld systemctl enable firewalld systemctl start firewalld diff --git a/scripts/install/centos.sh b/scripts/install/centos.sh index 3667e5967..02d988895 100755 --- a/scripts/install/centos.sh +++ b/scripts/install/centos.sh @@ -29,7 +29,7 @@ if [ ! -d /root/.acme.sh ];then curl https://get.acme.sh | sh fi -if [ -f /etc/init.d/iptables ];then +if [ -f /usr/sbin/iptables ];then iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT @@ -50,7 +50,7 @@ if [ -f /etc/init.d/iptables ];then fi -if [ ! -f /etc/init.d/iptables ];then +if [ ! -f /usr/sbin/iptables ];then yum install firewalld -y systemctl enable firewalld #取消服务锁定 diff --git a/scripts/install/fedora.sh b/scripts/install/fedora.sh index 5c32845d8..a7f8d4441 100644 --- a/scripts/install/fedora.sh +++ b/scripts/install/fedora.sh @@ -23,7 +23,7 @@ if [ ! -d /root/.acme.sh ];then curl https://get.acme.sh | sh fi -if [ -f /etc/init.d/iptables ];then +if [ -f /usr/sbin/iptables ];then iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT @@ -46,7 +46,7 @@ fi if [ "${isVersion}" == '' ];then - if [ ! -f "/etc/init.d/iptables" ];then + if [ ! -f "/usr/sbin/iptables" ];then yum install firewalld -y systemctl enable firewalld systemctl start firewalld diff --git a/scripts/install/freebsd.sh b/scripts/install/freebsd.sh index 896b1b450..51639b334 100644 --- a/scripts/install/freebsd.sh +++ b/scripts/install/freebsd.sh @@ -45,7 +45,7 @@ if [ ! -d /root/.acme.sh ];then curl https://get.acme.sh | sh fi -if [ -f /etc/init.d/iptables ];then +if [ -f /usr/sbin/iptables ];then iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT @@ -66,7 +66,7 @@ if [ -f /etc/init.d/iptables ];then fi -if [ ! -f /etc/init.d/iptables ];then +if [ ! -f /usr/sbin/iptables ];then pkg install -y firewalld systemctl enable firewalld systemctl start firewalld diff --git a/scripts/install/opensuse.sh b/scripts/install/opensuse.sh index 0834de39c..d537c5a9b 100644 --- a/scripts/install/opensuse.sh +++ b/scripts/install/opensuse.sh @@ -56,7 +56,7 @@ if [ ! -d /root/.acme.sh ];then curl https://get.acme.sh | sh fi -if [ -f /etc/init.d/iptables ];then +if [ -f /usr/sbin/iptables ];then iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT @@ -77,7 +77,7 @@ if [ -f /etc/init.d/iptables ];then fi -if [ ! -f /etc/init.d/iptables ];then +if [ ! -f /usr/sbin/iptables ];then zypper install -y firewalld systemctl enable firewalld systemctl start firewalld diff --git a/scripts/install/rocky.sh b/scripts/install/rocky.sh index 9d0183102..8e913e7cc 100644 --- a/scripts/install/rocky.sh +++ b/scripts/install/rocky.sh @@ -24,7 +24,7 @@ if [ ! -d /root/.acme.sh ];then curl https://get.acme.sh | sh fi -if [ -f /etc/init.d/iptables ];then +if [ -f /usr/sbin/iptables ];then iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT @@ -45,7 +45,7 @@ if [ -f /etc/init.d/iptables ];then fi -if [ ! -f /etc/init.d/iptables ];then +if [ ! -f /usr/sbin/iptables ];then yum install firewalld -y systemctl enable firewalld systemctl start firewalld