Script to switch between wireguard server:
#!/bin/sh
# Read the current value of main_server
main_server="$(uci get wireguard.@proxy[0].main_server)"
# Get the index of the current main_server option
index=$(uci show wireguard | grep -n "main_server=$main_server$" | cut -d ':' -f 1)
# Get the names of all the peers
peer_names=$(uci show wireguard | grep -o "name=[^ ]*" | cut -d '=' -f 2)
# Get the number of peers
num_peers=$(echo "$peer_names" | wc -l)
# Find the index of the current main_server option in the peer list
peer_index=$(echo "$peer_names" | grep -n "$main_server" | cut -d ':' -f 1)
# Calculate the index of the next peer
next_peer_index=$(( (peer_index % num_peers) + 1 ))
# Get the name of the next peer
next_peer=$(echo "$peer_names" | sed -n "${next_peer_index}p" | sed "s/\'//g")
# Update the main_server option
uci set wireguard.@proxy[0].main_server="$next_peer"
# Commit the changes
uci commit wireguard
For instance save it as file name, /usr/bin/rotato_wg_server.sh
Then change script /usr/bin/switchaction to call it.