From 451a19845c72cd3f321a700c52d0ad5849d13d6d Mon Sep 17 00:00:00 2001 From: francescor Date: Sun, 28 Nov 2021 12:30:02 +0100 Subject: [PATCH] take down multiple profile before taking up only one --- wirego | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/wirego b/wirego index 0a67431..6b41307 100755 --- a/wirego +++ b/wirego @@ -37,6 +37,16 @@ function wg-quick-with-message() { wg-quick $up_down $profile } +function wirego_down() { + for active_profile in $active_profiles; do + wg-quick-with-message down $active_profile + if [ "${DISTRO}" == "fedora" ]; then + # restart resolved to remove wireguard DNS from your /etc/resolv.conf + sudo systemctl restart systemd-resolved.service + fi + done +} + # Detect Operating System if [ -f /etc/os-release ]; then source /etc/os-release @@ -108,15 +118,8 @@ fi if [ "$parameter" == "down" ] ; then if [ "$active_profiles" != "" ] ; then - for active_profile in $active_profiles; do - wg-quick-with-message down $active_profile - echo - if [ "${DISTRO}" == "fedora" ]; then - # restart resolved to remove wireguard DNS from your /etc/resolv.conf - sudo systemctl restart systemd-resolved.service - fi - done - else + wirego_down + else echo "wg is already down" fi exit