@@ -42,7 +42,7 @@ if [[ "${release}" == "centos" ]]; then
4242 if [[ ${os_version} -lt 8 ]]; then
4343 echo -e " ${red} Please use CentOS 8 or higher ${plain} \n" && exit 1
4444 fi
45- elif [[ " ${release} " == " ubuntu" ]]; then
45+ elif [[ " ${release} " == " ubuntu" ]]; then
4646 if [[ ${os_version} -lt 20 ]]; then
4747 echo -e " ${red} please use Ubuntu 20 or higher version! ${plain} \n" && exit 1
4848 fi
@@ -432,8 +432,7 @@ show_xray_status() {
432432}
433433
434434open_ports () {
435- if ! command -v ufw & > /dev/null
436- then
435+ if ! command -v ufw & > /dev/null; then
437436 echo " ufw firewall is not installed. Installing now..."
438437 sudo apt-get update
439438 sudo apt-get install -y ufw
@@ -460,22 +459,23 @@ open_ports() {
460459
461460 # Check if the input is valid
462461 if ! [[ $ports =~ ^([0-9]+| [0-9]+-[0-9]+)(,([0-9]+| [0-9]+-[0-9]+))* $ ]]; then
463- echo " Error: Invalid input. Please enter a comma-separated list of ports or a range of ports (e.g. 80,443,2053 or 400-500)." >&2 ; exit 1
462+ echo " Error: Invalid input. Please enter a comma-separated list of ports or a range of ports (e.g. 80,443,2053 or 400-500)." >&2
463+ exit 1
464464 fi
465465
466466 # Open the specified ports using ufw
467- IFS=' ,' read -ra PORT_LIST <<< " $ports"
467+ IFS=' ,' read -ra PORT_LIST <<< " $ports"
468468 for port in " ${PORT_LIST[@]} " ; do
469469 if [[ $port == * -* ]]; then
470- # Split the range into start and end ports
471- start_port=$( echo $port | cut -d' -' -f1)
472- end_port=$( echo $port | cut -d' -' -f2)
473- # Loop through the range and open each port
474- for (( i= start_port; i<= end_port; i++ )) ; do
475- sudo ufw allow $i
476- done
470+ # Split the range into start and end ports
471+ start_port=$( echo $port | cut -d' -' -f1)
472+ end_port=$( echo $port | cut -d' -' -f2)
473+ # Loop through the range and open each port
474+ for (( i = start_port; i <= end_port; i++ )) ; do
475+ sudo ufw allow $i
476+ done
477477 else
478- sudo ufw allow " $port "
478+ sudo ufw allow " $port "
479479 fi
480480 done
481481
@@ -529,7 +529,7 @@ ssl_cert_issue() {
529529 fi
530530 fi
531531 # install socat second
532- if [[ " ${release} " == " centos" ]] || [[ " ${release} " == " fedora" ]] ; then
532+ if [[ " ${release} " == " centos" ]] || [[ " ${release} " == " fedora" ]]; then
533533 yum install socat -y
534534 else
535535 apt install socat -y
@@ -555,16 +555,16 @@ ssl_cert_issue() {
555555 else
556556 LOGI " your domain is ready for issuing cert now..."
557557 fi
558-
559- # create a directory for install cert
560- certPath=" /root/cert/${domain} "
561- if [ ! -d " $certPath " ]; then
562- mkdir -p " $certPath "
563- else
564- rm -rf " $certPath "
565- mkdir -p " $certPath "
566- fi
567-
558+
559+ # create a directory for install cert
560+ certPath=" /root/cert/${domain} "
561+ if [ ! -d " $certPath " ]; then
562+ mkdir -p " $certPath "
563+ else
564+ rm -rf " $certPath "
565+ mkdir -p " $certPath "
566+ fi
567+
568568 # get needed port here
569569 local WebPort=80
570570 read -p " please choose which port do you use,default will be 80 port:" WebPort
@@ -595,21 +595,20 @@ ssl_cert_issue() {
595595 else
596596 LOGI " install certs succeed,enable auto renew..."
597597 fi
598-
599- ~ /.acme.sh/acme.sh --upgrade --auto-upgrade
600- if [ $? -ne 0 ]; then
601- LOGE " auto renew failed, certs details:"
602- ls -lah cert/*
603- chmod 755 $certPath /*
604- exit 1
605- else
606- LOGI " auto renew succeed, certs details:"
607- ls -lah cert/*
608- chmod 755 $certPath /*
609- fi
610598
611- }
599+ ~ /.acme.sh/acme.sh --upgrade --auto-upgrade
600+ if [ $? -ne 0 ]; then
601+ LOGE " auto renew failed, certs details:"
602+ ls -lah cert/*
603+ chmod 755 $certPath /*
604+ exit 1
605+ else
606+ LOGI " auto renew succeed, certs details:"
607+ ls -lah cert/*
608+ chmod 755 $certPath /*
609+ fi
612610
611+ }
613612
614613warp_fixchatgpt () {
615614 curl -fsSL https://gist.githubusercontent.com/hamid-gh98/dc5dd9b0cc5b0412af927b1ccdb294c7/raw/install_warp_proxy.sh | bash
@@ -619,21 +618,21 @@ warp_fixchatgpt() {
619618
620619run_speedtest () {
621620 # Check if Speedtest is already installed
622- if ! command -v speedtest & > /dev/null; then
621+ if ! command -v speedtest & > /dev/null; then
623622 # If not installed, install it
624- if command -v dnf & > /dev/null; then
623+ if command -v dnf & > /dev/null; then
625624 sudo dnf install -y curl
626625 curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.rpm.sh | sudo bash
627626 sudo dnf install -y speedtest
628- elif command -v yum & > /dev/null; then
627+ elif command -v yum & > /dev/null; then
629628 sudo yum install -y curl
630629 curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.rpm.sh | sudo bash
631630 sudo yum install -y speedtest
632- elif command -v apt-get & > /dev/null; then
631+ elif command -v apt-get & > /dev/null; then
633632 sudo apt-get update && sudo apt-get install -y curl
634633 curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | sudo bash
635634 sudo apt-get install -y speedtest
636- elif command -v apt & > /dev/null; then
635+ elif command -v apt & > /dev/null; then
637636 sudo apt update && sudo apt install -y curl
638637 curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | sudo bash
639638 sudo apt install -y speedtest
@@ -647,8 +646,6 @@ run_speedtest() {
647646 speedtest
648647}
649648
650-
651-
652649show_usage () {
653650 echo " x-ui control menu usages: "
654651 echo " ------------------------------------------"
@@ -760,7 +757,7 @@ show_menu() {
760757 19)
761758 warp_fixchatgpt
762759 ;;
763- 20)
760+ 20)
764761 run_speedtest
765762 ;;
766763 * )
0 commit comments