wireguard-ui icon indicating copy to clipboard operation
wireguard-ui copied to clipboard

Config re-sync instead of full wireguard restart

Open armisss4 opened this issue 2 years ago • 4 comments

Created wireguard restart script, which compares wg0.conf part between [Interface] and first peer with previous version for changes, and, if there is any - restarts whole wireguard, if the only changes are done to peers, it calls "wg syncconf", eliminating client disconnection after pressing apply config problem. Resolves #228, resolves #167

armisss4 avatar Feb 10 '23 13:02 armisss4

Since you are modifying a bash HEREDOC in the readme, insert a pwd via a shell variable instead of /DIR-TO-RESTART-FILE/ which not everyone will pick up on.

systemcrash avatar Feb 16 '23 19:02 systemcrash

Instead of using: ExecStart=/usr/bin/systemctl restart [email protected]

use: ExecStart=/usr/bin/systemctl reload [email protected]

afzl-wtu avatar Mar 20 '23 07:03 afzl-wtu

I tried using systemctl reload instead of systemctl restart and reload caused my remote shell to never reconnect, while restart would reconnect after a few seconds.

I like the script though, Im using it on my machine!

I added another little thing to it, since I wanted my wg0.conf to be regenerated from the db each time I run the script.

...
config="/etc/wireguard/wg0.conf"
old_config="/etc/wireguard/wg0.conf.old"

rm $config
systemctl restart wireguard-ui
sleep 5
# Wait for the wg0.conf to be reloaded before continuing on with the script
echo "Config Regenerated"

if [ ! -f $old_config ]; then
...

kornpow avatar Apr 04 '23 20:04 kornpow

If I understand this code right, it is fixed to wg0 interface. But can not handle any other, if the name is not wg0 but wg1 or anyname.at.anytown2. Right? Should not be that rather a dynamic config parameter? (Even the auto-install script is asking for a WireGuard interface name.)

PizzaProgram avatar May 24 '23 05:05 PizzaProgram