aboutsummaryrefslogblamecommitdiff
path: root/vpn
blob: 6d5d7fe661419948fd7d7b7038fa1c7a5e0e7d3d (plain) (tree)
1
2
3
4
5
6
7
8
9
         
 



                                             
 

                            
 



                           
                                                                                   












                                                                            
#!/bin/sh

note()
{
	command -v notify-send > /dev/null &&
		notify-send "撚 vpn" "$1"

	printf "\n%s\n" "$1"
}

main()
{
	wg_conf="${1:-wg0}"

	if ip -details link show "$wg_conf" 2> /dev/null | grep --quiet "wireguard"
	then
		sudo -A -p "撚  halt vpn: " wg-quick down "$wg_conf" &&
			note "connection was dropped"
	else
		sudo -A -p "撚  initialize vpn: " wg-quick up "$wg_conf" &&
			note "traffic routed through $wg_conf"
	fi

	command -v wip > /dev/null &&
		wip
}

main "$@"