From 14f61134dc5a536218584f59d958a637109b9019 Mon Sep 17 00:00:00 2001 From: Sarina Date: Sun, 21 Jul 2024 21:32:11 +0330 Subject: [PATCH] Fix path related issues --- core/scripts/hysteria2/add_user.sh | 6 +++--- core/scripts/hysteria2/install.sh | 2 +- core/scripts/hysteria2/remove_user.sh | 8 ++++---- core/scripts/hysteria2/show_user_uri.sh | 8 ++++---- core/scripts/hysteria2/user.sh | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/core/scripts/hysteria2/add_user.sh b/core/scripts/hysteria2/add_user.sh index 9fcfe98..17c7d59 100644 --- a/core/scripts/hysteria2/add_user.sh +++ b/core/scripts/hysteria2/add_user.sh @@ -41,13 +41,13 @@ add_user() { traffic=$((traffic_gb * 1073741824)) - if [ ! -f "/etc/hysteria/users/users.json" ]; then - echo "{}" > /etc/hysteria/users/users.json + if [ ! -f "/etc/hysteria/users.json" ]; then + echo "{}" > /etc/hysteria/users.json fi jq --arg username "$username" --arg password "$password" --argjson traffic "$traffic" --argjson expiration_days "$expiration_days" --arg creation_date "$creation_date" \ '.[$username] = {password: $password, max_download_bytes: $traffic, expiration_days: $expiration_days, account_creation_date: $creation_date, blocked: false}' \ - /etc/hysteria/users/users.json > /etc/hysteria/users/users_temp.json && mv /etc/hysteria/users/users_temp.json /etc/hysteria/users/users.json + /etc/hysteria/users.json > /etc/hysteria/users_temp.json && mv /etc/hysteria/users_temp.json /etc/hysteria/users.json python3 /etc/hysteria/core/cli.py restart-hysteria2 > /dev/null 2>&1 diff --git a/core/scripts/hysteria2/install.sh b/core/scripts/hysteria2/install.sh index c8d1e26..34cae15 100644 --- a/core/scripts/hysteria2/install.sh +++ b/core/scripts/hysteria2/install.sh @@ -116,7 +116,7 @@ install_hysteria() { # Add the scripts to the crontab (crontab -l ; echo "*/1 * * * * python3 /etc/hysteria/core/cli.py traffic-status >/dev/null 2>&1") | crontab - (crontab -l ; echo "*/1 * * * * /etc/hysteria/core/scripts/hysteria2/kick.sh >/dev/null 2>&1") | crontab - - } +} diff --git a/core/scripts/hysteria2/remove_user.sh b/core/scripts/hysteria2/remove_user.sh index 628ff6e..619617b 100644 --- a/core/scripts/hysteria2/remove_user.sh +++ b/core/scripts/hysteria2/remove_user.sh @@ -9,10 +9,10 @@ remove_user() { username=$1 - if [ -f "/etc/hysteria/users/users.json" ]; then + if [ -f "/etc/hysteria/users.json" ]; then # Check if the username exists in the users.json file - if jq -e "has(\"$username\")" /etc/hysteria/users/users.json > /dev/null; then - jq --arg username "$username" 'del(.[$username])' /etc/hysteria/users/users.json > /etc/hysteria/users/users_temp.json && mv /etc/hysteria/users/users_temp.json /etc/hysteria/users/users.json + if jq -e "has(\"$username\")" /etc/hysteria/users.json > /dev/null; then + jq --arg username "$username" 'del(.[$username])' /etc/hysteria/users.json > /etc/hysteria/users_temp.json && mv /etc/hysteria/users_temp.json /etc/hysteria/users.json if [ -f "/etc/hysteria/traffic_data.json" ]; then jq --arg username "$username" 'del(.[$username])' /etc/hysteria/traffic_data.json > /etc/hysteria/traffic_data_temp.json && mv /etc/hysteria/traffic_data_temp.json /etc/hysteria/traffic_data.json @@ -24,7 +24,7 @@ remove_user() { echo -e "\033[0;31mError:\033[0m User $username not found." fi else - echo -e "\033[0;31mError:\033[0m Config file /etc/hysteria/users/users.json not found." + echo -e "\033[0;31mError:\033[0m Config file /etc/hysteria/users.json not found." fi } diff --git a/core/scripts/hysteria2/show_user_uri.sh b/core/scripts/hysteria2/show_user_uri.sh index 35302b3..0009c2a 100644 --- a/core/scripts/hysteria2/show_user_uri.sh +++ b/core/scripts/hysteria2/show_user_uri.sh @@ -2,7 +2,7 @@ # Function to show URI if Hysteria2 is installed and active show_uri() { - if [ -f "/etc/hysteria/users/users.json" ]; then + if [ -f "/etc/hysteria/users.json" ]; then if systemctl is-active --quiet hysteria-server.service; then # Check if the username is provided as an argument if [ -z "$1" ]; then @@ -13,9 +13,9 @@ show_uri() { username=$1 # Validate the username - if jq -e "has(\"$username\")" /etc/hysteria/users/users.json > /dev/null; then + if jq -e "has(\"$username\")" /etc/hysteria/users.json > /dev/null; then # Get the selected user's details - authpassword=$(jq -r ".\"$username\".password" /etc/hysteria/users/users.json) + authpassword=$(jq -r ".\"$username\".password" /etc/hysteria/users.json) port=$(jq -r '.listen' /etc/hysteria/config.json | cut -d':' -f2) sha256=$(jq -r '.tls.pinSHA256' /etc/hysteria/config.json) obfspassword=$(jq -r '.obfs.salamander.password' /etc/hysteria/config.json) @@ -56,7 +56,7 @@ show_uri() { echo -e "\033[0;31mError:\033[0m Hysteria2 is not active." fi else - echo -e "\033[0;31mError:\033[0m Config file /etc/hysteria/users/users.json not found." + echo -e "\033[0;31mError:\033[0m Config file /etc/hysteria/users.json not found." fi } diff --git a/core/scripts/hysteria2/user.sh b/core/scripts/hysteria2/user.sh index 4e6f115..f20f17c 100644 --- a/core/scripts/hysteria2/user.sh +++ b/core/scripts/hysteria2/user.sh @@ -4,7 +4,7 @@ ADDR="$1" AUTH="$2" TX="$3" -USERS_FILE="/etc/hysteria/users/users.json" +USERS_FILE="/etc/hysteria/users.json" TRAFFIC_FILE="/etc/hysteria/traffic_data.json" CONFIG_FILE="/etc/hysteria/config.json"