Community discussions

MikroTik App
 
rogerioqueiroz
just joined
Topic Author
Posts: 3
Joined: Thu Mar 30, 2023 4:49 pm

"Wait" and reboot

Wed Mar 27, 2024 4:52 pm

Hi

The first one, to update the packages, is working normally, but I would like to record each step in the log, but when it goes to update it apparently executes both commands at the same time, causing the log record to be on "wait", However, as when it finishes updating it restarts, it ends up not printing the information I want in the log.
:log info "Checking for updates";
system/package/update/check-for-updates
:delay 5s;
:if ([system/package/update/get installed-version] != [system/package/update/get latest-version]) do={[:log info "New version found, updating"] [/system/package/update/install]} else={:log info "Already in the latest version"};
The second script, which would be to update the Routerboard, does not restart it. If I run the script through the terminal, it waits for confirmation. Would I be able to make the script respond to confirmation or make it restart without confirmation?
:log info "Checking for RouterBOARD upgrade";
/system/routerboard/print
:delay 5s;
:if ([system/routerboard/get current-firmware] != [system/routerboard/get upgrade-firmware]) do={[:log info "Upgrading RouterBOARD";] [/system/routerboard/upgrade] [:delay30s] [/system/reboot]} else={ :log info "RouterBOARD already in the latest version" };
I didn't find anything in the docs, can you guys help me?
 
rogerioqueiroz
just joined
Topic Author
Posts: 3
Joined: Thu Mar 30, 2023 4:49 pm

Re: "Wait" and reboot

Thu Mar 28, 2024 10:43 pm

I managed to solve the first one with the help of a user on Reddit. I'll post how it turned out below in case anyone is interested.

https://www.reddit.com/r/mikrotik/comme ... t/kwyaar7/

If anyone can help me make a command in the script to restart, I would appreciate it.
 
jaclaz
Long time Member
Long time Member
Posts: 664
Joined: Tue Oct 03, 2023 4:21 pm

Re: "Wait" and reboot

Fri Mar 29, 2024 12:21 am

You can try the :execute script approach:
viewtopic.php?t=50573
No idea if It still works on current ROS versions.
 
User avatar
loloski
Member
Member
Posts: 351
Joined: Mon Mar 15, 2021 9:10 pm

Re: "Wait" and reboot

Fri Mar 29, 2024 3:00 am

Shameless plug, I personally use e-worm collection for this purpose https://github.com/eworm-de/routeros-sc ... reboot.rsc
 
rogerioqueiroz
just joined
Topic Author
Posts: 3
Joined: Thu Mar 30, 2023 4:49 pm

Re: "Wait" and reboot  [SOLVED]

Tue Apr 09, 2024 11:03 pm

I achieved.

The update is scheduled to run every day at 01:00 and the upgrade at the start of Mikrotik.

I tested it for a few days and several devices, everything worked fine.

Update package
:log info "Checking for updates";
/system/package/update/check-for-updates
:delay 5s;
:if (/system/package/update/get installed-version != /system/package/update/get latest-version) do={(:log info "New version found, updating") (/system/package/update/install)} else={:log info "Already in the latest version"};
Upgrade RouterBoard
:log info "Checking for RouterBOARD upgrade";
:delay 10s;
:if ([/system/routerboard/get current-firmware] != [/system/routerboard/get upgrade-firmware]) do={[:log info "Upgrading RouterBOARD"] [:execute script={/system/routerboard/upgrade}] [:delay 10s] [:execute script={/system/reboot};]} else={:log info "RouterBOARD already in the latest version"};
Posted in case anyone is looking for the same solution.

Who is online

Users browsing this forum: No registered users and 4 guests