3 ## Infoblox API integration by Jason Keller and Elijah Tenai
5 ## Report any bugs via https://github.com/jasonkeller/acme.sh
9 ## Nothing to see here, just some housekeeping
12 baseurlnObject
="https://$Infoblox_Server/wapi/v2.2.2/record:txt?name=$fulldomain&text=$txtvalue&view=$Infoblox_View"
14 _info
"Using Infoblox API"
15 _debug fulldomain
"$fulldomain"
16 _debug txtvalue
"$txtvalue"
18 ## Check for the credentials
19 if [ -z "$Infoblox_Creds" ] ||
[ -z "$Infoblox_Server" ]; then
22 _err
"You didn't specify the credentials, server or infoblox view yet (Infoblox_Creds, Infoblox_Server and Infoblox_View)."
23 _err
"Please set them via EXPORT ([username:password], [ip or hostname]) and try again."
27 if [ -z "$Infoblox_View" ]; then
28 Infoblox_View
="default"
31 ## Save the credentials to the account file
32 _saveaccountconf Infoblox_Creds
"$Infoblox_Creds"
33 _saveaccountconf Infoblox_Server
"$Infoblox_Server"
35 ## Base64 encode the credentials
36 Infoblox_CredsEncoded
=$
(printf "%b" "$Infoblox_Creds" | _base64
)
38 ## Construct the HTTP Authorization header
39 export _H1
="Accept-Language:en-US"
40 export _H2
="Authorization: Basic $Infoblox_CredsEncoded"
42 ## Add the challenge record to the Infoblox grid member
43 result
=$
(_post
"" "$baseurlnObject" "" "POST")
45 ## Let's see if we get something intelligible back from the unit
46 if echo "$result" |
egrep "record:txt/.*:.*/${Infoblox_View}"; then
47 _info
"Successfully created the txt record"
50 _err
"Error encountered during record addition"
59 ## Nothing to see here, just some housekeeping
63 _info
"Using Infoblox API"
64 _debug fulldomain
"$fulldomain"
65 _debug txtvalue
"$txtvalue"
67 ## Base64 encode the credentials
68 Infoblox_CredsEncoded
=$
(printf "%b" "$Infoblox_Creds" | _base64
)
70 ## Construct the HTTP Authorization header
71 export _H1
="Accept-Language:en-US"
72 export _H2
="Authorization: Basic $Infoblox_CredsEncoded"
74 ## Does the record exist? Let's check.
75 baseurlnObject
="https://$Infoblox_Server/wapi/v2.2.2/record:txt?name=$fulldomain&text=$txtvalue&view=$Infoblox_View&_return_type=xml-pretty"
76 result
=$
(_get
"$baseurlnObject")
78 ## Let's see if we get something intelligible back from the grid
79 if echo "$result" |
egrep 'record:txt/.*:.*/default'; then
80 ## Extract the object reference
81 objRef
=$
(printf "%b" "$result" | _egrep_o
"record:txt/.*:.*/${Infoblox_View}")
82 objRmUrl
="https://$Infoblox_Server/wapi/v2.2.2/$objRef"
83 ## Delete them! All the stale records!
84 rmResult
=$
(_post
"" "$objRmUrl" "" "DELETE")
85 ## Let's see if that worked
86 if echo "$rmResult" |
egrep "record:txt/.*:.*/${Infoblox_View}"; then
87 _info
"Successfully deleted $objRef"
90 _err
"Error occurred during txt record delete"
95 _err
"Record to delete didn't match an existing record"
101 #################### Private functions below ##################################