From 959e5be86a2f5f3a3c26c84ad7bb8330b25e3f28 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Fri, 23 Aug 2024 12:01:33 +0330 Subject: [PATCH] Use users.json --- core/scripts/hysteria2/remove_user.sh | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/core/scripts/hysteria2/remove_user.sh b/core/scripts/hysteria2/remove_user.sh index 1759032..a5e1624 100644 --- a/core/scripts/hysteria2/remove_user.sh +++ b/core/scripts/hysteria2/remove_user.sh @@ -1,29 +1,21 @@ #!/bin/bash -# Source the path.sh script to load the necessary variables source /etc/hysteria/core/scripts/path.sh source /etc/hysteria/core/scripts/utils.sh define_colors -# Function to remove a user from the configuration remove_user() { if [ $# -ne 1 ]; then echo "Usage: $0 " exit 1 fi - username=$1 + local username=$1 if [ -f "$USERS_FILE" ]; then - # Check if the username exists in the users.json file if jq -e "has(\"$username\")" "$USERS_FILE" > /dev/null; then jq --arg username "$username" 'del(.[$username])' "$USERS_FILE" > "${USERS_FILE}.temp" && mv "${USERS_FILE}.temp" "$USERS_FILE" - if [ -f "$TRAFFIC_FILE" ]; then - jq --arg username "$username" 'del(.[$username])' "$TRAFFIC_FILE" > "${TRAFFIC_FILE}.temp" && mv "${TRAFFIC_FILE}.temp" "$TRAFFIC_FILE" - fi - - python3 "$CLI_PATH" restart-hysteria2 > /dev/null 2>&1 echo "User $username removed successfully." else echo -e "${red}Error:${NC} User $username not found." @@ -33,5 +25,4 @@ remove_user() { fi } -# Call the function with the provided username argument remove_user "$1"