Merge pull request #1537 from gravitl/feature_v0.15.1_vpn_scripts

Feature v0.15.1 vpn scripts
This commit is contained in:
Alex Feiszli 2022-09-12 11:45:01 -04:00 committed by GitHub
commit 83bba03d16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -230,7 +230,7 @@ echo "Netmaker setup is now complete. You are ready to begin using Netmaker."
setup_vpn() {( set -e setup_vpn() {( set -e
echo "creating vpn network (10.201.0.0/16)" echo "creating vpn network (10.201.0.0/16)"
curl -s -o /dev/null -d '{"addressrange":"10.201.0.0/16","netid":"vpn","defaultextclientdns":"8.8.8.8"}' -H "Authorization: Bearer $MASTER_KEY" -H 'Content-Type: application/json' https://api.${NETMAKER_BASE_DOMAIN}/api/networks curl -s -o /dev/null -d '{"addressrange":"10.201.0.0/16","netid":"vpn","defaultextclientdns":"10.201.255.254"}' -H "Authorization: Bearer $MASTER_KEY" -H 'Content-Type: application/json' https://api.${NETMAKER_BASE_DOMAIN}/api/networks
sleep 5 sleep 5
@ -241,9 +241,9 @@ SERVER_ID=$(jq -r '.[0].id' <<< ${curlresponse})
curl -s -o /dev/null -X POST -H "Authorization: Bearer $MASTER_KEY" -H 'Content-Type: application/json' https://api.${NETMAKER_BASE_DOMAIN}/api/nodes/vpn/$SERVER_ID/createingress curl -s -o /dev/null -X POST -H "Authorization: Bearer $MASTER_KEY" -H 'Content-Type: application/json' https://api.${NETMAKER_BASE_DOMAIN}/api/nodes/vpn/$SERVER_ID/createingress
echo "waiting 10 seconds for server to apply configuration..." echo "waiting 5 seconds for server to apply configuration..."
sleep 10 sleep 5
echo "configuring netmaker server vpn gateway..." echo "configuring netmaker server vpn gateway..."
@ -257,11 +257,13 @@ SERVER_ID=$(jq -r '.[0].id' <<< ${curlresponse})
EGRESS_JSON=$( jq -n \ EGRESS_JSON=$( jq -n \
--arg gw "$GATEWAY_IFACE" \ --arg gw "$GATEWAY_IFACE" \
'{ranges: ["0.0.0.0/0","::/0"], interface: $gw}' ) '{ranges: ["0.0.0.0/0"], interface: $gw}' )
echo "egress json: $EGRESS_JSON" echo "egress json: $EGRESS_JSON"
curl -s -o /dev/null -X POST -d "$EGRESS_JSON" -H "Authorization: Bearer $MASTER_KEY" -H 'Content-Type: application/json' https://api.${NETMAKER_BASE_DOMAIN}/api/nodes/vpn/$SERVER_ID/creategateway curl -s -o /dev/null -X POST -d "$EGRESS_JSON" -H "Authorization: Bearer $MASTER_KEY" -H 'Content-Type: application/json' https://api.${NETMAKER_BASE_DOMAIN}/api/nodes/vpn/$SERVER_ID/creategateway
sleep 3
echo "creating client configs..." echo "creating client configs..."
for ((a=1; a <= $NUM_CLIENTS; a++)) for ((a=1; a <= $NUM_CLIENTS; a++))
@ -271,6 +273,7 @@ do
'{clientid: $clientid}' ) '{clientid: $clientid}' )
curl -s -o /dev/null -d "$CLIENT_JSON" -H "Authorization: Bearer $MASTER_KEY" -H 'Content-Type: application/json' https://api.${NETMAKER_BASE_DOMAIN}/api/extclients/vpn/$SERVER_ID curl -s -o /dev/null -d "$CLIENT_JSON" -H "Authorization: Bearer $MASTER_KEY" -H 'Content-Type: application/json' https://api.${NETMAKER_BASE_DOMAIN}/api/extclients/vpn/$SERVER_ID
sleep 2
done done
echo "finished configuring vpn server." echo "finished configuring vpn server."