Lil refactor

This commit is contained in:
Sarina
2024-07-21 18:46:02 +03:30
parent 8ea571eb1b
commit 04ae679294
3 changed files with 17 additions and 21 deletions

View File

@ -1,13 +1,7 @@
#!/bin/bash #!/bin/bash
define_colors() { source /etc/hysteria/core/scripts/utils.sh
green='\033[0;32m' define_colors
cyan='\033[0;36m'
red='\033[0;31m'
yellow='\033[0;33m'
LPurple='\033[1;35m'
NC='\033[0m'
}
install_hysteria() { install_hysteria() {
# Step 1: Install Hysteria2 # Step 1: Install Hysteria2

10
core/scripts/utils.sh Normal file
View File

@ -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
}

18
menu.sh
View File

@ -1,14 +1,6 @@
#!/bin/bash #!/bin/bash
# Function to define colors source /etc/hysteria/core/scripts/utils.sh
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
}
# Ensure necessary packages are installed # Ensure necessary packages are installed
clear clear
@ -20,8 +12,8 @@ if ! command -v jq &> /dev/null || ! command -v qrencode &> /dev/null || ! comma
fi fi
# Add alias 'hys2' for Hysteria2 # Add alias 'hys2' for Hysteria2
if ! grep -q "alias hys2='bash <(curl https://raw.githubusercontent.com/H-Return/Hysteria2/main/menu.sh)'" ~/.bashrc; then if ! grep -q "alias hys2='/etc/hysteria/menu.sh'" ~/.bashrc; then
echo "alias hys2='bash <(curl https://raw.githubusercontent.com/H-Return/Hysteria2/main/menu.sh)'" >> ~/.bashrc echo "alias hys2='/etc/hysteria/menu.sh'" >> ~/.bashrc
source ~/.bashrc source ~/.bashrc
fi fi
@ -124,11 +116,11 @@ hysteria2_menu() {
display_hysteria2_menu display_hysteria2_menu
read -r choice read -r choice
case $choice in case $choice in
1) install_and_configure ;; 1) python3 /etc/hysteria/core/cli.py install-hysteria2 ;;
2) add_user ;; 2) add_user ;;
3) modify_users ;; 3) modify_users ;;
4) show_uri ;; 4) show_uri ;;
5) traffic_status ;; 5) python3 /etc/hysteria2/core/cli.py traffic_status ;;
6) remove_user ;; 6) remove_user ;;
0) return ;; 0) return ;;
*) echo "Invalid option. Please try again." ;; *) echo "Invalid option. Please try again." ;;