Config re-sync instead of full wireguard restart
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
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.
Instead of using: ExecStart=/usr/bin/systemctl restart [email protected]
use: ExecStart=/usr/bin/systemctl reload [email protected]
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
...
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.)