-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudflare.sh
82 lines (72 loc) · 1.79 KB
/
cloudflare.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
# Wrapper for the Cloudflare C Program
PROGRAM="./cloudflare" # Path to the compiled C program
function list_zones() {
echo "Fetching zones..."
$PROGRAM list_zones
}
function add_update_record() {
echo "Enter Zone ID:"
read -r zone_id
echo "Enter Record Type (e.g., A, AAAA, CNAME):"
read -r record_type
echo "Enter Record Name (e.g., example.com):"
read -r record_name
echo "Enter Record Content (e.g., 192.0.2.1):"
read -r record_content
echo "Enter TTL (e.g., 3600):"
read -r ttl
echo "Enable Proxy? (1 for yes, 0 for no):"
read -r proxied
echo "Adding/Updating record..."
$PROGRAM add_update_record "$zone_id" "$record_type" "$record_name" "$record_content" "$ttl" "$proxied"
}
function delete_record() {
echo "Enter Zone ID:"
read -r zone_id
echo "Enter Record ID:"
read -r record_id
echo "Deleting record..."
$PROGRAM delete_record "$zone_id" "$record_id"
}
function purge_cache() {
echo "Enter Zone ID:"
read -r zone_id
echo "Purging cache..."
$PROGRAM purge_cache "$zone_id"
}
# Main menu
while true; do
echo ""
echo "Cloudflare Management Script"
echo "============================"
echo "1) List Zones"
echo "2) Add/Update DNS Record"
echo "3) Delete DNS Record"
echo "4) Purge Cache"
echo "5) Exit"
echo ""
echo -n "Choose an option: "
read -r option
case $option in
1)
list_zones
;;
2)
add_update_record
;;
3)
delete_record
;;
4)
purge_cache
;;
5)
echo "Exiting. Goodbye!"
exit 0
;;
*)
echo "Invalid option. Please try again."
;;
esac
done