-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New features and scripts. Updated readme
- Loading branch information
LuisMalhadas
committed
Jul 20, 2023
1 parent
ce984d8
commit 19d4617
Showing
9 changed files
with
255 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
# Check if all three arguments are provided | ||
if [ $# -ne 3 ]; then | ||
echo "Usage: $0 [region country pair list] <username> <password>" | ||
exit 1 | ||
fi | ||
|
||
# Parse the IP range, country code, and credentials from arguments | ||
region_country_list=$1 | ||
username=$3 | ||
password=$4 | ||
|
||
# Run the getToken.sh script and store the output in a variable | ||
token_output=$(/opt/getToken.sh $username $password) | ||
|
||
# Extract the Bearer token using grep and cut | ||
bearer_token=$(echo "$token_output" | grep -o '"token":"Bearer[^"]*' | cut -d '"' -f 4) | ||
echo "Token: $bearer_token" | ||
|
||
# Read the region and country codes from the list into arrays | ||
mapfile -t regions_countries_array <<< "$region_country_list" | ||
|
||
# Loop to execute cURL commands for each IP in the range | ||
for ((i = 0; i < ${#regions_countries_array[@]}; i++)); do | ||
# Extract the region and country codes from the list | ||
current_pair=${regions_countries_array[i]} | ||
current_region=$(echo "$current_pair" | cut -d ' ' -f 1) | ||
current_country=$(echo "$current_pair" | cut -d ' ' -f 2) | ||
|
||
# Build the cURL request command | ||
curl_command="curl 'http://34.34.34.34/api/smartRoute/addTunnel' -X 'POST' -H 'Authorization: $bearer_token' --data-binary '{\"regionCode\":\"$current_region\",\"countryCode\":\"$current_country\"}' -H 'Content-Type: application/json'" | ||
|
||
# Print the cURL command to console | ||
echo "Executing cURL command: $curl_command" | ||
|
||
# Execute the cURL command | ||
eval "$curl_command" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
# Check if all three arguments are provided | ||
if [ $# -ne 3 ]; then | ||
echo "Usage: $0 [country list] <username> <password>" | ||
exit 1 | ||
fi | ||
|
||
# Parse the IP range, country code, and credentials from arguments | ||
country_list=$1 | ||
username=$2 | ||
password=$3 | ||
|
||
# Run the getToken.sh script and store the output in a variable | ||
token_output=$(/opt/getToken.sh $username $password) | ||
|
||
# Extract the Bearer token using grep and cut | ||
bearer_token=$(echo "$token_output" | grep -o '"token":"Bearer[^"]*' | cut -d '"' -f 4) | ||
echo "Token: $bearer_token" | ||
|
||
# Build the cURL request command | ||
curl_command="curl 'http://34.34.34.34/api/smartRoute/deleteTunnels' -X 'POST' -H 'Authorization: $bearer_token' --data-binary '[\""${country_list// /\",\"}"\"]' -H 'Content-Type: application/json'" | ||
|
||
# Print the cURL command to console | ||
echo "Executing cURL command: $curl_command" | ||
|
||
# Execute the cURL command | ||
eval "$curl_command" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
# Check if all three arguments are provided | ||
if [ $# -ne 2 ]; then | ||
echo "Usage: $0 <username> <password>" | ||
exit 1 | ||
fi | ||
|
||
# Parse the arguments | ||
username=$1 | ||
password=$2 | ||
|
||
# Run the getToken.sh script and store the output in a variable | ||
token_output=$(/opt/getToken.sh $username $password) | ||
|
||
# Extract the Bearer token using grep and cut | ||
bearer_token=$(echo "$token_output" | grep -o '"token":"Bearer[^"]*' | cut -d '"' -f 4) | ||
echo "Token: $bearer_token" | ||
|
||
# Build the cURL request command | ||
curl_command="curl 'http://34.34.34.34/api/smartRoute/getDeviceId' -X 'GET' -H 'Authorization: $bearer_token' -H 'Content-Type: application/json'" | ||
|
||
# Print the cURL command to console | ||
echo "Executing cURL command: $curl_command" | ||
|
||
# Execute the cURL command | ||
eval "$curl_command" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
# Check if all three arguments are provided | ||
if [ $# -ne 2 ]; then | ||
echo "Usage: $0 <username> <password>" | ||
exit 1 | ||
fi | ||
|
||
# Parse the arguments | ||
username=$1 | ||
password=$2 | ||
|
||
# Run the getToken.sh script and store the output in a variable | ||
token_output=$(/opt/getToken.sh $username $password) | ||
|
||
# Extract the Bearer token using grep and cut | ||
bearer_token=$(echo "$token_output" | grep -o '"token":"Bearer[^"]*' | cut -d '"' -f 4) | ||
echo "Token: $bearer_token" | ||
|
||
# Build the cURL request command | ||
curl_command="curl 'http://34.34.34.34/api/smartRoute/getDpnMode' -X 'GET' -H 'Authorization: $bearer_token' -H 'Content-Type: application/json'" | ||
|
||
# Print the cURL command to console | ||
echo "Executing cURL command: $curl_command" | ||
|
||
# Execute the cURL command | ||
eval "$curl_command" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
# Check if all three arguments are provided | ||
if [ $# -ne 2 ]; then | ||
echo "Usage: $0 <username> <password>" | ||
exit 1 | ||
fi | ||
|
||
# Parse the arguments | ||
username=$1 | ||
password=$2 | ||
|
||
# Run the getToken.sh script and store the output in a variable | ||
token_output=$(/opt/getToken.sh $username $password) | ||
|
||
# Extract the Bearer token using grep and cut | ||
bearer_token=$(echo "$token_output" | grep -o '"token":"Bearer[^"]*' | cut -d '"' -f 4) | ||
echo "Token: $bearer_token" | ||
|
||
# Build the cURL request command | ||
curl_command="curl 'http://34.34.34.34/api/smartRoute/listTunnels' -X 'GET' -H 'Authorization: $bearer_token' -H 'Content-Type: application/json'" | ||
|
||
# Print the cURL command to console | ||
echo "Executing cURL command: $curl_command" | ||
|
||
# Execute the cURL command | ||
eval "$curl_command" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
# Check if all three arguments are provided | ||
if [ $# -lt 3 ]; then | ||
echo "Usage: $0 <Mode> <username> <password> \n if mode is full specify tunnel code: $0 <Mode> <tunnelCode> <username> <password> \n Note: Killswitch is alsways false for now." | ||
exit 1 | ||
fi | ||
|
||
# Parse the arguments | ||
mode=$1 | ||
if [ "$mode" == "full" ]; then | ||
tunnel=$2 | ||
username=$3 | ||
password=$4 | ||
else | ||
username=$2 | ||
password=$3 | ||
fi | ||
|
||
# Run the getToken.sh script and store the output in a variable | ||
token_output=$(/opt/getToken.sh $username $password) | ||
|
||
# Extract the Bearer token using grep and cut | ||
bearer_token=$(echo "$token_output" | grep -o '"token":"Bearer[^"]*' | cut -d '"' -f 4) | ||
echo "Token: $bearer_token" | ||
|
||
# Build the cURL request command | ||
if [ "$mode" == "full" ]; then | ||
curl_command="curl 'http://34.34.34.34/api/smartRoute/setDpnMode' -X 'POST' -H 'Authorization: $bearer_token' --data-binary '{\"dpnMode\":\"$mode\",\"tunnelCode\":\"$tunnel\",\"killSwitch\":false}' -H 'Content-Type: application/json'" | ||
else | ||
curl_command="curl 'http://34.34.34.34/api/smartRoute/setDpnMode' -X 'POST' -H 'Authorization: $bearer_token' --data-binary '{\"dpnMode\":\"$mode\"}' -H 'Content-Type: application/json'" | ||
fi | ||
|
||
# Print the cURL command to console | ||
echo "Executing cURL command: $curl_command" | ||
|
||
# Execute the cURL command | ||
eval "$curl_command" |