From 0a467597cc1dd815a707376c039973fe7dcc2333 Mon Sep 17 00:00:00 2001 From: Alex Blank Date: Mon, 9 Oct 2023 14:39:12 +0200 Subject: [PATCH] added mullvad reconnect on dns failure script --- .config/nvim/init.vim | 4 ++++ .scripts/network_utilities.sh | 33 +++++++++++++++++++++++++++++++++ .scripts/updating.sh | 19 +++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 .scripts/network_utilities.sh create mode 100644 .scripts/updating.sh diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index cbf5f14..d6b551d 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -15,3 +15,7 @@ Plug 'preservim/nerdtree' Plug 'github/copilot.vim' call plug#end() + + +" set tab to 4 spaces for neovim +set tabstop=4 diff --git a/.scripts/network_utilities.sh b/.scripts/network_utilities.sh new file mode 100644 index 0000000..e976ecd --- /dev/null +++ b/.scripts/network_utilities.sh @@ -0,0 +1,33 @@ +# network utility functions + +# get the ip address of the host +function get_local_ip() { + echo -e "The interfaces and IPs are:\n$(ip -o -4 addr show | awk '/inet 192.168|inet 10.|inet 172.16/ {split($4, a, "/"); print $2 ": " a[1] "\n"}')" +} + +function get_public_ip() { + public_ip=$(curl -s canhazip.com) + echo -e "The public IP is: $public_ip" +} + +function is_dns_working() { + dns_working=$(ping -c 1 google.com | grep "1 received" | wc -l) + if [ $dns_working -eq 1 ]; then + return 0 + else + return 1 + fi + +} + + +function reconnect_vpn_on_dns_failure() { + # reconnect vpn if dns is not working + if ! is_dns_working; then + echo "DNS is not working, reconnecting VPN" + mullvad reconnect + else + echo "DNS is working, no need to reconnect VPN" + fi +} + diff --git a/.scripts/updating.sh b/.scripts/updating.sh new file mode 100644 index 0000000..70c57cd --- /dev/null +++ b/.scripts/updating.sh @@ -0,0 +1,19 @@ +# script for updating all packages but excluding a list of packages + +# set path to list of packages to exclude +exclude_list_file=~/.setup/packages/exclude_from_updating.list + +# load list of packages to exclude +exclude_list=$(cat $exclude_list_file) + +# define function that calls yay update and excludes packages from exclude_list + +function update_system { + yay -Syu --noconfirm --needed --noprovides --ignore $exclude_list +} + +# also define function that only updates packages from pacman +function update_pacman_packages { + sudo pacman -Syu --noconfirm --needed --noprovides --ignore $exclude_list +} +