22 lines
749 B
Bash
22 lines
749 B
Bash
#!/bin/bash
|
|
# AstroCom Dynamic IP Update Script
|
|
# Gets current public IP from https://myip.wtf/text and posts it to the AstroCom API
|
|
# Requires: curl
|
|
|
|
# Configuration
|
|
API_KEY="your_api_key_here" # Replace with your AstroCom API Key!
|
|
|
|
|
|
|
|
# Get current IP
|
|
CURRENT_IP=$(curl -s https://myip.wtf/text)
|
|
if [[ -z "$CURRENT_IP" ]]; then
|
|
echo "Failed to retrieve current IP address."
|
|
exit 1
|
|
fi
|
|
echo "Current IP: $CURRENT_IP"
|
|
# Update IP via AstroCom API PATCH https://astrocom.tel/api/v1/user/update; JSON body: {"server": "current_ip"}
|
|
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -X PATCH https://astrocom.tel/api/v1/user/update \
|
|
-H "Content-Type: application/json" \
|
|
-H "Authorization: Bearer $API_KEY" \
|
|
-d "{\"server\": \"$CURRENT_IP\"}" |