-
Notifications
You must be signed in to change notification settings - Fork 0
/
0vpn-options
executable file
·65 lines (58 loc) · 2.52 KB
/
0vpn-options
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
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# This script is expected to be sourced by the other 0vpn-scripts
if [ "$0" == "${BASH_SOURCE[0]}" ]; then
echo "This script is made to be sourced, not run."
exit 1
fi
ZEROVPN_SERVER_HOSTNAME="$(hostname --long)"
ZEROVPN_SERVER_NAME="$(hostname --short)"
ZEROVPN_WIREGUARD_PORT="4242"
ZEROVPN_ANNOUNCE_PORT="4243"
ZEROVPN_ANNOUNCE_INTERVAL="10"
ZEROVPN_DNS_PORT="53"
ZEROVPN_KEYFILE="key"
ZEROVPN_TLD="internal"
ZEROVPN_WIREGUARD_DEVICE="wg0"
ZEROVPN_STATIC_CLIENTS=""
ZEROVPN_CLIENT_NAME="$(hostname --short)"
function help {
echo "Common available options:"
echo " --server-hostname [hostname] (default: \"$ZEROVPN_SERVER_HOSTNAME\")"
echo " --server-name [name] (default: \"$ZEROVPN_SERVER_NAME\")"
echo " --wireguard-port [port] (default: \"$ZEROVPN_WIREGUARD_PORT\")"
echo " --announce-port [port] (default: \"$ZEROVPN_ANNOUNCE_PORT\")"
echo " --dns-port [port] (default: \"$ZEROVPN_DNS_PORT\")"
echo " --keyfile [filename] (default: \"$ZEROVPN_KEYFILE\")"
echo " --tld [domain-name] (default: \"$ZEROVPN_TLD\")"
echo " --wireguard-device [device-name] (default: \"$ZEROVPN_WIREGUARD_DEVICE\")"
echo ""
echo "Server-only options:"
echo " --static-clients [list of names] (default: \"$ZEROVPN_STATIC_CLIENTS\")"
echo ""
echo "Client-only options:"
echo " --client-name [name] (default: \"$ZEROVPN_CLIENT_NAME\")"
echo " --announce-interval [seconds] (default: \"$ZEROVPN_ANNOUNCE_INTERVAL\")"
}
while true; do
if [ "$#" -eq 0 ]; then
break;
fi
case $1 in
--server-hostname) ZEROVPN_SERVER_HOSTNAME="$2"; shift 2;;
--server-name) ZEROVPN_SERVER_NAME="$2"; shift 2;;
--wireguard-port) ZEROVPN_WIREGUARD_PORT="$2"; shift 2;;
--announce-port) ZEROVPN_ANNOUNCE_PORT="$2"; shift 2;;
--announce-interval) ZEROVPN_ANNOUNCE_INTERVAL="$2"; shift 2;;
--dns-port) ZEROVPN_DNS_PORT="$2"; shift 2;;
--keyfile) ZEROVPN_KEYFILE="$2"; shift 2;;
--tld) ZEROVPN_TLD="$2"; shift 2;;
--wireguard-device) ZEROVPN_WIREGUARD_DEVICE="$2"; shift 2;;
--static-clients) ZEROVPN_STATIC_CLIENTS="$2"; shift 2;;
--client-name) ZEROVPN_CLIENT_NAME="$2"; shift 2;;
--help) help; shift 1; exit 0;;
-h) help; shift 1; exit 0;;
*) echo "Error parsing arguments. Expected argument. Got: \"$1\""; exit 1;;
esac
done
echo "Configuration:"
for n in "${!ZEROVPN_@}"; do echo " $n=${!n}"; done