Community discussions

MikroTik App
 
Prairiekid
just joined
Topic Author
Posts: 9
Joined: Fri Nov 27, 2009 11:56 pm

owner of script is *sys not admin - not working

Fri Mar 26, 2010 9:49 pm

I have been using the following script for quite a while now. Thanks to the author who is unknown to me. It works great, but as of late I am trying to integrate the script as part of a complete config and have it run after reset. Everything works as it should except for this portion of the config:
Code:
/system script
add name="ChangeBand" \
source=":local delais 5s\r\n:local liste 2.4ghz-b/g,2ghz-5mhz,2ghz-10mhz;\r\n \
\r\n:foreach band in=\$liste \
do={\r\n:if (![/interface wireless get wlan1 running]) do={\r\n/interface \
wireless set wlan1 band=\$band\r\n:delay \$delais\r\n}\r\n}\r\n\r\n:if \
(![/interface wireless get wlan1 running]) \\\r\ndo={\r\n :if \
[/interface wireless nstreme get wlan1 enable-nstreme] \\\r\n do={\r\n \
/interface wireless nstreme set wlan1 enable-nstreme=no\r\n } \
else={\r\n /interface wireless nstreme set wlan1 \
enable-nstreme=yes\r\n }\r\n}"
/system scheduler
add comment="" disabled=no interval=20s name="schedcheckWifi" \
on-event=ChangeBand start-time=startup
When I drop this or my complete config from the terminal the owner of the script is admin and everything runs great. When it is imported after a run after reset, the owner is *sys and it looks right, the script count goes up, but it doesn't actually do anything. Can someone set me on the right track to get this working in a run-after-reset scenario. Can I force the owner to admin? Is that the solution?
Thanks in advance for your help.
 
vemax78
just joined
Posts: 11
Joined: Thu Sep 22, 2011 5:53 pm

Re: owner of script is *sys not admin - not working

Thu Sep 22, 2011 6:24 pm

I have the same problem, for example I have a file "post-factory-reset.rsc" that contains this script:
/system script add name="test" source=":nothing"
From terminal console send the command:
/system reset-configuration no-defaults=yes skip-backup=yes run-after-reset="post-factory-reset.rsc"
After reboot, the output of system script print is:
[admin@MikroTik] > system script print
Flags: I - invalid
0 name="test" owner="*sys"
policy=(unknown),ftp,reboot,read,write,policy,test,winbox,password,sniff,
sensitive,api,(unknown),(unknown),(unknown),(unknown),(unknown),(unknown),
(unknown),(unknown),(unknown),(unknown),(unknown),(unknown),(unknown),
(unknown),(unknown),(unknown)
run-count=0 source=:nothing
The problem is that the owner is *sys (it is not admin). I am using a RB433 with RouterOS 5.7
I need the option run-after-reset for automatic reconfigure RouterBoard after configuration reset. Is that the solution ?
Instead of using the parameter run-after-reset, there is a way, after reset, to automaticity load a script at the bootstrap of RouterBOARD ?

Thank you
Massimo
 
vemax78
just joined
Posts: 11
Joined: Thu Sep 22, 2011 5:53 pm

Re: owner of script is *sys not admin - not working

Fri Sep 23, 2011 6:41 pm

I found a workaround using /tool fetch into script imported by factory reset after reboot

Example:

Script postfactoryreset.rsc:
:delay 5s;
/tool fetch address=127.0.0.1 mode=ftp src-path=/bootstrap.rsc dst-path=bootstrap.auto.rsc user=admin password="" host="" upload="yes";

Script bootstrap.rsc:
/system script add name="test" source=":nothing"

Factory reset the board with command:
/system reset-configuration no-defaults=yes skip-backup=yes run-after-reset="postfactoryreset.rsc"

After reset the output of "/system script print" is
[admin@MikroTik] > system script print
Flags: I - invalid
0 name="test" owner="admin"
policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,
api
run-count=0 source=:nothing


Ciao
Massimo