aboutsummaryrefslogtreecommitdiff
path: root/vpn
blob: 0eef247eb067aef96a2ed80cf97a3c62ab48dc27 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/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, authentication required: " wg-quick down "$wg_conf" &&
			note "connection was dropped"
	else
		sudo -A -p " init, authentication required: " wg-quick up "$wg_conf" &&
			note "traffic routed through $wg_conf"
	fi && command -v wip > /dev/null &&
		wip
}

main "$@"