Hello
Like i thought i couldn't count on noone so i Made a script myself. it is tested. And it's unexpectedsystemrebootproof.
So there shouldn't be any problem with it ( itested it for 2 days).
Hope someone could have use of it
1. Code of main program that triggers subprograms pppup pppdown:
:foreach i in $pppup do {#here you put a command that will be triggered when mikrotik shutdowns unexpectedly - for egz. clean up some firewall rules;};:set pppup ;:set pppdown;:local x 1; :do {/system script run pppdown; :delay 2s;/system script run pppup;} while ($x = 1);:set x;
2. Code of pppup:
:foreach i in=[/ppp active find service=pppoe] do={:local exclude [:pick [/ppp active get $i name] 0 ([:len[/ppp active get $i name]]-14)];:put $exclude; :if ([:find [:toarray $pppup] $exclude] >= 0) do={:put "its there already"} else={:put added;:#here you place commands that will be triggered when ppp connection starts);:global pppup ([:toarray $pppup] . $exclude);}};
3. Code of pppdown
:global pppdown $pppup; :foreach i in=[/ppp active find service=pppoe] do={:local exclude [/ppp active get $i name];:if ([:find [:toarray $pppup] $exclude] >= 0) do={ :global pppdown ([:pick [:toarray $pppdown] 0 ([:find [:toarray $pppdown] $exclude])] . [:pick [:toarray $pppdown] ([:find [:toarray $pppdown] $exclude]+1) [:len [:toarray $pppdown]]] ); }};:foreach i in=$pppdown do={:global pppup ([:pick [:toarray $pppup] 0 ([:find [:toarray $pppup] $i])] . [:pick [:toarray $pppup] ([:find [:toarray $pppup] $i]+1) [:len [:toarray $pppup]]] );#HERE you put commands you want to trigger when ppp connection goes down]};
The script takes out name from active connections so you can use it in creating commands, you can also take some other info like ip. But it's up to you.
Hopefully someone will find it usefull.
This was tested with 2.9
Best Regards
Michal