Compare commits
No commits in common. "572a2407d090ac29e361b0d9a3db0e82104a9f9c" and "0b7671f8329afc41b8aa5faed65645ccfe60deb6" have entirely different histories.
572a2407d0
...
0b7671f832
3 changed files with 26 additions and 6 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
#!rsc by RouterOS
|
#!rsc by RouterOS
|
||||||
# RouterOS script: ddns-hetzner
|
# RouterOS script: ddns-hetzner
|
||||||
# Version 2.0.2
|
# Version 2.0.1
|
||||||
# Copyright (c) 2024-2026 Philip 'ShokiNN' Henning <mail@philip-henning.com>
|
# Copyright (c) 2024-2026 Philip 'ShokiNN' Henning <mail@philip-henning.com>
|
||||||
# https://git.s1q.dev/phg/routeros-scripts-custom/about/COPYING.md
|
# https://git.s1q.dev/phg/routeros-scripts-custom/about/COPYING.md
|
||||||
#
|
#
|
||||||
|
|
@ -48,8 +48,10 @@ onerror Err {
|
||||||
|
|
||||||
:onerror GetAnnouncedIPErr in={
|
:onerror GetAnnouncedIPErr in={
|
||||||
$LogPrint debug $ScriptName ("GetAnnouncedIP - started");
|
$LogPrint debug $ScriptName ("GetAnnouncedIP - started");
|
||||||
|
[/system/script/run "JParseFunctions"; global JSONLoad; global JSONLoads; global JSONUnload];
|
||||||
|
$LogPrint debug $ScriptName ("GetAnnouncedIP - JParseFunctions loaded");
|
||||||
|
|
||||||
:set Records ([:deserialize from=json ([/tool/fetch "$APIUrl/zones/$ZoneName/rrsets/$RecordName/$RecordType" http-method=get http-header-field="Authorization: Bearer $APIToken" output=user as-value]->"data")]->"rrset"->"records");
|
:set Records ([$JSONLoads ([/tool/fetch "$APIUrl/zones/$ZoneName/rrsets/$RecordName/$RecordType" http-method=get http-header-field="Authorization: Bearer $APIToken" output=user as-value]->"data")]->"rrset"->"records");
|
||||||
$LogPrint debug $ScriptName ("GetAnnouncedIP - Records received: " . [:len $Records]);
|
$LogPrint debug $ScriptName ("GetAnnouncedIP - Records received: " . [:len $Records]);
|
||||||
foreach rec in=$Records do={
|
foreach rec in=$Records do={
|
||||||
$LogPrint debug $ScriptName ("GetAnnouncedIP - Record: Name: \"" . $RecordName . "\", Type: \"" . $RecordType . "\", Value: \"" . ($rec->"value") . "\", Comment: \"" . ($rec->"comment") . "\"");
|
$LogPrint debug $ScriptName ("GetAnnouncedIP - Record: Name: \"" . $RecordName . "\", Type: \"" . $RecordType . "\", Value: \"" . ($rec->"value") . "\", Comment: \"" . ($rec->"comment") . "\"");
|
||||||
|
|
@ -82,13 +84,15 @@ onerror Err {
|
||||||
|
|
||||||
:onerror APISetRecordErr in={
|
:onerror APISetRecordErr in={
|
||||||
$LogPrint debug $ScriptName ("APISetRecord - started");
|
$LogPrint debug $ScriptName ("APISetRecord - started");
|
||||||
|
[/system/script/run "JParseFunctions"; global JSONLoad; global JSONLoads; global JSONUnload];
|
||||||
|
$LogPrint debug $ScriptName ("APISetRecord - JParseFunctions loaded");
|
||||||
|
|
||||||
:local Records;
|
:local Records;
|
||||||
:local Record;
|
:local Record;
|
||||||
:local Payload;
|
:local Payload;
|
||||||
|
|
||||||
:onerror GetRecordsErr in={
|
:onerror GetRecordsErr in={
|
||||||
:set Records ([:deserialize from=json ([/tool/fetch "$APIUrl/zones/$ZoneName/rrsets/$RecordName/$RecordType" http-method=get http-header-field="Authorization: Bearer $APIToken" output=user as-value]->"data")]->"rrset"->"records");
|
:set Records ([$JSONLoads ([/tool/fetch "$APIUrl/zones/$ZoneName/rrsets/$RecordName/$RecordType" http-method=get http-header-field="Authorization: Bearer $APIToken" output=user as-value]->"data")]->"rrset"->"records");
|
||||||
} do={
|
} do={
|
||||||
:if ([:find "$GetRecordsErr" "status 404";] >= 1) do={
|
:if ([:find "$GetRecordsErr" "status 404";] >= 1) do={
|
||||||
:set Records [:toarray ""];
|
:set Records [:toarray ""];
|
||||||
|
|
@ -132,6 +136,8 @@ onerror Err {
|
||||||
}
|
}
|
||||||
$LogPrint debug $ScriptName ("APISetRecord - APIResponse: " . $APIResponse);
|
$LogPrint debug $ScriptName ("APISetRecord - APIResponse: " . $APIResponse);
|
||||||
|
|
||||||
|
$JSONUnload;
|
||||||
|
$LogPrint debug $ScriptName ("APISetRecord - JSONUnload done");
|
||||||
$LogPrint debug $ScriptName ("APISetRecord - finished");
|
$LogPrint debug $ScriptName ("APISetRecord - finished");
|
||||||
:return $APIResponse;
|
:return $APIResponse;
|
||||||
} do={
|
} do={
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@
|
||||||
- [Table of Contents](#table-of-contents)
|
- [Table of Contents](#table-of-contents)
|
||||||
- [Description](#description)
|
- [Description](#description)
|
||||||
- [Requirements and installation](#requirements-and-installation)
|
- [Requirements and installation](#requirements-and-installation)
|
||||||
|
- [Dependencies](#dependencies)
|
||||||
|
- [JSON parser Installation](#json-parser-installation)
|
||||||
- [Pre requisites](#pre-requisites)
|
- [Pre requisites](#pre-requisites)
|
||||||
- [Script Installation](#script-installation)
|
- [Script Installation](#script-installation)
|
||||||
- [Configuration](#configuration)
|
- [Configuration](#configuration)
|
||||||
|
|
@ -28,6 +30,18 @@ RouterOS 6 isn't and won't be supported!
|
||||||
|
|
||||||
## Requirements and installation
|
## Requirements and installation
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
This script requires [Winand](https://github.com/Winand)'s [mikrotik-json-parser](https://github.com/Winand/mikrotik-json-parser) to be installed.
|
||||||
|
|
||||||
|
#### JSON parser Installation
|
||||||
|
|
||||||
|
Create another new script:
|
||||||
|
|
||||||
|
1. Name: `JParseFunctions`
|
||||||
|
2. Policy: `read`, `write`, `test` uncheck everything else
|
||||||
|
3. Source: The content of [mikrotik-json-parser](https://github.com/Winand/mikrotik-json-parser/blob/master/JParseFunctions)
|
||||||
|
|
||||||
### Pre requisites
|
### Pre requisites
|
||||||
|
|
||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
#!rsc by RouterOS
|
#!rsc by RouterOS
|
||||||
# RouterOS script: global-functions.d/phg.rsc
|
# RouterOS script: global-functions-custom-phg
|
||||||
# Copyright (c) 2025-2026 Philip 'ShokiNN' Henning <mail@philip-henning.com>
|
# Copyright (c) 2025 Philip 'ShokiNN' Henning <mail@philip-henning.com>
|
||||||
# https://git.s1q.dev/phg/routeros-scripts-custom/about/COPYING.md
|
# https://git.s1q.dev/phg/routeros-scripts-custom/about/COPYING.md
|
||||||
#
|
#
|
||||||
# requires RouterOS, version=7.14
|
# requires RouterOS, version=7.14
|
||||||
#
|
#
|
||||||
# global functions for my custom scripts
|
# global functions for my custom scripts
|
||||||
# https://git.s1q.dev/phg/routeros-scripts-custom
|
# https://git.s1q.dev/phg/routeros-scripts-custom/about
|
||||||
|
|
||||||
:local ScriptName [ :jobname ];
|
:local ScriptName [ :jobname ];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue