gl-wg already provides this for when the device is configured as a wg client:

root@GL-AR300M:~# grep shared /etc/init.d/wireguard
local preshared_key
config_get preshared_key $1 “preshared_key”
[ -n “$preshared_key” ] && echo -e “PresharedKey = $preshared_key” >>“$WFILE”

but the same is not available in gl-wg-server. I assume you don’t provide the source for those (I couldn’t find it in github), so it is not possible to contribute enhancements.