Best way to toggle WireGuard on and off?

I'm still learning that stuff. But it's just a matter of time...

Note to self: Combining wgon and wgoff scripts into wgtoggle script that turns it on if it's off and turns it off if it's on:

#!/bin/sh

# Get the current WireGuard interface status
wg_status=$(wg show wg0)

# Check if WireGuard is already running
if [ -z "$wg_status" ]; then
  # WireGuard is not running, so enable it
  uci -q del network.wg0.disabled
  echo "Enabling WireGuard..."
else
  # WireGuard is running, so disable it
  uci -q set network.wg0.disabled='1'
  echo "Disabling WireGuard..."
fi

# Commit changes to network configuration
uci -q commit network

# Restart network service to apply changes
service network restart

echo "Done!"

Save in /usr/local as wgtoggle
Make the script executable using: chmod +x wgtoggle

Run the script with ./wgtoggle to toggle WireGuard based on its current state

Edit: Script doesn't work. Not detecting WireGuard status. Dang. Thought this was clever.