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
elif [[ "${release}" == "ubuntu" ]]; 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
elif [[ "${release}" == "fedora" ]]; 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
elif [[ "${release}" == "debian" ]]; then
if [[ ${os_version} -lt 10 ]]; then
echo -e "${red} Please use Debian 10 or higher ${plain}\n" && exit 1
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
echo "Your OS is ArchLinux"
elif [[ "${release}" == "manjaro" ]]; then
@ -95,12 +99,12 @@ confirm_restart() {
}
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
}
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
start
@ -119,7 +123,7 @@ update() {
fi
return 0
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
LOGI "Update is complete, Panel has automatically restarted "
exit 0
@ -353,7 +357,7 @@ enable_bbr() {
}
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
echo ""
LOGE "Failed to download script, Please check whether the machine can connect Github"
@ -548,11 +552,11 @@ install_acme() {
return 0
}
ssl_cert_issue_main() {
ssl_cert_issue_dev() {
echo -e "${green}\t1.${plain} Get SSL"
echo -e "${green}\t2.${plain} Revoke"
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
case "$choice" in
0)
@ -560,15 +564,15 @@ ssl_cert_issue_main() {
1)
ssl_cert_issue ;;
2)
local domain=""
read -p "Please enter your domain name to revoke the certificate: " domain
~/.acme.sh/acme.sh --revoke -d ${domain}
local dodev=""
read -p "Please enter your dodev name to revoke the certificate: " dodev
~/.acme.sh/acme.sh --revoke -d ${dodev}
LOGI "Certificate revoked"
;;
3)
local domain=""
read -p "Please enter your domain name to forcefully renew an SSL certificate: " domain
~/.acme.sh/acme.sh --renew -d ${domain} --force ;;
local dodev=""
read -p "Please enter your dodev name to forcefully renew an SSL certificate: " dodev
~/.acme.sh/acme.sh --renew -d ${dodev} --force ;;
*) echo "Invalid choice" ;;
esac
}
@ -602,24 +606,24 @@ ssl_cert_issue() {
LOGI "install socat succeed..."
fi
# get the domain here,and we need verify it
local domain=""
read -p "Please enter your domain name:" domain
LOGD "your domain is:${domain},check it..."
# get the dodev here,and we need verify it
local dodev=""
read -p "Please enter your dodev name:" dodev
LOGD "your dodev is:${dodev},check it..."
# here we need to judge whether there exists cert already
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)
LOGE "system already has certs here,can not issue again,current certs details:"
LOGI "$certInfo"
exit 1
else
LOGI "your domain is ready for issuing cert now..."
LOGI "your dodev is ready for issuing cert now..."
fi
# create a directory for install cert
certPath="/root/cert/${domain}"
certPath="/root/cert/${dodev}"
if [ ! -d "$certPath" ]; then
mkdir -p "$certPath"
else
@ -637,22 +641,22 @@ ssl_cert_issue() {
# NOTE:This should be handled by user
# open the port and kill the occupied progress
~/.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
LOGE "issue certs failed,please check logs"
rm -rf ~/.acme.sh/${domain}
rm -rf ~/.acme.sh/${dodev}
exit 1
else
LOGE "issue certs succeed,installing certs..."
fi
# install cert
~/.acme.sh/acme.sh --installcert -d ${domain} \
--key-file /root/cert/${domain}/privkey.pem \
--fullchain-file /root/cert/${domain}/fullchain.pem
~/.acme.sh/acme.sh --installcert -d ${dodev} \
--key-file /root/cert/${dodev}/privkey.pem \
--fullchain-file /root/cert/${dodev}/fullchain.pem
if [ $? -ne 0 ]; then
LOGE "install certs failed,exit"
rm -rf ~/.acme.sh/${domain}
rm -rf ~/.acme.sh/${dodev}
exit 1
else
LOGI "install certs succeed,enable auto renew..."
@ -677,7 +681,7 @@ ssl_cert_issue_CF() {
LOGI "This Acme script requires the following data:"
LOGI "1.Cloudflare Registered e-mail"
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 "
confirm "Confirmed?[y/n]" "y"
if [ $? -eq 0 ]; then
@ -690,7 +694,7 @@ ssl_cert_issue_CF() {
exit 1
fi
fi
CF_Domain=""
CF_Dodev=""
CF_GlobalKey=""
CF_AccountEmail=""
certPath=/root/cert
@ -700,9 +704,9 @@ ssl_cert_issue_CF() {
rm -rf $certPath
mkdir $certPath
fi
LOGD "Please set a domain name:"
read -p "Input your domain here:" CF_Domain
LOGD "Your domain name is set to:${CF_Domain}"
LOGD "Please set a dodev name:"
read -p "Input your dodev here:" CF_Dodev
LOGD "Your dodev name is set to:${CF_Dodev}"
LOGD "Please set the API key:"
read -p "Input your key here:" CF_GlobalKey
LOGD "Your API key is:${CF_GlobalKey}"
@ -716,15 +720,15 @@ ssl_cert_issue_CF() {
fi
export CF_Key="${CF_GlobalKey}"
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
LOGE "Certificate issuance failed, script exiting..."
exit 1
else
LOGI "Certificate issued Successfully, Installing..."
fi
~/.acme.sh/acme.sh --installcert -d ${CF_Domain} -d *.${CF_Domain} --ca-file /root/cert/ca.cer \
--cert-file /root/cert/${CF_Domain}.cer --key-file /root/cert/${CF_Domain}.key \
~/.acme.sh/acme.sh --installcert -d ${CF_Dodev} -d *.${CF_Dodev} --ca-file /root/cert/ca.cer \
--cert-file /root/cert/${CF_Dodev}.cer --key-file /root/cert/${CF_Dodev}.key \
--fullchain-file /root/cert/fullchain.cer
if [ $? -ne 0 ]; then
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}\t3.${plain} Turn on/off WireProxy"
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
case "$choice" in
0)
show_menu ;;
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)
warp a
@ -872,14 +876,14 @@ iplimit_remove_conflicts() {
done
}
iplimit_main() {
iplimit_dev() {
echo -e "\n${green}\t1.${plain} Install Fail2ban and configure IP Limit"
echo -e "${green}\t2.${plain} Change Ban Duration"
echo -e "${green}\t3.${plain} Unban Everyone"
echo -e "${green}\t4.${plain} Check Logs"
echo -e "${green}\t5.${plain} fail2ban status"
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
case "$choice" in
0)
@ -889,7 +893,7 @@ iplimit_main() {
if [[ $? == 0 ]]; then
install_iplimit
else
iplimit_main
iplimit_dev
fi ;;
2)
read -rp "Please enter new Ban Duration in Minutes [default 5]: " NUM
@ -899,17 +903,17 @@ iplimit_main() {
else
echo -e "${red}${NUM} is not a number! Please, try again.${plain}"
fi
iplimit_main ;;
iplimit_dev ;;
3)
confirm "Proceed with Unbanning everyone from IP Limit jail?" "y"
if [[ $? == 0 ]]; then
fail2ban-client reload --restart --unban 3x-ipl
echo -e "${green}All users Unbanned successfully.${plain}"
iplimit_main
iplimit_dev
else
echo -e "${yellow}Cancelled.${plain}"
fi
iplimit_main ;;
iplimit_dev ;;
4)
show_banlog
;;
@ -1005,7 +1009,7 @@ remove_iplimit(){
before_show_menu ;;
0)
echo -e "${yellow}Cancelled.${plain}\n"
iplimit_main ;;
iplimit_dev ;;
*)
echo -e "${red}Invalid option. Please select a valid number.${plain}\n"
remove_iplimit ;;
@ -1113,13 +1117,13 @@ show_menu() {
check_install && disable
;;
15)
ssl_cert_issue_main
ssl_cert_issue_dev
;;
16)
ssl_cert_issue_CF
;;
17)
iplimit_main
iplimit_dev
;;
18)
warp_cloudflare