Post-update command not called in suricatta mode

95 views
Skip to first unread message

Adrian Winterstein

unread,
Mar 26, 2025, 12:12:31 PM3/26/25
to swup...@googlegroups.com
Hi,

Specifying a post-update command on the command line works well when
installing a local image, but does not work, when installing an image served
by a general HTTP server in suricatta mode of swupdate. In the latter case the
command is just ignored. I'm using SWUpdate v2024.12.1.

The folowing works and leads to the script being executed:

swupdate -v -e stable,copy2 -p '/home/root/test.sh' -i /media/update-image-*

The following, however, would only lead to the pre-update command being
executed the post-update command being ignored:

swupdate -v -e stable,copy2 -P '/home/root/test.sh' -p '/home/root/test.sh' -u '-t default -i 25 -u http://192.168.1.101:8080'

Looking into the file core/stream_interface.c, I saw that the preupdatecmd
function is called there, while there is no call to the postupdate function.
Hence, I briefly added the call (see attached patch file) and the post-update
command is indeed executed then.

Is this a bug in swupdate or am I missing something?

Best,
Adrian Winterstein
0001-Add-call-for-post-update-script.patch

Stefano Babic

unread,
Mar 31, 2025, 11:00:48 AM3/31/25
to Adrian Winterstein, swup...@googlegroups.com
Hi Adrian,
Then how do you explain that it is called sometimes ?

In fact, behavior is not consistent. The postupdate was introduced for
the integrated Webserver, and then extended to other parts (the local),
but not to any subsystem.

However, the way a client (local, suricatta, Webserver) is asking to run
the command is different. The client send an ipc command to the core,
see ipc_postupdate() in code. And this is not called by suricatta code.

>
> Is this a bug in swupdate or am I missing something?

It is a bug, bu patch is not correct.

I would also like to see that patch is inlined to allow review.

Best regards,
Stefano Babic

Adrian Winterstein

unread,
Apr 2, 2025, 10:48:44 AM4/2/25
to swup...@googlegroups.com, Stefano Babic
Hi Stefano,

> Then how do you explain that it is called sometimes ?
I don't understand what you are refering to with this question, unfortunately.

> In fact, behavior is not consistent. The postupdate was introduced for
> the integrated Webserver, and then extended to other parts (the local),
> but not to any subsystem.
>
> However, the way a client (local, suricatta, Webserver) is asking to run
> the command is different. The client send an ipc command to the core,
> see ipc_postupdate() in code. And this is not called by suricatta code.
I had a look at the server_hawbit.c and server_general.c now and indeed, the
ipc_postupdate() is missing at the cleanup in the server_general.c. Here's a
suggestion for fixing this:

From ce291ec4fca1fc951a01880f88a5dc5470948f82 Mon Sep 17 00:00:00 2001
From: Adrian Winterstein <adr...@winterstein.biz>
Date: Wed, 2 Apr 2025 18:19:56 +0200
Subject: [PATCH] suricatta: add missing postupdate call

---
suricatta/server_general.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/suricatta/server_general.c b/suricatta/server_general.c
index f106bce1..45b439eb 100644
--- a/suricatta/server_general.c
+++ b/suricatta/server_general.c
@@ -573,6 +573,19 @@ cleanup:
free(server_general.cached_file);
server_general.cached_file = NULL;
}
+
+ if (result == SERVER_OK) {
+ INFO("Update successful, executing post-update actions.");
+ ipc_message msg;
+ memset(&msg, 0, sizeof(msg));
+ if (ipc_postupdate(&msg) != 0) {
+ result = SERVER_EERR;
+ } else {
+ result = msg.type == ACK ? SERVER_OK : SERVER_EERR;
+ DEBUG("%s", msg.data.msg);
+ }
+ }
+
return result;
}

--
2.49.0


The relevant log output when executing with this patch looks like this (the post update command is executed):

[INFO ] : SWUPDATE running : Installation in progress
[TRACE] : SWUPDATE running : [install_single_image] : Found installer for stream core-image-base-raspberrypi0-2w-64.rootfs.ext4.gz raw
[INFO ] : SWUPDATE successful ! SWUPDATE successful !
[TRACE] : SWUPDATE running : [network_initializer] : Main thread sleep again !
[INFO ] : No SWUPDATE running : Waiting for requests...
[INFO ] : SWUPDATE running : [server_install_update] : Update successful, executing post-update actions.
[DEBUG] : SWUPDATE running : [postupdate] : Running Post-update command
[TRACE] : SWUPDATE running : [read_lines_notify] : Test command output
[TRACE] : SWUPDATE running : [__run_cmd] : '/home/root/test.sh' command returned 0
[DEBUG] : SWUPDATE running : [server_install_update] : Post-update actions successfully executed.

