Closed issrec closed 1 month ago
Hi @issrec
many thanks for your interest in this project! Please check out this prerelease
I've added a -n
flag and added the exit-code 2 when:
-n
Does this solve your use case?
Hi @Marco98, this is a great change and it works:
$ ./routeros-upgrader -n; echo $?
2024/07/26 11:35:28 checking installed packages
|UP> MikroTik1: routeros-7.15.2-powerpc => routeros-7.15.3-powerpc
|UP> MikroTik1: wireless-7.15.2-powerpc => wireless-7.15.3-powerpc
|UP> MikroTik2: dude-7.15.2-arm => dude-7.15.3-arm
|UP> MikroTik2: container-7.15.2-arm => container-7.15.3-arm
|UP> MikroTik2: routeros-7.15.2-arm => routeros-7.15.3-arm
|UP> MikroTik2: wireless-7.15.2-arm => wireless-7.15.3-arm
2
$ echo N |./routeros-upgrader; echo $?
2024/07/26 11:37:55 checking installed packages
|UP> MikroTik1: routeros-7.15.2-powerpc => routeros-7.15.3-powerpc
|UP> MikroTik1: wireless-7.15.2-powerpc => wireless-7.15.3-powerpc
|UP> MikroTik2: dude-7.15.2-arm => dude-7.15.3-arm
|UP> MikroTik2: container-7.15.2-arm => container-7.15.3-arm
|UP> MikroTik2: routeros-7.15.2-arm => routeros-7.15.3-arm
|UP> MikroTik2: wireless-7.15.2-arm => wireless-7.15.3-arm
Install? [y/N]: 2
A small digression. My routers are set to knock. When they are not reachable, the error code returned is 0 - which suggests that everything is OK and there are no pending updates, which is not true 😉:
$ ./routeros-upgrader -n; echo $?
2024/07/26 11:34:54 checking installed packages
|DN> MikroTik1: unreachable
|DN> MikroTik2: unreachable
2024/07/26 11:34:54 no action required - exiting
0
Hi @issrec, yeah it makes more sense in this case with a non-zero exit code. I've now added an error to this. Please see this prerelease
Hi @Marco98, I thank you for the change. It looks better:
$ ./routeros-upgrader -n; echo $?
2024/07/29 07:37:47 checking installed packages
|DN> MikroTik1: unreachable
|DN> MikroTik2: unreachable
2024/07/29 07:37:47 no action required - exiting
2024/07/29 07:37:47 fatal error: one or more routers unreachable
1
$ ./routeros-upgrader -n; echo $?
2024/07/29 07:38:39 checking installed packages
|DN> MikroTik1: unreachable
|UP> MikroTik2: dude-7.15.2-arm => dude-7.15.3-arm
|UP> MikroTik2: container-7.15.2-arm => container-7.15.3-arm
|UP> MikroTik2: routeros-7.15.2-arm => routeros-7.15.3-arm
|UP> MikroTik2: wireless-7.15.2-arm => wireless-7.15.3-arm
2
@issrec thank you! Do you need additional tweaks for your automation or can i release the changes?
Overall it's OK and that's enough for my automation. For now I see one/two situations that are not recognizable:
$ ./routeros-upgrader -n; echo $?
2024/07/26 11:35:28 checking installed packages
|UP> MikroTik1: routeros-7.15.2-powerpc => routeros-7.15.3-powerpc
|UP> MikroTik1: wireless-7.15.2-powerpc => wireless-7.15.3-powerpc
|UP> MikroTik2: dude-7.15.2-arm => dude-7.15.3-arm
|UP> MikroTik2: container-7.15.2-arm => container-7.15.3-arm
|UP> MikroTik2: routeros-7.15.2-arm => routeros-7.15.3-arm
|UP> MikroTik2: wireless-7.15.2-arm => wireless-7.15.3-arm
2
$ ./routeros-upgrader -n; echo $?
2024/07/29 07:38:39 checking installed packages
|DN> MikroTik1: unreachable
|UP> MikroTik2: dude-7.15.2-arm => dude-7.15.3-arm
|UP> MikroTik2: container-7.15.2-arm => container-7.15.3-arm
|UP> MikroTik2: routeros-7.15.2-arm => routeros-7.15.3-arm
|UP> MikroTik2: wireless-7.15.2-arm => wireless-7.15.3-arm
2
I thank you @Marco98 for the changes you made.
Hi, I did three sessions with the
routeros-upgrader
tool:If the tool returned a non-zero exit code when updates were available, it could be used to monitor/automate mass upgrade. However, it would be worth taking care of standard input processing ;) and perhaps introducing the
-n
(force no) option.