From patchwork Wed Jul 1 09:40:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1320357 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::238; helo=mail-lj1-x238.google.com; envelope-from=swupdate+bncbcxploxj6ikrbb5u6h3qkgqedcaloxy@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=aKoQvGWm; dkim-atps=neutral Received: from mail-lj1-x238.google.com (mail-lj1-x238.google.com [IPv6:2a00:1450:4864:20::238]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49xbn71PKKz9sTV for ; Wed, 1 Jul 2020 19:40:27 +1000 (AEST) Received: by mail-lj1-x238.google.com with SMTP id y16sf7774299ljh.22 for ; Wed, 01 Jul 2020 02:40:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1593596423; cv=pass; d=google.com; s=arc-20160816; b=oqv4GpsmFGYUkPi4FUvGLk++SwRJakrbRCUcmpe2gLcGJDFiz4ptKQ5Jy32DuRpHg8 h0kL6MMdNTcw2s1MEx2/QZOmxr4q7KRBwFWW1aJZvYNiFps0UfAbnvoCQnHeJjZqeVsi 6BIyKl0CsRyAfZOpzXmZUi+rWhUo1u6QykWeW5Ln/SwxYre8Htt4kYsX89lBtQ/wiHXj NwXNdeWoBG5B7kMfY4BaNxAUniUOHQG7OKYHcxNzRbFATNCPuBc+QyhXrLYVnt9BGU// wsyaIOWe1/BC765SP4tnxejuACE5YDHaxKtyvantfuffQALPJ3w4l18Zp8XYhBZkTF93 ZJwQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature; bh=LqEZpLMGC8tWJFldSVzNGpWeL1//il4UkPkPYyXDER4=; b=OZ6ZF2eNkL5ls4SbYFpqcRVY6hAlpiChArDYvJ7C1JmHmJWduG37XXhJ8xNkddr7DV 1ifiAVUDzoUNdCPu6Z9V8D9kQZHWzgG107s95A4vTdiqaqm81wKQ4xowtm8OwAYQI9A0 lHVEuxXkMyWQtFL5M0fEd45G+5WcNhYBcN9nGhsX+Ue6MNhTiMpQeCSxY7LkI9ESk+by LmmIaftbRR+GYUwAUc44341D6lL1orrwJJlMSRGIpgg5oYQPDU0FPe0RSlUN7urVs+mK B/DwwGFpJUH0Z8xGOYwWH5r5LBMURPoX0hZ2HvfLHqV4TAx7ot0rf2l70tgpZIVA6vPO 2VvA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=LqEZpLMGC8tWJFldSVzNGpWeL1//il4UkPkPYyXDER4=; b=aKoQvGWmPaTUv9yNq4bTtmmAbHDP8uO0fVzIXdytUW0t5amlxwEyKt/i4rnsCa/Toz HXPGvFbQBe2CMUtn/Vs2n6+O+J0t3ZSdu9W/S79Rk0KV7WnHMSvIZoX+S9zv+lw/9ELL ZUxv11s7aB973NvlyqefTub3Xmm+j/IHlUdE7aPfv0GgHU0d7DsiT2Pz9MRx49kxXx1m sLDaoklD5aihICzPYcGFruPmt4E9CFKmt1199BjXpJGKUXtsMWSaQ4LZOvAe3NYSCl1j NxdwyZuAbnUq1B9uqcpeXcZPfHffg1bKTHxNCoEZlFreNuvX3ppJ1k361BoqxwiagUlB ds6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=LqEZpLMGC8tWJFldSVzNGpWeL1//il4UkPkPYyXDER4=; b=uHW9oGi1akwC9qs8JzZXefk+4XDQVtVfZd1YgrQRMQ+9ugBmn0B90OSauDY24EnG1I WdM7vwVyjgkJF0NfSO3O/NhCDmYcMVh1pJm0f+r1vjEbQZFFjCMBqkIuY9zHouFWAd65 u0k72ZyrNIBd3bS8KpuzEPyWxjkR7MbVT5e7APB9574Rkk9SfZXmqn9FOCPMWCpDwU9K RBb9O+I+FD8U2WjDuMUbkRsECa9oVt+uQs1B58wDVsWi4NWgbnbc95BwM3cWFpVkDikL rzUkSEED8F9iXIT1ZAu+JPTgFb5mzPoogKoaNlcDfYSHnQMZc/9SRLrPiBqf2P4oIA4H aNgQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532OrWqbbjvtCi5jH3E2ZBQUYUEcd9i3R01rsmAJBETs5ID2RJ6I JvC9kGNLhi5s0Txn98vO+Eg= X-Google-Smtp-Source: ABdhPJxD0LmdmLNai8BhzNN6KT+purkRt8q6UkDQ/9KIjbDOEXDwRSQoRUUTWum5+ZOK7ZQL60nsHQ== X-Received: by 2002:a2e:9a47:: with SMTP id k7mr925078ljj.96.1593596423760; Wed, 01 Jul 2020 02:40:23 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a19:be95:: with SMTP id o143ls915578lff.0.gmail; Wed, 01 Jul 2020 02:40:22 -0700 (PDT) X-Received: by 2002:a19:8c47:: with SMTP id i7mr1141846lfj.32.1593596422761; Wed, 01 Jul 2020 02:40:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593596422; cv=none; d=google.com; s=arc-20160816; b=dN/mDcg1twXrZxiMx8zSo4LnGoj8CBxLaWmN5IZsO/hrhmdsgq+AVd+ld4iDyzgT10 8PGsUGHk/uw6WRM3L2DGuc1SJ885dQvClbxQyGAIoHeRiJZ/zhd5ll0ewVVUA23CX/X2 I43MzfHno3S4eouIfUaawaH5MKzzKDSvfLKMOqzOjlpLBBXvuw13P6wy+6+ICRC3fP/L 7bD9BaQw0Hmy7nrQpq+TV5EZbJQwrS2+AzdaQRQ4ivtryNcTxnLQ+8BOLwTdqc1WyvZG F1UY09QDvvKziVoh0lPpF8/azxm3ZXy4/qPVMkxdnu8T+8ipA1DmwbvMMQsCD7SZGuJ/ 3rpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=lC9j+TVFWmRYuMyUUmQbHLZQog2SCVtlC6SsxAC6Xko=; b=J0uoLgyrB23H46LlQAAyn/6IlTQakbVQ8591D5vWJ/7Z6M9P9P4/FQ7dkYttFSgHBz wO5XBfJzNOmCzjGkZA83Xg/omfaJGAeMGtbfxjn+nAq7rrKZvaux2YNRKpjEjdUkW5oa 0b91wZbDSvfqBqDHczgA/StrsP0rh7aJehESN1PAdfe1h0ldMuSwu2MbJ9aAOF3Mme9Y HMgEZE1/AAHAfgdM/DTpeHrr/d/wkH0pWPe6U0F3gcrY0i9QninrCEPNxsd4aK7aXJSR 3lIr1dzdCS34Fli/Pz4mk122g3RmPG1zL0Iqjyw1P5dWD1dn4joNeoUWPlS1FHZD91YD fJ1g== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id u11si392148lfl.4.2020.07.01.02.40.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Jul 2020 02:40:22 -0700 (PDT) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 49xbn21sQxz1qtyT; Wed, 1 Jul 2020 11:40:22 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 49xbn21LjLz1qqkC; Wed, 1 Jul 2020 11:40:22 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id UqPo7juo_lXX; Wed, 1 Jul 2020 11:40:21 +0200 (CEST) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Wed, 1 Jul 2020 11:40:21 +0200 (CEST) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 09EFB454050A; Wed, 1 Jul 2020 11:40:21 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Z03JbmE1sLk8; Wed, 1 Jul 2020 11:40:18 +0200 (CEST) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id 96D9F4540310; Wed, 1 Jul 2020 11:40:18 +0200 (CEST) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH] suricatta: add IPC copmmand to trigger an update Date: Wed, 1 Jul 2020 11:40:16 +0200 Message-Id: <20200701094016.3882096-1-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , This extends commit e705a76a2 and add a command to force a check on the server without waiting for a polling time. This is useful in case the device is mostly offline, and when it is online, it should check and update as soon as possible without waiting. An additional IPC command is added - it accepts a json command in the format: "trigger" : "true" or "trigger : "false" trigger is one shot - after checking, trigger is reset automatically by the daemon. The external process is in charge to send multiple trigger requests if desired. Signed-off-by: Stefano Babic --- doc/source/swupdate-ipc.rst | 14 ++++++++++++++ suricatta/suricatta.c | 22 +++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/doc/source/swupdate-ipc.rst b/doc/source/swupdate-ipc.rst index 60ac7a1..8efde3b 100644 --- a/doc/source/swupdate-ipc.rst +++ b/doc/source/swupdate-ipc.rst @@ -141,6 +141,20 @@ Enable / disable Suricatta daemon { "enable" : true } { "enable" : false } +Trigger a check on the server +............................. + +This is useful in case the device is mostly offline, and when it is online, it should check +immediately if an update exists and run it. In fact, after enabling the suricatta daemon, +the update follows the usual states, and the daemon waits for a polling time before +loading the new software. This command forces an update (if available) without changing the +polling time. + +:: + + { "trigger" : true } + + Activate an already installed Software ...................................... diff --git a/suricatta/suricatta.c b/suricatta/suricatta.c index ac3be89..e5f8cc4 100644 --- a/suricatta/suricatta.c +++ b/suricatta/suricatta.c @@ -24,6 +24,7 @@ #include static bool enable = true; +static bool trigger = false; static struct option long_options[] = { {"enable", no_argument, NULL, 'e'}, {"disable", no_argument, NULL, 'd'}, @@ -59,6 +60,22 @@ static server_op_res_t suricatta_enable(ipc_message *msg) enable = json_object_get_boolean(json_data); TRACE ("suricatta mode %sabled", enable ? "en" : "dis"); } + else { + /* + * check if polling of server is requested via IPC (trigger) + * This allows to force to check if an update is available + * on the server. This is useful in case the device is not always + * online, and it just checks for update (and then update should run + * immediately) just when online. + */ + json_data = json_get_path_key( + json_root, (const char *[]){"trigger", NULL}); + if (json_data) { + trigger = json_object_get_boolean(json_data); + TRACE ("suricatta polling trigger received, checking on server"); + } + + } msg->type = ACK; @@ -194,7 +211,8 @@ int start_suricatta(const char *cfgfname, int argc, char *argv[]) TRACE("Server initialized, entering suricatta main loop."); while (true) { - if (enable) { + if (enable || trigger) { + trigger = false; switch (server.has_pending_action(&action_id)) { case SERVER_UPDATE_AVAILABLE: DEBUG("About to process available update."); @@ -202,6 +220,8 @@ int start_suricatta(const char *cfgfname, int argc, char *argv[]) break; case SERVER_ID_REQUESTED: server.send_target_data(); + trigger = true; + continue; break; case SERVER_EINIT: break;