更新 trojan.sh
This commit is contained in:
58
trojan.sh
58
trojan.sh
@@ -293,22 +293,8 @@ function preinstall_check(){
|
|||||||
systemctl stop nginx
|
systemctl stop nginx
|
||||||
fi
|
fi
|
||||||
$systemPackage -y install net-tools socat >/dev/null 2>&1
|
$systemPackage -y install net-tools socat >/dev/null 2>&1
|
||||||
Port80=`netstat -tlpn | awk -F '[: ]+' '$1=="tcp"{print $5}' | grep -w 80`
|
check_port 80
|
||||||
Port443=`netstat -tlpn | awk -F '[: ]+' '$1=="tcp"{print $5}' | grep -w 443`
|
check_port 443
|
||||||
if [ -n "$Port80" ]; then
|
|
||||||
process80=`netstat -tlpn | awk -F '[: ]+' '$5=="80"{print $9}'`
|
|
||||||
red "==========================================================="
|
|
||||||
red "检测到80端口被占用, 占用进程为: ${process80}, 本次安装结束"
|
|
||||||
red "==========================================================="
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ -n "$Port443" ]; then
|
|
||||||
process443=`netstat -tlpn | awk -F '[: ]+' '$5=="443"{print $9}'`
|
|
||||||
red "============================================================="
|
|
||||||
red "检测到443端口被占用, 占用进程为: ${process443}, 本次安装结束"
|
|
||||||
red "============================================================="
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ -f "/etc/selinux/config" ]; then
|
if [ -f "/etc/selinux/config" ]; then
|
||||||
CHECK=$(grep SELINUX= /etc/selinux/config | grep -v "#")
|
CHECK=$(grep SELINUX= /etc/selinux/config | grep -v "#")
|
||||||
if [ "$CHECK" == "SELINUX=enforcing" ]; then
|
if [ "$CHECK" == "SELINUX=enforcing" ]; then
|
||||||
@@ -410,25 +396,20 @@ function preinstall_check(){
|
|||||||
|
|
||||||
function repair_cert(){
|
function repair_cert(){
|
||||||
systemctl stop nginx
|
systemctl stop nginx
|
||||||
#iptables -I INPUT -p tcp --dport 80 -j ACCEPT
|
if [ $? -ne 0 ]; then
|
||||||
#iptables -I INPUT -p tcp --dport 443 -j ACCEPT
|
red "停止 nginx 失败,退出脚本"
|
||||||
Port80=`netstat -tlpn | awk -F '[: ]+' '$1=="tcp"{print $5}' | grep -w 80`
|
|
||||||
if [ -n "$Port80" ]; then
|
|
||||||
process80=`netstat -tlpn | awk -F '[: ]+' '$5=="80"{print $9}'`
|
|
||||||
red "==========================================================="
|
|
||||||
red "检测到80端口被占用, 占用进程为: ${process80}, 本次安装结束"
|
|
||||||
red "==========================================================="
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
check_port 80
|
||||||
green "============================"
|
green "============================"
|
||||||
blue "请输入绑定到本VPS的域名"
|
blue "请输入绑定到本VPS的域名"
|
||||||
blue "务必与之前失败使用的域名一致"
|
blue "务必与之前失败使用的域名一致"
|
||||||
green "============================"
|
green "============================"
|
||||||
read your_domain
|
read your_domain
|
||||||
if test -s /root/.acme.sh/${your_domain}_ecc/fullchain.cer; then
|
# if test -s /root/.acme.sh/${your_domain}_ecc/fullchain.cer; then
|
||||||
green "证书文件存在"
|
# green "证书文件存在"
|
||||||
exit 1
|
# exit 1
|
||||||
fi
|
# fi
|
||||||
real_addr=`ping ${your_domain} -c 1 | sed '1{s/[^(]*(//;s/).*//;q}'`
|
real_addr=`ping ${your_domain} -c 1 | sed '1{s/[^(]*(//;s/).*//;q}'`
|
||||||
local_addr=`curl ipv4.icanhazip.com`
|
local_addr=`curl ipv4.icanhazip.com`
|
||||||
if [ $real_addr == $local_addr ] ; then
|
if [ $real_addr == $local_addr ] ; then
|
||||||
@@ -496,6 +477,17 @@ function remove_trojan(){
|
|||||||
green "trojan删除完毕"
|
green "trojan删除完毕"
|
||||||
green "=============="
|
green "=============="
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function check_port() {
|
||||||
|
local port=$1
|
||||||
|
local port_process=`netstat -tlpn | awk -F '[: ]+' '$5=="'"$port"'" {print $9}'`
|
||||||
|
if [ -n "$port_process" ]; then
|
||||||
|
red "==========================================================="
|
||||||
|
red "检测到${port}端口被占用, 占用进程为: ${port_process}, 本次安装结束"
|
||||||
|
red "==========================================================="
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
function port_forward(){
|
function port_forward(){
|
||||||
iptables -t nat -A PREROUTING -p tcp --dport 49000:50000 -j REDIRECT --to-ports 443
|
iptables -t nat -A PREROUTING -p tcp --dport 49000:50000 -j REDIRECT --to-ports 443
|
||||||
green "=========================="
|
green "=========================="
|
||||||
@@ -537,7 +529,15 @@ function install_acme(){
|
|||||||
curl https://get.acme.sh | sh
|
curl https://get.acme.sh | sh
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function check_cert() {
|
||||||
|
local domain=$1
|
||||||
|
local cert_path="/root/.acme.sh/${domain}_ecc/fullchain.cer"
|
||||||
|
if [[ -s $cert_path ]]; then
|
||||||
|
green "证书文件存在"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
start_menu(){
|
start_menu(){
|
||||||
clear
|
clear
|
||||||
green " ======================================="
|
green " ======================================="
|
||||||
|
|||||||
Reference in New Issue
Block a user