Skip to content

Commit

Permalink
take down multiple profile before taking up only one
Browse files Browse the repository at this point in the history
  • Loading branch information
francescor committed Nov 28, 2021
1 parent 04053c5 commit 451a198
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions wirego
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 451a198

Please sign in to comment.