aboutsummaryrefslogblamecommitdiff
path: root/vpn
blob: 0e5998e1ae769d0be4eb0a86c934930e721c1341 (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 "wireguard" > /dev/null 2>&1
	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 "$@"