Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
NavyStack committed Feb 3, 2024
1 parent f35cfb2 commit ed0ed86
Show file tree
Hide file tree
Showing 15 changed files with 389 additions and 977 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/Update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,43 @@ jobs:
with:
commit_message: "[BOT] [OCI] changes - ${{ steps.oracle-extract-timestamp.outputs.oracle_utc }}"
push_options: '--force'

- name: Run Azure Script
run: |
chmod +x ./microsoft-azure/start.sh
./microsoft-azure/start.sh
- name: Extract Timestamp from File (Azure)
id: azure-extract-timestamp
run: echo "azure_utc=$(<./microsoft-azure/timestamp.txt)" >> "$GITHUB_OUTPUT"

- name: Git Auto Commit (Azure)
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "[BOT] [Azure] changes - ${{ steps.azure-extract-timestamp.outputs.azure_utc }}"
push_options: '--force'

- name: Run Github Script
run: |
chmod +x ./github/start.sh
./github/start.sh
- name: Extract Timestamp from File (Github)
id: github-extract-timestamp
run: echo "github_utc=$(<./github/timestamp.txt)" >> "$GITHUB_OUTPUT"

- name: Git Auto Commit (Github)
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "[BOT] [Github] changes - ${{ steps.github-extract-timestamp.outputs.github_utc }}"
push_options: '--force'

- name: Extract Timestamp from File (Cloudflare)
id: cloudflare-extract-timestamp
run: echo "cloudflare_utc=$(<./cloudflare/timestamp.txt)" >> "$GITHUB_OUTPUT"

- name: Git Auto Commit (Cloudflare)
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "[BOT] [Cloudflare] changes - ${{ steps.cloudflare-extract-timestamp.outputs.cloudflare_utc }}"
push_options: '--force'
59 changes: 59 additions & 0 deletions amazon/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

# https://docs.aws.amazon.com/general/latest/gr/aws-ip-ranges.html

set -euo pipefail
set -x

# Define file paths
json_file="/tmp/amazon.json"
timestamp_file="amazon/timestamp.txt"
ipv4_file="/tmp/amazon-ipv4.txt"
ipv6_file="/tmp/amazon-ipv6.txt"
ipv4_output="amazon/ipv4.txt"
ipv6_output="amazon/ipv6.txt"

# get from public ranges
if curl -s https://ip-ranges.amazonaws.com/ip-ranges.json > "$json_file"; then
echo "AWS IP ranges fetched successfully."
else
echo "Error: Failed to fetch AWS IP ranges." >&2
exit 1
fi

# Extract "createDate" value
create_date=$(jq -r '.createDate' "$json_file")

# Save "createDate" value to file
echo "$create_date" > "$timestamp_file"

# save ipv4
if jq '.prefixes[] | [.ip_prefix][] | select(. != null)' -r "$json_file" > "$ipv4_file"; then
echo "AWS IPv4 addresses saved successfully."
else
echo "Error: Failed to save AWS IPv4 addresses." >&2
exit 1
fi

# save ipv6
if jq '.ipv6_prefixes[] | [.ipv6_prefix][] | select(. != null)' -r "$json_file" > "$ipv6_file"; then
echo "AWS IPv6 addresses saved successfully."
else
echo "Error: Failed to save AWS IPv6 addresses." >&2
exit 1
fi

# sort & uniq
if sort -V "$ipv4_file" | uniq > "$ipv4_output"; then
echo "AWS IPv4 addresses sorted and duplicates removed successfully."
else
echo "Error: Failed to sort AWS IPv4 addresses." >&2
exit 1
fi

if sort -V "$ipv6_file" | uniq > "$ipv6_output"; then
echo "AWS IPv6 addresses sorted and duplicates removed successfully."
else
echo "Error: Failed to sort AWS IPv6 addresses." >&2
exit 1
fi
74 changes: 74 additions & 0 deletions cloudflare/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash
# https://www.cloudflare.com/ips/

# Define file paths
timestamp_file="cloudflare/timestamp.txt"

ipv4_file="/tmp/cf-ipv4.txt"
ipv4_output="cloudflare/ipv4.txt"
ipv4_comma_output="cloudflare/ipv4_comma.txt"

ipv6_file="/tmp/cf-ipv6.txt"
ipv6_output="cloudflare/ipv6.txt"
ipv6_comma_output="cloudflare/ipv6_comma.txt"

