mirror of
https://github.com/tiennm99/MTTools.git
synced 2026-10-04 13:01:11 +00:00
Update main.sh
This commit is contained in:
1 parent
6aa89eaef7
commit
782ee8045d
1 file changed
+14
-6
+14
-6
@@ -18,14 +18,22 @@ update_record() {
|
||||
-H "Content-Type: application/json" | jq -r '.result[0].id')
|
||||
|
||||
if [ -n "$record_id" ]; then
|
||||
curl -sX PUT "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$record_id" \
|
||||
-H "X-Auth-Email: $CF_EMAIL" \
|
||||
-H "Authorization: Bearer $CF_API_KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data "{\"type\":\"A\",\"name\":\"$record\",\"content\":\"$CURRENT_IP\"}"
|
||||
curl --request PUT \
|
||||
--url https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$record_id \
|
||||
--header 'Content-Type: application/json' \
|
||||
--header "X-Auth-Email: $CF_EMAIL" \
|
||||
--header "Authorization: Bearer $CF_API_KEY" \
|
||||
--data "{\"content\":\"$CURRENT_IP\",\"name\":\"$record\",\"proxied\":false,\"type\":\"A\",\"ttl\":3600}"
|
||||
echo "Updated $record to $CURRENT_IP"
|
||||
else
|
||||
echo "Error: $record not found"
|
||||
echo "No A record found for $record, creating a new one"
|
||||
curl --request POST \
|
||||
--url https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records \
|
||||
--header 'Content-Type: application/json' \
|
||||
--header "X-Auth-Email: $CF_EMAIL" \
|
||||
--header "Authorization: Bearer $CF_API_KEY" \
|
||||
--data "{\"content\":\"$CURRENT_IP\",\"name\":\"$record\",\"proxied\":false,\"type\":\"A\",\"ttl\":3600}"
|
||||
echo "Created A record for $record with IP $CURRENT_IP"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user