Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Ladutko_Sergey/3/1addDNS.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
###find arya.ns.cloudflare.com###
if cat ./test.txt | grep arya.ns.cloudflare.com > /dev/null
then
echo "The record arya.ns.cloudflare.com already exists"
else
echo "arya.ns.cloudflare.com" >> ./test.txt
echo "The record arya.ns.cloudflare.com add"
fi

###find nchance.ns.cloudflare.com###
if cat ./test.txt | grep nchance.ns.cloudflare.com > /dev/null
then
echo "The record nchance.ns.cloudflare.com already exists"
else
echo "nchance.ns.cloudflare.com" >> ./test.txt
echo "The record nchance.ns.cloudflare.com add"
fi
25 changes: 25 additions & 0 deletions Ladutko_Sergey/3/2checkclaudflore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
MY_TOCKEN=
IP=
if curl -X POST "https://api.cloudflare.com/client/v4/zones/ea1dc8f4bcbaa356fd80978d23989450/dns_records" \
-H "Authorization: Bearer $MY_TOCKEN" \
-H "Content-Type: application/json" \
--data '{"type":"A","name":"homework.sergeyladutko.xyz","content":"'"$IP"'","ttl":120,"priority":10,"proxied":true}' | grep -w "The record already exists" >> /dev/null
then
echo "The record already exists"
else
echo "create dns records in cloudflare.com"
fi
############CHECKIP###################
if curl -X GET "https://api.cloudflare.com/client/v4/zones/ea1dc8f4bcbaa356fd80978d23989450/dns_records?type=A&name=homework.sergeyladutko.xyz&content=136.243.91.3&page=1&per_page=20&order=type&direction=desc&match=all" \
-H "Authorization: Bearer OgeV_r5CwiDT2IYzkZNsZLXmBJz8F3diW4zaKLcr" \
-H "Content-Type: application/json" | grep -w $IP >> /dev/null
then
echo "The record is valid and ready to go"
else
curl -X PUT "https://api.cloudflare.com/client/v4/zones/ea1dc8f4bcbaa356fd80978d23989450/dns_records/13084c7f88d2e43c8fc5c4fd4c12e183" \
-H "Authorization: Bearer OgeV_r5CwiDT2IYzkZNsZLXmBJz8F3diW4zaKLcr" \
-H "Authorization: Bearer $MY_TOCKEN" \
--data '{"type":"A","name":"homework.sergeyladutko.xyz","content":"'"$IP"'","ttl":120,"priority":10,"proxied":true}'
echo "The record is update"
fi
15 changes: 15 additions & 0 deletions Ladutko_Sergey/3/3claudflorefunction.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -o errexit
set -o nounset
DNS_NAME=$1
IP=$2
create_dns_record() {
curl -X POST "https://api.cloudflare.com/client/v4/zones/ea1dc8f4bcbaa356fd80978d23989450/dns_records" \
-H "Authorization: Bearer OgeV_r5CwiDT2IYzkZNsZLXmBJz8F3diW4zaKLcr" \
-H "Content-Type: application/json" \
--data '{"type":"A","name":"'"$DNS_NAME"'","content":"'"$IP"'","ttl":120,"priority":10,"proxied":true}'

}

create_dns_record
9 changes: 9 additions & 0 deletions Ladutko_Sergey/3/4dns.services
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Create DNS demon

[Service]
Type=idle
ExecStart=/home/sergey/HOMEWORK/Hometask3/checkclaudflore.sh

[Install]
WantedBy=multi-user.target