forked from buzzhub/lsyupdate
check 添加 9100
This commit is contained in:
parent
84aac32552
commit
0c868705e1
@ -36,23 +36,37 @@ function get_cloud_config() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
cloud_mac_address="$mac_address-v1"
|
cloud_mac_address_v1="$mac_address-v1"
|
||||||
echo "Cloud MAC Address: $cloud_mac_address"
|
cloud_mac_address_v2="$mac_address-v2"
|
||||||
echo "Cloud Port: $cloud_port"
|
cloud_port_v2=$((cloud_port + 10000))
|
||||||
|
|
||||||
|
echo "Cloud MAC Address V1: $cloud_mac_address_v1"
|
||||||
|
echo "Cloud MAC Address V2: $cloud_mac_address_v2"
|
||||||
|
echo "Cloud Port V1 (22): $cloud_port"
|
||||||
|
echo "Cloud Port V2 (9100): $cloud_port_v2"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 检查 FRPC 配置是否与云端一致
|
# 检查 FRPC 配置是否与云端一致
|
||||||
function check_config() {
|
function check_config() {
|
||||||
local cloud_port="$1"
|
local cloud_port="$1"
|
||||||
local cloud_mac_address="$2"
|
local cloud_mac_address_v1="$2"
|
||||||
|
local cloud_mac_address_v2="$3"
|
||||||
|
local cloud_port_v2="$4"
|
||||||
|
|
||||||
current_mac_address=$(grep -Eo '^\[[a-f0-9:-]*-v1\]' "$CONFIG_FILE" | tr -d '[]')
|
current_port_v1=$(awk -v section="[$cloud_mac_address_v1]" '
|
||||||
current_port=$(grep -o 'remote_port = [0-9]*' "$CONFIG_FILE" | awk '{print $3}' | xargs)
|
$0 ~ section { found=1 }
|
||||||
|
found && /remote_port = [0-9]+/ { print $3; exit }
|
||||||
|
' "$CONFIG_FILE")
|
||||||
|
|
||||||
echo "Current MAC Address in frpc.ini: '$current_mac_address' '$cloud_mac_address'"
|
current_port_v2=$(awk -v section="[$cloud_mac_address_v2]" '
|
||||||
echo "Current Port in frpc.ini: '$current_port' '$cloud_port'"
|
$0 ~ section { found=1 }
|
||||||
|
found && /remote_port = [0-9]+/ { print $3; exit }
|
||||||
|
' "$CONFIG_FILE")
|
||||||
|
|
||||||
if [ "$current_mac_address" != "$cloud_mac_address" ] || [ "$current_port" != "$cloud_port" ]; then
|
echo "Current Port for $cloud_mac_address_v1 (22): '$current_port_v1' (Expected: '$cloud_port')"
|
||||||
|
echo "Current Port for $cloud_mac_address_v2 (9100): '$current_port_v2' (Expected: '$cloud_port_v2')"
|
||||||
|
|
||||||
|
if [ "$current_port_v1" != "$cloud_port" ] || [ "$current_port_v2" != "$cloud_port_v2" ]; then
|
||||||
echo "[INFO] Configuration mismatch detected. Updating frpc.ini..."
|
echo "[INFO] Configuration mismatch detected. Updating frpc.ini..."
|
||||||
cat > "$CONFIG_FILE" <<EOF
|
cat > "$CONFIG_FILE" <<EOF
|
||||||
[common]
|
[common]
|
||||||
@ -60,11 +74,17 @@ server_addr = box.jxm.cool
|
|||||||
server_port = 8000
|
server_port = 8000
|
||||||
token = 92098d16-1961-4bda-902b-e43e3d41d5a9
|
token = 92098d16-1961-4bda-902b-e43e3d41d5a9
|
||||||
|
|
||||||
[$cloud_mac_address]
|
[$cloud_mac_address_v1]
|
||||||
type = tcp
|
type = tcp
|
||||||
local_ip = 127.0.0.1
|
local_ip = 127.0.0.1
|
||||||
local_port = 22
|
local_port = 22
|
||||||
remote_port = $cloud_port
|
remote_port = $cloud_port
|
||||||
|
|
||||||
|
[$cloud_mac_address_v2]
|
||||||
|
type = tcp
|
||||||
|
local_ip = 127.0.0.1
|
||||||
|
local_port = 9100
|
||||||
|
remote_port = $cloud_port_v2
|
||||||
EOF
|
EOF
|
||||||
echo "[INFO] Configuration updated. Restarting frpc..."
|
echo "[INFO] Configuration updated. Restarting frpc..."
|
||||||
sudo systemctl restart lsyfrpc.service
|
sudo systemctl restart lsyfrpc.service
|
||||||
@ -89,7 +109,7 @@ main() {
|
|||||||
trap "rm -f $LOCK_FILE" EXIT SIGHUP SIGINT SIGTERM SIGQUIT
|
trap "rm -f $LOCK_FILE" EXIT SIGHUP SIGINT SIGTERM SIGQUIT
|
||||||
|
|
||||||
get_cloud_config
|
get_cloud_config
|
||||||
check_config "$cloud_port" "$cloud_mac_address"
|
check_config "$cloud_port" "$cloud_mac_address_v1" "$cloud_mac_address_v2" "$cloud_port_v2"
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user