summaryrefslogtreecommitdiffstats
path: root/connect/vpn/vpn-name.sh.example
blob: 0aa4c002fbee6b798b3bbdba2bbf3add47f56ccb (plain)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# example VPN config script

vpn_prepare()
{
	example_ipaddr=192.168.0.1
	example_openvpn_port=1194
	example_openvpn_tundev="$(get_unused_tun_device)"
	[ -n "$example_openvpn_tundev" ] || die "Failed to get TUN device"
	example_openvpn_ca="/etc/openvpn/keys/example-ca.crt"
	example_openvpn_cert="/etc/openvpn/keys/example.crt"
	example_openvpn_key="/etc/openvpn/keys/example.key"
	example_openvpn_pid=
	example_openvpn_log="$(mktemp /tmp/example.openvpn.log.XXXXXX)"
	[ -w "$example_openvpn_log" ] || die "Failed to create example log"
}

vpn_stop()
{
	openvpn_kill "example" "$example_openvpn_pid" \
		"$example_openvpn_log"
	example_openvpn_pid=
}

vpn_start()
{
	openvpn --client \
		--dev "$example_openvpn_tundev" \
		--proto tcp \
		--remote "$example_ipaddr" "$example_openvpn_port" \
		--nobind \
		--ca "$example_openvpn_ca" \
		--cert "$example_openvpn_cert" \
		--key "$example_openvpn_key" \
		--remote-cert-tls server \
		--cipher BF-CBC \
		--keysize 128 \
		--auth SHA1 \
		--comp-lzo \
		--persist-key \
		--persist-tun \
		--verb 4 \
		--log "$example_openvpn_log" &
	example_openvpn_pid=$!

	openvpn_wait_connect "example" "$example_openvpn_pid" \
		"$example_openvpn_log"
}

vpn_destroy()
{
	rm -f "$example_openvpn_log"
}
bues.ch cgit interface