From 04ae67929466508674431a95e689f435fefad373 Mon Sep 17 00:00:00 2001 From: Sarina Date: Sun, 21 Jul 2024 18:46:02 +0330 Subject: [PATCH] Lil refactor --- core/scripts/hysteria2/install.sh | 10 ++-------- core/scripts/utils.sh | 10 ++++++++++ menu.sh | 18 +++++------------- 3 files changed, 17 insertions(+), 21 deletions(-) create mode 100644 core/scripts/utils.sh diff --git a/core/scripts/hysteria2/install.sh b/core/scripts/hysteria2/install.sh index 0a46aa2..ae54d23 100644 --- a/core/scripts/hysteria2/install.sh +++ b/core/scripts/hysteria2/install.sh @@ -1,13 +1,7 @@ #!/bin/bash -define_colors() { - green='\033[0;32m' - cyan='\033[0;36m' - red='\033[0;31m' - yellow='\033[0;33m' - LPurple='\033[1;35m' - NC='\033[0m' -} +source /etc/hysteria/core/scripts/utils.sh +define_colors install_hysteria() { # Step 1: Install Hysteria2 diff --git a/core/scripts/utils.sh b/core/scripts/utils.sh new file mode 100644 index 0000000..799109b --- /dev/null +++ b/core/scripts/utils.sh @@ -0,0 +1,10 @@ + +# Function to define colors +define_colors() { + green='\033[0;32m' + cyan='\033[0;36m' + red='\033[0;31m' + yellow='\033[0;33m' + LPurple='\033[1;35m' + NC='\033[0m' # No Color +} \ No newline at end of file diff --git a/menu.sh b/menu.sh index 4c7d617..08224b0 100644 --- a/menu.sh +++ b/menu.sh @@ -1,14 +1,6 @@ #!/bin/bash -# Function to define colors -define_colors() { - green='\033[0;32m' - cyan='\033[0;36m' - red='\033[0;31m' - yellow='\033[0;33m' - LPurple='\033[1;35m' - NC='\033[0m' # No Color -} +source /etc/hysteria/core/scripts/utils.sh # Ensure necessary packages are installed clear @@ -20,8 +12,8 @@ if ! command -v jq &> /dev/null || ! command -v qrencode &> /dev/null || ! comma fi # Add alias 'hys2' for Hysteria2 -if ! grep -q "alias hys2='bash <(curl https://raw.githubusercontent.com/H-Return/Hysteria2/main/menu.sh)'" ~/.bashrc; then - echo "alias hys2='bash <(curl https://raw.githubusercontent.com/H-Return/Hysteria2/main/menu.sh)'" >> ~/.bashrc +if ! grep -q "alias hys2='/etc/hysteria/menu.sh'" ~/.bashrc; then + echo "alias hys2='/etc/hysteria/menu.sh'" >> ~/.bashrc source ~/.bashrc fi @@ -124,11 +116,11 @@ hysteria2_menu() { display_hysteria2_menu read -r choice case $choice in - 1) install_and_configure ;; + 1) python3 /etc/hysteria/core/cli.py install-hysteria2 ;; 2) add_user ;; 3) modify_users ;; 4) show_uri ;; - 5) traffic_status ;; + 5) python3 /etc/hysteria2/core/cli.py traffic_status ;; 6) remove_user ;; 0) return ;; *) echo "Invalid option. Please try again." ;;