Skip to content

Commit

Permalink
[Feat] DNS Record can be automatically created, without manual record…
Browse files Browse the repository at this point in the history
… creation in advanced. (#6)

* [Feat] Record auto-creation implementation

If script detects given record name has not been created,
it will automatically POST to cf v4 api to create, then
prompt the user.

Tests should follow.

* [Bug] Minor Typo on function create4RecordIfNotExists

Provide `hostIp` as param for function create4RecordIfNotExists.
Solved.

* [Enhancement] Code Clean-up and Follow google shell style.

Info and error message are both handled by shell functions,
rather than echo everywhere and pipes it to stderr.

Global variables were renamed following STYLE_GUIDELINE.

Function variables were renamed following snake_case.

Other code clean-ups, and guideline following.

* [Bug,Enhancement] Typo causes NULL var

Fix where GLOBAL_VARIABLES' names alterd in `cloudflare-ddns` but
stay the same in `cfddns.sh`, which leads to NULL var.

if statements use `[[]]` instead of `[]`.

* [Bug] Record update will occur when HostIp==RecordIp

fixed.

* [Doc,Enhancement] Function comment & file header updated.

Some variables were declared `readonly` for more development-friendly
design.

Function comment and documentation links updated.

`set -o errexit` added.

* [Bug,Doc] `errexit` results in unexpected exit.

Removal of `set -e`, which is short for `set -o errexit`.

Comment & Documentation updated.
  • Loading branch information
MijazzChan authored Mar 1, 2022
1 parent bd623c7 commit 84dd187
Show file tree
Hide file tree
Showing 2 changed files with 215 additions and 100 deletions.
25 changes: 13 additions & 12 deletions cfddns.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
#!/bin/sh

#!/bin/bash
#
# Entrance File and Config File for cloudflare-ddns.

# Import utility function here
# You `cloudflare-ddns` file ABSOLUTE PATH here!
. /config/scripts/cloudflare-ddns-edgeos/cloudflare-ddns

########
# Alter here
########
#######################
# -Config- Alter here #
#######################

# Access Token generated from Cloudflare API token page
access_token=""
CF_ACCESS_TOKEN=""

# Can be seen from your zone page, bottom right Zone id
zone_identifier=""
ZONE_IDENTIFIER=""

# You DNS record name, with A subdomain
record_name=""
RECORD_NAME=""


########
# Alter stops
########
#######################
# -Config- Stop here #
#######################

updateMain
main
Loading

0 comments on commit 84dd187

Please sign in to comment.