Refactor paths

This commit is contained in:
Sarina
2024-07-22 15:46:16 +03:30
parent 1985a171e9
commit ba9ff87b8c
11 changed files with 133 additions and 96 deletions

View File

@ -1,3 +1,8 @@
#!/bin/bash
# Source the path.sh script to load the CONFIG_FILE variable
source /etc/hysteria/core/scripts/path.sh
# Function to update port number in configuration
update_port() {
local port=$1
@ -9,14 +14,14 @@ update_port() {
fi
# Check if the config file exists and update the port number
if [ -f "/etc/hysteria/config.json" ]; then
jq --arg port "$port" '.listen = ":" + $port' /etc/hysteria/config.json > /etc/hysteria/config_temp.json && mv /etc/hysteria/config_temp.json /etc/hysteria/config.json
python3 /etc/hysteria/core/cli.py restart-hysteria2 > /dev/null 2>&1
if [ -f "$CONFIG_FILE" ]; then
jq --arg port "$port" '.listen = ":" + $port' "$CONFIG_FILE" > "${CONFIG_FILE}.temp" && mv "${CONFIG_FILE}.temp" "$CONFIG_FILE"
python3 "$CLI_PATH" restart-hysteria2 > /dev/null 2>&1
echo "Port changed successfully to $port."
else
echo "Error: Config file /etc/hysteria/config.json not found."
echo "Error: Config file $CONFIG_FILE not found."
return 1
fi
}
update_port "$1"
update_port "$1"