mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-04-16 10:09:37 +00:00
WIP: introduce ipv6-dhcp-client-script
This commit is contained in:
parent
78bd74c544
commit
64a024833e
1 changed files with 59 additions and 0 deletions
59
ipv6-dhcp-client-script.rsc
Normal file
59
ipv6-dhcp-client-script.rsc
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
#!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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue