mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-04-20 20:03:39 +03:00
Merge 09abbdfcf0
into 2fdafd34ca
This commit is contained in:
commit
3a69630ce3
2 changed files with 28 additions and 1 deletions
|
@ -124,7 +124,7 @@ After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStart=/usr/bin/systemctl restart wg-quick@wg0.service
|
ExecStart=/bin/bash /DIR-TO-RESTART-FILE/restart-wg.sh
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
RequiredBy=wgui.path
|
RequiredBy=wgui.path
|
||||||
|
|
27
restart-wg.sh
Normal file
27
restart-wg.sh
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
config="/etc/wireguard/wg0.conf"
|
||||||
|
old_config="/etc/wireguard/wg0.conf.old"
|
||||||
|
|
||||||
|
if [ ! -f $old_config ]; then
|
||||||
|
awk '/Interface/,/# ID:/' $config | head -n -1 | tail -n +2 > $old_config
|
||||||
|
echo "No old config found, restarting wireguard (wg-quick)"
|
||||||
|
wg-quick down wg0
|
||||||
|
systemctl restart wg-quick@wg0.service
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
difference=$(diff <(awk '/Interface/,/# ID:/' $config | head -n -1 | tail -n +2) <(cat $old_config))
|
||||||
|
|
||||||
|
if [ -n "$difference" ]; then
|
||||||
|
awk '/Interface/,/# ID:/' $config | head -n -1 | tail -n +2 > $old_config
|
||||||
|
echo "Changes to interface detected, restarting wireguard (wg-quick)"
|
||||||
|
wg-quick down wg0
|
||||||
|
systemctl restart wg-quick@wg0.service
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
awk '/Interface/,/# ID:/' $config | head -n -1 | tail -n +2 > $old_config
|
||||||
|
echo "No changes to interface detected, restarting wireguard (wg syncconf)"
|
||||||
|
wg syncconf wg0 <(wg-quick strip wg0)
|
||||||
|
exit 0
|
||||||
|
fi
|
Loading…
Add table
Reference in a new issue