Update x-ui.sh

This commit is contained in:
quydang 2023-12-23 07:59:14 +07:00 committed by GitHub
parent af28a2f796
commit f13948fdc5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

96
x-ui.sh
View file

@ -44,16 +44,20 @@ if [[ "${release}" == "centos" ]]; then
fi fi
elif [[ "${release}" == "ubuntu" ]]; then elif [[ "${release}" == "ubuntu" ]]; then
if [[ ${os_version} -lt 20 ]]; then if [[ ${os_version} -lt 20 ]]; then
echo -e "${red}please use Ubuntu 20 or higher version! ${plain}\n" && exit 1 echo -e "${red} Please use Ubuntu 20 or higher version! ${plain}\n" && exit 1
fi fi
elif [[ "${release}" == "fedora" ]]; then elif [[ "${release}" == "fedora" ]]; then
if [[ ${os_version} -lt 36 ]]; then if [[ ${os_version} -lt 36 ]]; then
echo -e "${red}please use Fedora 36 or higher version! ${plain}\n" && exit 1 echo -e "${red} Please use Fedora 36 or higher version! ${plain}\n" && exit 1
fi fi
elif [[ "${release}" == "debian" ]]; then elif [[ "${release}" == "debian" ]]; then
if [[ ${os_version} -lt 10 ]]; then if [[ ${os_version} -lt 10 ]]; then
echo -e "${red} Please use Debian 10 or higher ${plain}\n" && exit 1 echo -e "${red} Please use Debian 10 or higher ${plain}\n" && exit 1
fi fi
elif [[ "${release}" == "almalinux" ]]; then
if [[ ${os_version} -lt 9 ]]; then
echo -e "${red} Please use Almalinux 9 or higher ${plain}\n" && exit 1
fi
elif [[ "${release}" == "arch" ]]; then elif [[ "${release}" == "arch" ]]; then
echo "Your OS is ArchLinux" echo "Your OS is ArchLinux"
elif [[ "${release}" == "manjaro" ]]; then elif [[ "${release}" == "manjaro" ]]; then
@ -95,12 +99,12 @@ confirm_restart() {
} }
before_show_menu() { before_show_menu() {
echo && echo -n -e "${yellow}Press enter to return to the main menu: ${plain}" && read temp echo && echo -n -e "${yellow}Press enter to return to the dev menu: ${plain}" && read temp
show_menu show_menu
} }
install() { install() {
bash <(curl -Ls https://raw.githubusercontent.com/MHSanaei/3x-ui/main/install.sh) bash <(curl -Ls https://raw.githubusercontent.com/quydang04/3x-ui/dev/install.sh)
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
start start
@ -119,7 +123,7 @@ update() {
fi fi
return 0 return 0
fi fi
bash <(curl -Ls https://raw.githubusercontent.com/MHSanaei/3x-ui/main/install.sh) bash <(curl -Ls https://raw.githubusercontent.com/quydang04/3x-ui/dev/install.sh)
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then
LOGI "Update is complete, Panel has automatically restarted " LOGI "Update is complete, Panel has automatically restarted "
exit 0 exit 0
@ -353,7 +357,7 @@ enable_bbr() {
} }
update_shell() { update_shell() {
wget -O /usr/bin/x-ui -N --no-check-certificate https://github.com/MHSanaei/3x-ui/raw/main/x-ui.sh wget -O /usr/bin/x-ui -N --no-check-certificate https://github.com/quydang04/3x-ui/raw/dev/x-ui.sh
if [[ $? != 0 ]]; then if [[ $? != 0 ]]; then
echo "" echo ""
LOGE "Failed to download script, Please check whether the machine can connect Github" LOGE "Failed to download script, Please check whether the machine can connect Github"
@ -548,11 +552,11 @@ install_acme() {
return 0 return 0
} }
ssl_cert_issue_main() { ssl_cert_issue_dev() {
echo -e "${green}\t1.${plain} Get SSL" echo -e "${green}\t1.${plain} Get SSL"
echo -e "${green}\t2.${plain} Revoke" echo -e "${green}\t2.${plain} Revoke"
echo -e "${green}\t3.${plain} Force Renew" echo -e "${green}\t3.${plain} Force Renew"
echo -e "${green}\t0.${plain} Back to Main Menu" echo -e "${green}\t0.${plain} Back to dev Menu"
read -p "Choose an option: " choice read -p "Choose an option: " choice
case "$choice" in case "$choice" in
0) 0)
@ -560,15 +564,15 @@ ssl_cert_issue_main() {
1) 1)
ssl_cert_issue ;; ssl_cert_issue ;;
2) 2)
local domain="" local dodev=""
read -p "Please enter your domain name to revoke the certificate: " domain read -p "Please enter your dodev name to revoke the certificate: " dodev
~/.acme.sh/acme.sh --revoke -d ${domain} ~/.acme.sh/acme.sh --revoke -d ${dodev}
LOGI "Certificate revoked" LOGI "Certificate revoked"
;; ;;
3) 3)
local domain="" local dodev=""
read -p "Please enter your domain name to forcefully renew an SSL certificate: " domain read -p "Please enter your dodev name to forcefully renew an SSL certificate: " dodev
~/.acme.sh/acme.sh --renew -d ${domain} --force ;; ~/.acme.sh/acme.sh --renew -d ${dodev} --force ;;
*) echo "Invalid choice" ;; *) echo "Invalid choice" ;;
esac esac
} }
@ -602,24 +606,24 @@ ssl_cert_issue() {
LOGI "install socat succeed..." LOGI "install socat succeed..."
fi fi
# get the domain here,and we need verify it # get the dodev here,and we need verify it
local domain="" local dodev=""
read -p "Please enter your domain name:" domain read -p "Please enter your dodev name:" dodev
LOGD "your domain is:${domain},check it..." LOGD "your dodev is:${dodev},check it..."
# here we need to judge whether there exists cert already # here we need to judge whether there exists cert already
local currentCert=$(~/.acme.sh/acme.sh --list | tail -1 | awk '{print $1}') local currentCert=$(~/.acme.sh/acme.sh --list | tail -1 | awk '{print $1}')
if [ ${currentCert} == ${domain} ]; then if [ ${currentCert} == ${dodev} ]; then
local certInfo=$(~/.acme.sh/acme.sh --list) local certInfo=$(~/.acme.sh/acme.sh --list)
LOGE "system already has certs here,can not issue again,current certs details:" LOGE "system already has certs here,can not issue again,current certs details:"
LOGI "$certInfo" LOGI "$certInfo"
exit 1 exit 1
else else
LOGI "your domain is ready for issuing cert now..." LOGI "your dodev is ready for issuing cert now..."
fi fi
# create a directory for install cert # create a directory for install cert
certPath="/root/cert/${domain}" certPath="/root/cert/${dodev}"
if [ ! -d "$certPath" ]; then if [ ! -d "$certPath" ]; then
mkdir -p "$certPath" mkdir -p "$certPath"
else else
@ -637,22 +641,22 @@ ssl_cert_issue() {
# NOTE:This should be handled by user # NOTE:This should be handled by user
# open the port and kill the occupied progress # open the port and kill the occupied progress
~/.acme.sh/acme.sh --set-default-ca --server letsencrypt ~/.acme.sh/acme.sh --set-default-ca --server letsencrypt
~/.acme.sh/acme.sh --issue -d ${domain} --standalone --httpport ${WebPort} ~/.acme.sh/acme.sh --issue -d ${dodev} --standalone --httpport ${WebPort}
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
LOGE "issue certs failed,please check logs" LOGE "issue certs failed,please check logs"
rm -rf ~/.acme.sh/${domain} rm -rf ~/.acme.sh/${dodev}
exit 1 exit 1
else else
LOGE "issue certs succeed,installing certs..." LOGE "issue certs succeed,installing certs..."
fi fi
# install cert # install cert
~/.acme.sh/acme.sh --installcert -d ${domain} \ ~/.acme.sh/acme.sh --installcert -d ${dodev} \
--key-file /root/cert/${domain}/privkey.pem \ --key-file /root/cert/${dodev}/privkey.pem \
--fullchain-file /root/cert/${domain}/fullchain.pem --fullchain-file /root/cert/${dodev}/fullchain.pem
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
LOGE "install certs failed,exit" LOGE "install certs failed,exit"
rm -rf ~/.acme.sh/${domain} rm -rf ~/.acme.sh/${dodev}
exit 1 exit 1
else else
LOGI "install certs succeed,enable auto renew..." LOGI "install certs succeed,enable auto renew..."
@ -677,7 +681,7 @@ ssl_cert_issue_CF() {
LOGI "This Acme script requires the following data:" LOGI "This Acme script requires the following data:"
LOGI "1.Cloudflare Registered e-mail" LOGI "1.Cloudflare Registered e-mail"
LOGI "2.Cloudflare Global API Key" LOGI "2.Cloudflare Global API Key"
LOGI "3.The domain name that has been resolved dns to the current server by Cloudflare" LOGI "3.The dodev name that has been resolved dns to the current server by Cloudflare"
LOGI "4.The script applies for a certificate. The default installation path is /root/cert " LOGI "4.The script applies for a certificate. The default installation path is /root/cert "
confirm "Confirmed?[y/n]" "y" confirm "Confirmed?[y/n]" "y"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
@ -690,7 +694,7 @@ ssl_cert_issue_CF() {
exit 1 exit 1
fi fi
fi fi
CF_Domain="" CF_Dodev=""
CF_GlobalKey="" CF_GlobalKey=""
CF_AccountEmail="" CF_AccountEmail=""
certPath=/root/cert certPath=/root/cert
@ -700,9 +704,9 @@ ssl_cert_issue_CF() {
rm -rf $certPath rm -rf $certPath
mkdir $certPath mkdir $certPath
fi fi
LOGD "Please set a domain name:" LOGD "Please set a dodev name:"
read -p "Input your domain here:" CF_Domain read -p "Input your dodev here:" CF_Dodev
LOGD "Your domain name is set to:${CF_Domain}" LOGD "Your dodev name is set to:${CF_Dodev}"
LOGD "Please set the API key:" LOGD "Please set the API key:"
read -p "Input your key here:" CF_GlobalKey read -p "Input your key here:" CF_GlobalKey
LOGD "Your API key is:${CF_GlobalKey}" LOGD "Your API key is:${CF_GlobalKey}"
@ -716,15 +720,15 @@ ssl_cert_issue_CF() {
fi fi
export CF_Key="${CF_GlobalKey}" export CF_Key="${CF_GlobalKey}"
export CF_Email=${CF_AccountEmail} export CF_Email=${CF_AccountEmail}
~/.acme.sh/acme.sh --issue --dns dns_cf -d ${CF_Domain} -d *.${CF_Domain} --log ~/.acme.sh/acme.sh --issue --dns dns_cf -d ${CF_Dodev} -d *.${CF_Dodev} --log
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
LOGE "Certificate issuance failed, script exiting..." LOGE "Certificate issuance failed, script exiting..."
exit 1 exit 1
else else
LOGI "Certificate issued Successfully, Installing..." LOGI "Certificate issued Successfully, Installing..."
fi fi
~/.acme.sh/acme.sh --installcert -d ${CF_Domain} -d *.${CF_Domain} --ca-file /root/cert/ca.cer \ ~/.acme.sh/acme.sh --installcert -d ${CF_Dodev} -d *.${CF_Dodev} --ca-file /root/cert/ca.cer \
--cert-file /root/cert/${CF_Domain}.cer --key-file /root/cert/${CF_Domain}.key \ --cert-file /root/cert/${CF_Dodev}.cer --key-file /root/cert/${CF_Dodev}.key \
--fullchain-file /root/cert/fullchain.cer --fullchain-file /root/cert/fullchain.cer
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
LOGE "Certificate installation failed, script exiting..." LOGE "Certificate installation failed, script exiting..."
@ -753,13 +757,13 @@ warp_cloudflare() {
echo -e "${green}\t2.${plain} Account Type (free, plus, team)" echo -e "${green}\t2.${plain} Account Type (free, plus, team)"
echo -e "${green}\t3.${plain} Turn on/off WireProxy" echo -e "${green}\t3.${plain} Turn on/off WireProxy"
echo -e "${green}\t4.${plain} Uninstall WARP" echo -e "${green}\t4.${plain} Uninstall WARP"
echo -e "${green}\t0.${plain} Back to Main Menu" echo -e "${green}\t0.${plain} Back to dev Menu"
read -p "Choose an option: " choice read -p "Choose an option: " choice
case "$choice" in case "$choice" in
0) 0)
show_menu ;; show_menu ;;
1) 1)
bash <(curl -sSL https://raw.githubusercontent.com/hamid-gh98/x-ui-scripts/main/install_warp_proxy.sh) bash <(curl -sSL https://raw.githubusercontent.com/hamid-gh98/x-ui-scripts/dev/install_warp_proxy.sh)
;; ;;
2) 2)
warp a warp a
@ -872,14 +876,14 @@ iplimit_remove_conflicts() {
done done
} }
iplimit_main() { iplimit_dev() {
echo -e "\n${green}\t1.${plain} Install Fail2ban and configure IP Limit" echo -e "\n${green}\t1.${plain} Install Fail2ban and configure IP Limit"
echo -e "${green}\t2.${plain} Change Ban Duration" echo -e "${green}\t2.${plain} Change Ban Duration"
echo -e "${green}\t3.${plain} Unban Everyone" echo -e "${green}\t3.${plain} Unban Everyone"
echo -e "${green}\t4.${plain} Check Logs" echo -e "${green}\t4.${plain} Check Logs"
echo -e "${green}\t5.${plain} fail2ban status" echo -e "${green}\t5.${plain} fail2ban status"
echo -e "${green}\t6.${plain} Uninstall IP Limit" echo -e "${green}\t6.${plain} Uninstall IP Limit"
echo -e "${green}\t0.${plain} Back to Main Menu" echo -e "${green}\t0.${plain} Back to dev Menu"
read -p "Choose an option: " choice read -p "Choose an option: " choice
case "$choice" in case "$choice" in
0) 0)
@ -889,7 +893,7 @@ iplimit_main() {
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then
install_iplimit install_iplimit
else else
iplimit_main iplimit_dev
fi ;; fi ;;
2) 2)
read -rp "Please enter new Ban Duration in Minutes [default 5]: " NUM read -rp "Please enter new Ban Duration in Minutes [default 5]: " NUM
@ -899,17 +903,17 @@ iplimit_main() {
else else
echo -e "${red}${NUM} is not a number! Please, try again.${plain}" echo -e "${red}${NUM} is not a number! Please, try again.${plain}"
fi fi
iplimit_main ;; iplimit_dev ;;
3) 3)
confirm "Proceed with Unbanning everyone from IP Limit jail?" "y" confirm "Proceed with Unbanning everyone from IP Limit jail?" "y"
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then
fail2ban-client reload --restart --unban 3x-ipl fail2ban-client reload --restart --unban 3x-ipl
echo -e "${green}All users Unbanned successfully.${plain}" echo -e "${green}All users Unbanned successfully.${plain}"
iplimit_main iplimit_dev
else else
echo -e "${yellow}Cancelled.${plain}" echo -e "${yellow}Cancelled.${plain}"
fi fi
iplimit_main ;; iplimit_dev ;;
4) 4)
show_banlog show_banlog
;; ;;
@ -1005,7 +1009,7 @@ remove_iplimit(){
before_show_menu ;; before_show_menu ;;
0) 0)
echo -e "${yellow}Cancelled.${plain}\n" echo -e "${yellow}Cancelled.${plain}\n"
iplimit_main ;; iplimit_dev ;;
*) *)
echo -e "${red}Invalid option. Please select a valid number.${plain}\n" echo -e "${red}Invalid option. Please select a valid number.${plain}\n"
remove_iplimit ;; remove_iplimit ;;
@ -1113,13 +1117,13 @@ show_menu() {
check_install && disable check_install && disable
;; ;;
15) 15)
ssl_cert_issue_main ssl_cert_issue_dev
;; ;;
16) 16)
ssl_cert_issue_CF ssl_cert_issue_CF
;; ;;
17) 17)
iplimit_main iplimit_dev
;; ;;
18) 18)
warp_cloudflare warp_cloudflare