File tree Expand file tree Collapse file tree 1 file changed +27
-4
lines changed
vpn-client/playbooks/templates Expand file tree Collapse file tree 1 file changed +27
-4
lines changed Original file line number Diff line number Diff line change 22
33set -euxo pipefail
44
5+ # Generate new client vpn configs and
6+ # write them to file
7+ # does not distribute them.
8+
59# Configuration parameters
6- SERVER_PUBLIC_IP=$1
7- SERVER_PORT=$2
8- SERVER_PUBLIC_KEY=$( wg pubkey < router-private.key)
9- DNS=$3
10+ # Check if $1 is set and not empty
11+ if [[ $# -ge 1 ]]; then
12+ SERVER_PUBLIC_IP=$1
13+ else
14+ SERVER_PUBLIC_IP=$( ip route get 8.8.8.8 | head -n 1 | awk ' {print $7}' )
15+ fi
16+
17+ echo " $SERVER_PUBLIC_IP "
18+
19+ # Check if $2 is set and not empty
20+ if [[ $# -ge 2 ]]; then
21+ SERVER_PORT=$2
22+ else
23+ SERVER_PORT=3478
24+ echo Using default port
25+ fi
1026
27+ # Check if $3 is set and not empty
28+ if [[ $# -ge 3 ]]; then
29+ DNS=$3
30+ else
31+ DNS=" 8.8.8.8"
32+ echo Using default DNS
33+ fi
1134# Generate client keys
1235CLIENT_PRIVATE_KEY=$( wg genkey)
1336CLIENT_PUBLIC_KEY=$( wg pubkey <<< " ${CLIENT_PRIVATE_KEY}" )
You can’t perform that action at this time.
0 commit comments