ngoduykhanh / wireguard-ui

Wireguard web interface
MIT License
4.25k stars 524 forks source link

Feature Request: Replace systemctl restart wg-quick@wg0.service with wg syncconf wg0 to Avoid Network Disruption #613

Open WorkTimer opened 3 months ago

WorkTimer commented 3 months ago

I propose replacing the systemctl restart wg-quick@wg0.service command with wg syncconf wg0 in the service execution command. This change aims to prevent network disruptions during the reconfiguration process. Here's the suggested modification: Replace: ExecStart=/usr/bin/systemctl restart wg-quick@wg0.service With: ExecStart=/bin/sh -c 'grep -v -e "^Address = " -e "MTU = " -e "PostUp = " -e "PreDown = " -e "PostDown = " -e "Table = " /etc/wireguard/wg0.conf | wg syncconf wg0 /dev/stdin'

/etc/systemd/system/wgui.service :

[Unit]
Description=Restart WireGuard
After=network.target

[Service]
Type=oneshot
# User=root
# Group=root
# ExecStart=/usr/bin/systemctl restart wg-quick@wg0.service
ExecStart=/bin/sh -c 'grep -v -e "^Address = " -e "MTU = " -e "PostUp = " -e "PreDown = " -e "PostDown = " -e "Table = " /etc/wireguard/wg0.conf | wg syncconf wg0 /dev/stdin'

[Install]
RequiredBy=wgui.path