I belive there's a small error in the code .
when key's are generated ...the WG_PUB="$(cat wgclient.pub)" should be WG_PUB="$(cat wgserver.pub)"
WG_PUB="$(cat wgclient.pub)" will give error
# Generate and exchange the keys
umask u=rw,g=,o=
wg genkey | tee wgserver.key | wg pubkey > wgserver.pub
wg genpsk > wg.psk
WG_KEY="$(cat wgserver.key)"
WG_PSK="$(cat wg.psk)"
WG_PUB="$(cat wgclient.pub)"