Fix path related issues
This commit is contained in:
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user