mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-07-04 00:11:35 +00:00
Compare commits
No commits in common. "26120456440b8a91bdb53b3a30fa068890b8ffc5" and "78bd74c5440aab387079baf53aba1421dd210a09" have entirely different histories.
2612045644
...
78bd74c544
2 changed files with 4 additions and 67 deletions
|
|
@ -1,59 +0,0 @@
|
|||
#!rsc by RouterOS
|
||||
# RouterOS script: ipv6-dhcp-client-script
|
||||
# Copyright (c) 2026 Christian Hesse <mail@eworm.de>
|
||||
# https://rsc.eworm.de/COPYING.md
|
||||
#
|
||||
# requires RouterOS, version=7.22
|
||||
#
|
||||
# TODO
|
||||
# https://rsc.eworm.de/doc/ipv6-dhcp-client-script.md
|
||||
|
||||
:onerror Err {
|
||||
:global GlobalConfigReady; :global GlobalFunctionsReady;
|
||||
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
|
||||
do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50;
|
||||
:local ScriptName [ :jobname ];
|
||||
|
||||
:global Grep;
|
||||
:global LogPrint;
|
||||
:global ParseKeyValueStore;
|
||||
:global ScriptLock;
|
||||
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:exit;
|
||||
}
|
||||
|
||||
:if (([ :typeof $"na-address" ] = "nothing" || [ :typeof $"na-valid" ] = "nothing") && \
|
||||
([ :typeof $"pd-prefix" ] = "nothing" || [ :typeof $"pd-valid" ] = "nothing")) do={
|
||||
$LogPrint error $ScriptName ("This script is supposed to run from ipv6 dhcp-client.");
|
||||
:exit;
|
||||
}
|
||||
|
||||
:global IPv6DHCPClientEnvVars {
|
||||
"na-address"=$"na-address";
|
||||
"na-valid"=$"na-valid";
|
||||
"pd-prefix"=$"pd-prefix";
|
||||
"pd-valid"=$"pd-valid" };
|
||||
|
||||
:local RunOrder ({});
|
||||
:foreach Script in=[ /system/script/find where source~("\n# provides: ipv6-dhcp-client-script\\b") ] do={
|
||||
:local ScriptVal [ /system/script/get $Script ];
|
||||
:local Store [ $ParseKeyValueStore [ $Grep ($ScriptVal->"source") ("\23 provides: ipv6-dhcp-client-script, ") ] ];
|
||||
|
||||
:set ($RunOrder->($Store->"order" . "-" . $ScriptVal->"name")) ($ScriptVal->"name");
|
||||
}
|
||||
|
||||
:foreach Order,Script in=$RunOrder do={
|
||||
:onerror Err {
|
||||
$LogPrint debug $ScriptName ("Running script with order " . $Order . ": " . $Script);
|
||||
/system/script/run $Script;
|
||||
} do={
|
||||
$LogPrint warning $ScriptName ("Running script '" . $Script . "' failed: " . $Err);
|
||||
}
|
||||
}
|
||||
|
||||
:set IPv6DHCPClientEnvVars;
|
||||
} do={
|
||||
:global IPv6DHCPClientEnvVars; :set IPv6DHCPClientEnvVars;
|
||||
:global ExitOnError; $ExitOnError [ :jobname ] $Err;
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
# https://rsc.eworm.de/COPYING.md
|
||||
#
|
||||
# requires RouterOS, version=7.22
|
||||
# provides: ipv6-dhcp-client-script, order=40
|
||||
#
|
||||
# update firewall and dns settings on IPv6 prefix change
|
||||
# https://rsc.eworm.de/doc/ipv6-update.md
|
||||
|
|
@ -15,17 +14,14 @@
|
|||
do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50;
|
||||
:local ScriptName [ :jobname ];
|
||||
|
||||
:global EitherOr;
|
||||
:global LogPrint;
|
||||
:global ParseKeyValueStore;
|
||||
:global ScriptLock;
|
||||
|
||||
:global IPv6DHCPClientEnvVars;
|
||||
|
||||
:local NaAddress [ $EitherOr $"na-address" ($IPv6DHCPClientEnvVars->"na-address") ];
|
||||
:local NaValid [ $EitherOr $"na-valid" ($IPv6DHCPClientEnvVars->"na-valid") ];
|
||||
:local PdPrefix [ $EitherOr $"pd-prefix" ($IPv6DHCPClientEnvVars->"pd-prefix") ];
|
||||
:local PdValid [ $EitherOr $"pd-valid" ($IPv6DHCPClientEnvVars->"pd-valid") ];
|
||||
:local NaAddress $"na-address";
|
||||
:local NaValid $"na-valid";
|
||||
:local PdPrefix $"pd-prefix";
|
||||
:local PdValid $"pd-valid";
|
||||
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:exit;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue