Fixed firewalld setting in CentOS 7
This commit is contained in:
parent
33beecbab2
commit
3831e2bf52
|
|
@ -10,14 +10,14 @@ export PATH
|
||||||
#==================================================================
|
#==================================================================
|
||||||
|
|
||||||
clear
|
clear
|
||||||
echo ""
|
echo
|
||||||
echo "#############################################################"
|
echo "#############################################################"
|
||||||
echo "# One click Install Shadowsocks-go server #"
|
echo "# One click Install Shadowsocks-go server #"
|
||||||
echo "# Intro: https://teddysun.com/392.html #"
|
echo "# Intro: https://teddysun.com/392.html #"
|
||||||
echo "# Author: Teddysun <i@teddysun.com> #"
|
echo "# Author: Teddysun <i@teddysun.com> #"
|
||||||
echo "# Thanks: @cyfdecyf <https://twitter.com/cyfdecyf> #"
|
echo "# Thanks: @cyfdecyf <https://twitter.com/cyfdecyf> #"
|
||||||
echo "#############################################################"
|
echo "#############################################################"
|
||||||
echo ""
|
echo
|
||||||
|
|
||||||
# Make sure only root can run our script
|
# Make sure only root can run our script
|
||||||
function rootness(){
|
function rootness(){
|
||||||
|
|
@ -68,7 +68,7 @@ function is_64bit(){
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Disable selinux
|
# Disable selinux
|
||||||
|
|
@ -85,11 +85,11 @@ function pre_install(){
|
||||||
echo "Please input password for shadowsocks-go:"
|
echo "Please input password for shadowsocks-go:"
|
||||||
read -p "(Default password: teddysun.com):" shadowsockspwd
|
read -p "(Default password: teddysun.com):" shadowsockspwd
|
||||||
[ -z "$shadowsockspwd" ] && shadowsockspwd="teddysun.com"
|
[ -z "$shadowsockspwd" ] && shadowsockspwd="teddysun.com"
|
||||||
echo ""
|
echo
|
||||||
echo "---------------------------"
|
echo "---------------------------"
|
||||||
echo "password = $shadowsockspwd"
|
echo "password = $shadowsockspwd"
|
||||||
echo "---------------------------"
|
echo "---------------------------"
|
||||||
echo ""
|
echo
|
||||||
# Set shadowsocks-go config port
|
# Set shadowsocks-go config port
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
|
|
@ -99,11 +99,11 @@ function pre_install(){
|
||||||
expr $shadowsocksport + 0 &>/dev/null
|
expr $shadowsocksport + 0 &>/dev/null
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
if [ $shadowsocksport -ge 1 ] && [ $shadowsocksport -le 65535 ]; then
|
if [ $shadowsocksport -ge 1 ] && [ $shadowsocksport -le 65535 ]; then
|
||||||
echo ""
|
echo
|
||||||
echo "---------------------------"
|
echo "---------------------------"
|
||||||
echo "port = $shadowsocksport"
|
echo "port = $shadowsocksport"
|
||||||
echo "---------------------------"
|
echo "---------------------------"
|
||||||
echo ""
|
echo
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
echo "Input error! Please input correct numbers."
|
echo "Input error! Please input correct numbers."
|
||||||
|
|
@ -121,7 +121,7 @@ function pre_install(){
|
||||||
stty echo
|
stty echo
|
||||||
stty $SAVEDSTTY
|
stty $SAVEDSTTY
|
||||||
}
|
}
|
||||||
echo ""
|
echo
|
||||||
echo "Press any key to start...or Press Ctrl+C to cancel"
|
echo "Press any key to start...or Press Ctrl+C to cancel"
|
||||||
char=`get_char`
|
char=`get_char`
|
||||||
#Install necessary dependencies
|
#Install necessary dependencies
|
||||||
|
|
@ -138,7 +138,7 @@ function pre_install(){
|
||||||
IP=$(curl -s -4 ipinfo.io/ip)
|
IP=$(curl -s -4 ipinfo.io/ip)
|
||||||
fi
|
fi
|
||||||
echo -e "Your main public IP is\t\033[32m$IP\033[0m"
|
echo -e "Your main public IP is\t\033[32m$IP\033[0m"
|
||||||
echo ""
|
echo
|
||||||
#Current folder
|
#Current folder
|
||||||
cur_dir=`pwd`
|
cur_dir=`pwd`
|
||||||
}
|
}
|
||||||
|
|
@ -205,23 +205,43 @@ function config_shadowsocks(){
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
# iptables set
|
# firewall set
|
||||||
function iptables_set(){
|
function firewall_set(){
|
||||||
echo "iptables start setting..."
|
echo "firewall set start..."
|
||||||
/sbin/service iptables status 1>/dev/null 2>&1
|
if centosversion 6; then
|
||||||
if [ $? -eq 0 ]; then
|
/etc/init.d/iptables status > /dev/null 2>&1
|
||||||
/sbin/iptables -L -n | grep '${shadowsocksport}' | grep 'ACCEPT' >/dev/null 2>&1
|
if [ $? -eq 0 ]; then
|
||||||
if [ $? -ne 0 ]; then
|
iptables -L -n | grep '${shadowsocksport}' | grep 'ACCEPT' > /dev/null 2>&1
|
||||||
/sbin/iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport ${shadowsocksport} -j ACCEPT
|
if [ $? -ne 0 ]; then
|
||||||
/sbin/iptables -I INPUT -m state --state NEW -m udp -p udp --dport ${shadowsocksport} -j ACCEPT
|
iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport ${shadowsocksport} -j ACCEPT
|
||||||
/etc/init.d/iptables save
|
iptables -I INPUT -m state --state NEW -m udp -p udp --dport ${shadowsocksport} -j ACCEPT
|
||||||
/etc/init.d/iptables restart
|
/etc/init.d/iptables save
|
||||||
|
/etc/init.d/iptables restart
|
||||||
|
else
|
||||||
|
echo "port ${shadowsocksport} has been set up."
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "port ${shadowsocksport} has been set up."
|
echo "WARNING: iptables looks like shutdown or not installed, please manually set it if necessary."
|
||||||
|
fi
|
||||||
|
elif centosversion 7; then
|
||||||
|
systemctl status firewalld > /dev/null 2>&1
|
||||||
|
if [ $? -eq 0 ];then
|
||||||
|
firewall-cmd --permanent --zone=public --add-port=${shadowsocksport}/tcp
|
||||||
|
firewall-cmd --permanent --zone=public --add-port=${shadowsocksport}/udp
|
||||||
|
firewall-cmd --reload
|
||||||
|
else
|
||||||
|
echo "Firewalld looks like not running, try to start..."
|
||||||
|
systemctl start firewalld
|
||||||
|
if [ $? -eq 0 ];then
|
||||||
|
firewall-cmd --permanent --zone=public --add-port=${shadowsocksport}/tcp
|
||||||
|
firewall-cmd --permanent --zone=public --add-port=${shadowsocksport}/udp
|
||||||
|
firewall-cmd --reload
|
||||||
|
else
|
||||||
|
echo "WARNING: Try to start firewalld failed. please enable port ${shadowsocksport} manually if necessary."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
echo "iptables looks like shutdown, please manually set it if necessary."
|
|
||||||
fi
|
fi
|
||||||
|
echo "firewall set completed..."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
|
|
@ -247,23 +267,23 @@ function install_go(){
|
||||||
echo "Shadowsocks-go start failure!"
|
echo "Shadowsocks-go start failure!"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo ""
|
echo
|
||||||
echo "shadowsocks-go install failed!"
|
echo "shadowsocks-go install failed!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
cd $cur_dir
|
cd $cur_dir
|
||||||
clear
|
clear
|
||||||
echo ""
|
echo
|
||||||
echo "Congratulations, shadowsocks-go install completed!"
|
echo "Congratulations, shadowsocks-go install completed!"
|
||||||
echo -e "Your Server IP: \033[41;37m ${IP} \033[0m"
|
echo -e "Your Server IP: \033[41;37m ${IP} \033[0m"
|
||||||
echo -e "Your Server Port: \033[41;37m ${shadowsocksport} \033[0m"
|
echo -e "Your Server Port: \033[41;37m ${shadowsocksport} \033[0m"
|
||||||
echo -e "Your Password: \033[41;37m ${shadowsockspwd} \033[0m"
|
echo -e "Your Password: \033[41;37m ${shadowsockspwd} \033[0m"
|
||||||
echo -e "Your Local Port: \033[41;37m 1080 \033[0m"
|
echo -e "Your Local Port: \033[41;37m 1080 \033[0m"
|
||||||
echo -e "Your Encryption Method: \033[41;37m aes-256-cfb \033[0m"
|
echo -e "Your Encryption Method: \033[41;37m aes-256-cfb \033[0m"
|
||||||
echo ""
|
echo
|
||||||
echo "Welcome to visit:https://teddysun.com/392.html"
|
echo "Welcome to visit:https://teddysun.com/392.html"
|
||||||
echo "Enjoy it!"
|
echo "Enjoy it!"
|
||||||
echo ""
|
echo
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -307,9 +327,7 @@ function install_shadowsocks_go(){
|
||||||
config_shadowsocks
|
config_shadowsocks
|
||||||
install_go
|
install_go
|
||||||
if [ "$OS" == 'CentOS' ]; then
|
if [ "$OS" == 'CentOS' ]; then
|
||||||
if centosversion 6; then
|
firewall_set
|
||||||
iptables_set
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -327,4 +345,4 @@ uninstall)
|
||||||
echo "Arguments error! [${action} ]"
|
echo "Arguments error! [${action} ]"
|
||||||
echo "Usage: `basename $0` {install|uninstall}"
|
echo "Usage: `basename $0` {install|uninstall}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user