# Check if the timestamp_file exists and remove it if it does
if [ -e "$timestamp_file" ]; then
rm "$timestamp_file"
echo "Step 0: File $timestamp_file removed successfully."
else
echo "Step 0: File $timestamp_file does not exist. Skip."
fi

# get from public ranges
if curl -s https://www.cloudflare.com/ips-v4/ > "$ipv4_file"; then
echo "IPv4 addresses fetched successfully."
else
echo "Error: Failed to fetch IPv4 addresses." >&2
exit 1
fi

if curl -s https://www.cloudflare.com/ips-v6/ > "$ipv6_file"; then
echo "IPv6 addresses fetched successfully."
else
echo "Error: Failed to fetch IPv6 addresses." >&2
exit 1
fi

# sort & uniq
if sort -V "$ipv4_file" | uniq > "$ipv4_output"; then
echo "IPv4 addresses sorted and duplicates removed successfully."
else
echo "Error: Failed to sort IPv4 addresses." >&2
exit 1
fi

if sort -V "$ipv6_file" | uniq > "$ipv6_output"; then
echo "IPv6 addresses sorted and duplicates removed successfully."
else
echo "Error: Failed to sort IPv6 addresses." >&2
exit 1
fi

# Save IPv4 addresses with comma separation
if paste -sd "," "$ipv4_output" > "$ipv4_comma_output"; then
echo "IPv4 addresses saved with comma separation successfully."
else
echo "Error: Failed to save IPv4 addresses with comma separation." >&2
exit 1
fi

# Save IPv6 addresses with comma separation
if paste -sd "," "$ipv6_output" > "$ipv6_comma_output"; then
echo "IPv6 addresses saved with comma separation successfully."
else
echo "Error: Failed to save IPv6 addresses with comma separation." >&2
exit 1
fi

# Step 5: Save timestamp to the timestamp file
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%S.000000Z")
echo "$timestamp" > "$timestamp_file"
echo "Step 5: Timestamp saved successfully."

echo "Cloudflare Complete!"
67 changes: 67 additions & 0 deletions github/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

set -euo pipefail
set -x

# Define file paths
json_file="/tmp/github.json"
timestamp_file="github/timestamp.txt"

github_all_txt="/tmp/github-all.txt"

github_ipv4_txt="github/ipv4.txt"
github_ipv6_txt="github/ipv6.txt"

# Check if the timestamp_file exists and remove it if it does
if [ -e "$timestamp_file" ]; then
rm "$timestamp_file"
echo "Step 0: File $timestamp_file removed successfully."
else
echo "Step 0: File $timestamp_file does not exist. Skip."
fi

# Step 1: Fetch data from GitHub API with error handling
if curl -s https://api.github.com/meta > "$json_file"; then
echo "Step 1: Data fetched from GitHub API successfully."
else
echo "Step 1: Unable to fetch data from GitHub API." >&2
exit 1
fi

# Step 2: Extract data without specified keys and flatten the structure
filtered_data=$(jq '
with_entries(
select(
.key | . != "ssh_keys" and
. != "verifiable_password_authentication" and
. != "ssh_key_fingerprints" and
. != "domains"
)
) | .[] | .[]
' -r "$json_file")

# Save the filtered data to the github_all_txt file
echo "$filtered_data" > "$github_all_txt"

# Step 3: Save IPv4 addresses
if grep -v ':' "$github_all_txt" | sort -V | uniq > "$github_ipv4_txt"; then
echo "Step 3: IPv4 addresses saved successfully."
else
echo "Step 3: Failed to save IPv4 addresses." >&2
exit 1
fi

# Step 4: Save IPv6 addresses
if grep ':' "$github_all_txt" | sort -V | uniq > "$github_ipv6_txt"; then
echo "Step 4: IPv6 addresses saved successfully."
else
echo "Step 3: Failed to save IPv6 addresses." >&2
exit 1
fi

# Step 5: Save timestamp to the timestamp file
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%S.000000Z")
echo "$timestamp" > "$timestamp_file"
echo "Step 5: Timestamp saved successfully."

echo "Github Complete!"
128 changes: 0 additions & 128 deletions googlebot/ipv4.txt

This file was deleted.

1 change: 0 additions & 1 deletion googlebot/ipv4_comma.txt

This file was deleted.

Loading

0 comments on commit ed0ed86

Please sign in to comment.