Best,
Adrian Winterstein


Stefano Babic

unread,
Apr 2, 2025, 11:54:27 AM4/2/25
to Adrian Winterstein, swup...@googlegroups.com
On 4/2/25 18:44, Adrian Winterstein wrote:
> Hi Stefano,
>
>> Then how do you explain that it is called sometimes ?
> I don't understand what you are refering to with this question, unfortunately.
>
>> In fact, behavior is not consistent. The postupdate was introduced for
>> the integrated Webserver, and then extended to other parts (the local),
>> but not to any subsystem.
>>
>> However, the way a client (local, suricatta, Webserver) is asking to run
>> the command is different. The client send an ipc command to the core,
>> see ipc_postupdate() in code. And this is not called by suricatta code.
> I had a look at the server_hawbit.c and server_general.c now and indeed, the
> ipc_postupdate() is missing at the cleanup in the server_general.c. Here's a
> suggestion for fixing this:
>
> From ce291ec4fca1fc951a01880f88a5dc5470948f82 Mon Sep 17 00:00:00 2001
> From: Adrian Winterstein <adr...@winterstein.biz>
> Date: Wed, 2 Apr 2025 18:19:56 +0200
> Subject: [PATCH] suricatta: add missing postupdate call

You should add that this is for the genral server.

>
> ---
> suricatta/server_general.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/suricatta/server_general.c b/suricatta/server_general.c
> index f106bce1..45b439eb 100644
> --- a/suricatta/server_general.c
> +++ b/suricatta/server_general.c
> @@ -573,6 +573,19 @@ cleanup:
> free(server_general.cached_file);
> server_general.cached_file = NULL;
> }
> +
> + if (result == SERVER_OK) {
> + INFO("Update successful, executing post-update actions.");
> + ipc_message msg;
> + memset(&msg, 0, sizeof(msg));
> + if (ipc_postupdate(&msg) != 0) {
> + result = SERVER_EERR;
> + } else {
> + result = msg.type == ACK ? SERVER_OK : SERVER_EERR;
> + DEBUG("%s", msg.data.msg);
> + }
> + }
> +
> return result;
> }
>

Ok - please send an appropriate patch (use git send-email to avoid the
mail client damages it), and I will merge it.

Best regards,
Stefano Babic

Stefano Babic

unread,
Apr 2, 2025, 12:23:32 PM4/2/25
to Adrian Winterstein, swup...@googlegroups.com
Your Signed-off-by is missing, please add it.

Adrian Winterstein

unread,
Apr 2, 2025, 12:28:50 PM4/2/25
to swup...@googlegroups.com, Stefano Babic, Adrian Winterstein
Signed-off-by: Adrian Winterstein <adr...@winterstein.biz>
---
suricatta/server_general.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/suricatta/server_general.c b/suricatta/server_general.c
index f106bce1..45b439eb 100644
--- a/suricatta/server_general.c
+++ b/suricatta/server_general.c
@@ -573,6 +573,19 @@ cleanup:
free(server_general.cached_file);
server_general.cached_file = NULL;
}
+
+ if (result == SERVER_OK) {
+ INFO("Update successful, executing post-update actions.");
+ ipc_message msg;
+ memset(&msg, 0, sizeof(msg));
+ if (ipc_postupdate(&msg) != 0) {
+ result = SERVER_EERR;
+ } else {
+ result = msg.type == ACK ? SERVER_OK : SERVER_EERR;
+ DEBUG("%s", msg.data.msg);
+ }
+ }
+
return result;
}

--
2.49.0

Adrian Winterstein

unread,
May 6, 2025, 2:29:37 AM5/6/25
to swup...@googlegroups.com
Hi Stefano,

Is something still missing from my side regarding this patch?

Best,
Adrian


Stefano Babic

unread,
May 6, 2025, 3:20:30 AM5/6/25
to Adrian Winterstein, swup...@googlegroups.com
Hi Adrian,

On 06.05.25 08:29, Adrian Winterstein wrote:
> Hi Stefano,
>
> Is something still missing from my side regarding this patch?
>

It is fine IMHO, thanks for remembering. I apply it for the release.

Best regards,
Stefano

> Best,
> Adrian
>
>

Reply all
Reply to author
Forward
0 new messages