-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add script for facileManager DNS API client #6173
Open
gianlucagiacometti
wants to merge
7
commits into
acmesh-official:dev
Choose a base branch
from
gianlucagiacometti:master
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3d98c92
Create dns_fmdns.sh
gianlucagiacometti dbb4666
Update dns_fmdns.sh
gianlucagiacometti 15af878
Update dns_fmdns.sh
gianlucagiacometti 12fc118
Update dns_fmdns.sh
gianlucagiacometti 891daef
Update dns_fmdns.sh
gianlucagiacometti 38aa869
Update dns_fmdns.sh
gianlucagiacometti b629e26
Fix info
gianlucagiacometti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
#!/usr/bin/env sh | ||
|
||
# | ||
# facileManager (https://github.com/WillyXJ/facileManager) hook script for acme.sh | ||
# | ||
# Author: Gianluca Giacometti | ||
# Git repo and usage: https://github.com/gianlucagiacometti/proxmox-acme-facilemanager | ||
# | ||
|
||
# Values to export: | ||
# export FMDNS_API_ENDPOINT='https://my.fmdnsapi.endpoint' | ||
# export FMDNS_API_TOKEN='xxxxx' | ||
# export FMDNS_API_DOMAIN_ID='xxxxx' | ||
|
||
# IMPORTANT NOTE: set the validation delay at a minimum value of 360s, since facileManager usually updates dns zones every 300s | ||
|
||
##################### Public functions ##################### | ||
|
||
dns_fmdns_add() { | ||
fulldomain="${1}" | ||
txtvalue="${2}" | ||
|
||
FMDNS_API_TOKEN="${FMDNS_API_TOKEN:-$(_readaccountconf_mutable FMDNS_API_TOKEN)}" | ||
# Check if API token exists | ||
if [ -z "$FMDNS_API_TOKEN" ]; then | ||
FMDNS_API_TOKEN="" | ||
_err "You did not specify facileManager API token." | ||
_err "Please export FMDNS_API_TOKEN and try again." | ||
return 1 | ||
fi | ||
|
||
FMDNS_API_ENDPOINT="${FMDNS_API_ENDPOINT:-$(_readaccountconf_mutable FMDNS_API_ENDPOINT)}" | ||
# Check if API endpoint exists | ||
if [ -z "$FMDNS_API_ENDPOINT" ]; then | ||
FMDNS_API_ENDPOINT="" | ||
_err "You did not specify facileManager API endpoint." | ||
_err "Please export FMDNS_API_ENDPOINT and try again." | ||
return 1 | ||
fi | ||
|
||
FMDNS_API_DOMAIN_ID="${FMDNS_API_DOMAIN_ID:-$(_readaccountconf_mutable FMDNS_API_DOMAIN_ID)}" | ||
# Check if API domain id exists | ||
if [ -z "$FMDNS_API_DOMAIN_ID" ]; then | ||
FMDNS_API_DOMAIN_ID="" | ||
_err "You did not specify facileManager API domain id." | ||
_err "Please export FMDNS_API_DOMAIN_ID and try again." | ||
return 1 | ||
fi | ||
|
||
_debug "Calling: _fmDnsApi_addRecord() '${fulldomain}' '${txtvalue}'" | ||
_fmDnsApi_addRecord | ||
return $? | ||
} | ||
|
||
dns_fmdns_rm() { | ||
fulldomain="${1}" | ||
txtvalue="${2}" | ||
|
||
FMDNS_API_TOKEN="${FMDNS_API_TOKEN:-$(_readaccountconf_mutable FMDNS_API_TOKEN)}" | ||
# Check if API token exists | ||
if [ -z "$FMDNS_API_TOKEN" ]; then | ||
FMDNS_API_TOKEN="" | ||
_err "You did not specify facileManager API token." | ||
_err "Please export FMDNS_API_TOKEN and try again." | ||
return 1 | ||
fi | ||
|
||
FMDNS_API_ENDPOINT="${FMDNS_API_ENDPOINT:-$(_readaccountconf_mutable FMDNS_API_ENDPOINT)}" | ||
# Check if API endpoint exists | ||
if [ -z "$FMDNS_API_ENDPOINT" ]; then | ||
FMDNS_API_ENDPOINT="" | ||
_err "You did not specify facileManager API endpoint." | ||
_err "Please export FMDNS_API_ENDPOINT and try again." | ||
return 1 | ||
fi | ||
|
||
FMDNS_API_DOMAIN_ID="${FMDNS_API_DOMAIN_ID:-$(_readaccountconf_mutable FMDNS_API_DOMAIN_ID)}" | ||
# Check if API domain id exists | ||
if [ -z "$FMDNS_API_DOMAIN_ID" ]; then | ||
FMDNS_API_DOMAIN_ID="" | ||
_err "You did not specify facileManager API domain id." | ||
_err "Please export FMDNS_API_DOMAIN_ID and try again." | ||
return 1 | ||
fi | ||
|
||
_debug "Calling: _fmDnsApi_removeRecord() '${fulldomain}' '${txtvalue}'" | ||
_fmDnsApi_removeRecord | ||
return $? | ||
} | ||
|
||
##################### Private functions ##################### | ||
|
||
_fmDnsApi_addRecord() { | ||
_info "Connecting to ${FMDNS_API_ENDPOINT}" | ||
_info "Adding record to zone" | ||
curData="{\"fmAuthToken\":\"${FMDNS_API_TOKEN}\",\"id\":\"${FMDNS_API_DOMAIN_ID}\",\"action\":\"add\",\"name\":\"${fulldomain}\",\"value\":\"${txtvalue}\",\"type\":\"TXT\",\"ttl\":\"5\",\"autoupdate\":\"yes\"}" | ||
curResult="$(_post "${curData}" "${FMDNS_API_ENDPOINT}")" | ||
_info "API result: "${curResult}"" | ||
_debug "Calling facileManager API: '${curData}' '${FMDNS_API_ENDPOINT}'" | ||
_debug "Result of zone add: '$curResult'" | ||
if [ "${curResult}" != "Success" ]; then | ||
if [ -z "${curResult}" ]; then | ||
_err "Empty response" | ||
else | ||
_err "${curResult}" | ||
fi | ||
return 1 | ||
fi | ||
return 0 | ||
} | ||
|
||
_fmDnsApi_removeRecord() { | ||
_info "Connecting to ${FMDNS_API_ENDPOINT}" | ||
_info "Removing record from zone" | ||
curData="{\"fmAuthToken\":\"${FMDNS_API_TOKEN}\",\"id\":\"${FMDNS_API_DOMAIN_ID}\",\"action\":\"delete\",\"name\":\"${fulldomain}\",\"type\":\"TXT\",\"ttl\":\"5\",\"autoupdate\":\"yes\"}" | ||
curResult="$(_post "${curData}" "${FMDNS_API_ENDPOINT}")" | ||
_info "API result: "${curResult}"" | ||
_debug "Calling facileManager API: '${curData}' '${FMDNS_API_ENDPOINT}'" | ||
_debug "Result of zone delete: '$curResult'" | ||
if [ "${curResult}" != "Success" ]; then | ||
if [ -z "${curResult}" ]; then | ||
_err "Empty response" | ||
else | ||
_err "${curResult}" | ||
fi | ||
return 1 | ||
fi | ||
return 0 | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please convert the options list to a structural info description
https://github.com/acmesh-official/acme.sh/wiki/DNS-API-Structural-Info-description
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I converted the options according to the docs. I will create the documentation in the acmesh-official wiki as required, as soon as the pull request is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I corrected the double double quotes which prevented spellcheck to succeed