From patchwork Thu Oct 28 09:15:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1547379 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=IykmNDmU; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::539; helo=mail-ed1-x539.google.com; envelope-from=swupdate+bncbcxploxj6ikrbmgu5gfqmgqebzhms5y@googlegroups.com; receiver=) Received: from mail-ed1-x539.google.com (mail-ed1-x539.google.com [IPv6:2a00:1450:4864:20::539]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hg0K00Hz9z9sXN for ; Thu, 28 Oct 2021 20:15:31 +1100 (AEDT) Received: by mail-ed1-x539.google.com with SMTP id y3-20020a056402358300b003dd490c775csf4923842edc.22 for ; Thu, 28 Oct 2021 02:15:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1635412528; cv=pass; d=google.com; s=arc-20160816; b=PmYPOspZVKsbXMOKq6fNaQ1dgLGSqsvGfQFZv8otVhiEr07XT7CxHzmYaKRVjDLrgL PYUdsKfut3veoVDQ9cEY5x//jGtw/ZpXlgvtRTLpN67CkPyGIS+ysFV5AIeTStX0Wfnj 8gOrtZFFddrvN+9KaDUCJrChACRZGBdLiFZZVsegQdQTVrQ4fPF7YkwcjfZY1qzUOhdX yAlzYnTLFVeiqfnuOwLPQKHSrdhOAFfp9XVvkhz62WPz6nskH4hEi2o1eQDwJ5YieA3M //T6xCLnB7F85aukQ5cWaZDrekdFtRSxS4qvEZgon13h5idrBbutIMGCpJgVVmJ9cI01 TGng== 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:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=LCYD3dJwJzlsSZrEA2I75Ea+yjOSJDncj6MPzgZJIco=; b=aYn8Ta2nZOOrnjDm5BN8pF5sq1A2lyM1cMgcr+1t5ZfYAP221UfVHZEYGnfwDNxM8H cBN9Njjhh9ojk8i/0uGTMhARLcIefJ4wUnFxK1sL9vACbxwJd1KmBDmrshESgMvFTbVe 9NTU0OMbe2yoqqeKLsvUijyADhIyxKyeCE7oaySXXrA1X11Q/7IyLU3WUwZ4aQCtU/C1 eXE071pz/Zxnmz3iixSdOAuDJizgelRHV+u3hjEMrreIosQuMuqgJMiEDIPXaoZsDrvi B4rHKAGZgs1feNKMW7ntkFDlbPeLqcGoJ9QUiSvNs3nOS3kSBlLdV2lpsOhf/BUzLK6L TKrg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :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=LCYD3dJwJzlsSZrEA2I75Ea+yjOSJDncj6MPzgZJIco=; b=IykmNDmUy90GR4lGnJOXoV4hYwm+mMEbpP8a30sNZ38RUrIGABKK54ZRZ5teLVOBQ7 oL5lafLk6vRzqboMPIjAS3JDKSiyWLDZMJW4E0d3VSmtlvVfkiJ206hZD423mVqRYi3p o81EwtzbqyQwSjRqapmiPlU7erQfbmPSWaKadnyuqNrJ6/z1lru5DgE6TmuVzYLqGmzI 6ZMHQ/YpL1PA/15iq1BMUQ43DK5ip2GfmYj9xd94XWOdy2176Hnyr0MxytyBqcoROndP FecqdZY4S1Oo0K7HHYg8P0ryxhe/apL0vTwTkZ2tErya1ycO8IN9CGBt1FGLcCql8BE1 SdFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references: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=LCYD3dJwJzlsSZrEA2I75Ea+yjOSJDncj6MPzgZJIco=; b=RdP4lfCB2UmXfGH6lrq6ey2rbKf97JTka2LSrFyzoVgGjDoUl36kOXd9/kPBIErAWf owUyevhepsfuImPDrLIO/MWrtZVZ6xCNqziCWFE6J813oUNgXEiOgavnL+mkiFS/RXBy 50+j9mPDo0cjdt7/4nFARgasn1Ik2ejRuc+E5fi8/xb0ZOSa9Ywn6fgwAmk5wnGUSG3h gOEaD6uEeJxyvdnm6I39Yl8gVzug5L029D0+K0LVDmppSeVDzRrKj3seMG/NkLbJ3wjS kvyML4bKlr7O/lWueyojungd3HhcAVLDPMurgyzu7qk0TKpt3GqggXpqVYQWF0pCBSCM rb0Q== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530ANoTjG6Y65LrwnlVV4iFVFRIF1b5Xj1VhZcivDksBxZWOSyoF FW9QfNIRPZiLIzwpoZu+yxU= X-Google-Smtp-Source: ABdhPJx4cH4oJHDUDdmsN/Ydq4e6GLy24zJ8izXDJkqr6ufC8QhB4tB46XhXT0U4fQ6S4aZpZF/k1g== X-Received: by 2002:a17:906:1fc1:: with SMTP id e1mr3682433ejt.515.1635412528689; Thu, 28 Oct 2021 02:15:28 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:906:5941:: with SMTP id g1ls1263063ejr.10.gmail; Thu, 28 Oct 2021 02:15:27 -0700 (PDT) X-Received: by 2002:a17:906:f41:: with SMTP id h1mr3995710ejj.255.1635412527873; Thu, 28 Oct 2021 02:15:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635412527; cv=none; d=google.com; s=arc-20160816; b=wH8+iuLYTZG3vvcfft77CI2FpcZvJGrlhwSSJMr1p02kQz7OcKGuZEsBsiSyByInr0 WLdSoTXmmqL09HYZRP7ct8jOz23nxjy+uVyuRxq788geXmTm//q+m/vMl1OUYtQnEQvs jk+mHwYKRARMsnWW6p1GnbpjyEoX/AFbX8Ab0y5Nz5NavDBObMLzxESb65px97H+sVVj gffYOlt+CEXRR2fRxw4q2nLGBg2SeSD4sfd3s93S0i/slNv4VQkh6+LlGEgQtKuFKN5g febe3e39DWmPuTNtBoTk3rHhiZh/0QW79JGHbee32ycZwJMkRQbMl95QyWT7OBeqbBZQ Xb1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=mjzTWp44D12FJVA2QCJJw8hWF/mWAXO2Z6v3l08Oz78=; b=qZrPBRLTheC80QAsYFywkzofAr9L4cf9QzLVhYspN8N0SMpsLT7pxCYAzMQWgWijI/ LCNKQA5o/xKObfziLn0xD9MUE0pEWys6XsyXvUWDOflWYcLRJglc69zkNFeW6nI+Ugp2 +SAUSE326fshg7jphUMFw9qFiZNenr3/iiMKkDkT4cT28ej66sbVouKtUP48jX+VV4uw SbSBmprflkgJQG3vgMRDu2z7S/PR6wotZsYOiGXZkw+7cx/mTRtK32hXuhV4BS68EXr4 SsZIyLh6A3jPb9BsWCSa0wONkahKTqIlZZWc+sBIfIVRLBLRa3LlwJi2c4CRurh/Roa/ XLng== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by 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 bi21si177629edb.0.2021.10.28.02.15.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Oct 2021 02:15:27 -0700 (PDT) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by 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 4Hg0Jv4WnFz1qwGf; Thu, 28 Oct 2021 11:15:27 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Hg0Jv4JCjz1qqkG; Thu, 28 Oct 2021 11:15:27 +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 BpEfvzkj78yW; Thu, 28 Oct 2021 11:15:25 +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; Thu, 28 Oct 2021 11:15:25 +0200 (CEST) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 1DBC04540BCF; Thu, 28 Oct 2021 11:15:25 +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 jnbG7foyqlyu; Thu, 28 Oct 2021 11:15:21 +0200 (CEST) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 30B5B45412FF; Thu, 28 Oct 2021 11:15:17 +0200 (CEST) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 3/3] Drop tools replaced by swupdate-ipc Date: Thu, 28 Oct 2021 11:15:13 +0200 Message-Id: <20211028091513.2875447-4-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211028091513.2875447-1-sbabic@denx.de> References: <20211028091513.2875447-1-sbabic@denx.de> 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 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: , Signed-off-by: Stefano Babic --- doc/source/conf.py | 4 +- doc/source/index.rst | 3 - doc/source/swupdate-hawkbitcfg.rst | 25 --- doc/source/swupdate-sendtohawkbit.rst | 21 -- doc/source/swupdate-sysrestart.rst | 23 --- tools/Makefile | 4 - tools/swupdate-gethawkbitstatus.c | 70 ------- tools/swupdate-hawkbitcfg.c | 146 -------------- tools/swupdate-sendtohawkbit.c | 106 ---------- tools/swupdate-sysrestart.c | 271 -------------------------- 10 files changed, 1 insertion(+), 672 deletions(-) delete mode 100644 doc/source/swupdate-hawkbitcfg.rst delete mode 100644 doc/source/swupdate-sendtohawkbit.rst delete mode 100644 doc/source/swupdate-sysrestart.rst delete mode 100644 tools/swupdate-gethawkbitstatus.c delete mode 100644 tools/swupdate-hawkbitcfg.c delete mode 100644 tools/swupdate-sendtohawkbit.c delete mode 100644 tools/swupdate-sysrestart.c diff --git a/doc/source/conf.py b/doc/source/conf.py index 5b41bf44..d062a04c 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -238,11 +238,9 @@ latex_use_parts = False # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'swupdate', u'Swupdate Documentation', [u'Stefano Babic'], 1), - ('swupdate-sendtohawkbit', 'sendtohawkbit', u'swupdate-sendtohawkbit tool', '', 1), + ('swupdate-ipc', 'ipc', u'SWUpdate IPC tool', '', 1), ('swupdate-client', 'client', u'SWUpdate client tool', '', 1), - ('swupdate-hawkbitcfg', 'hawkbitcfg', u'SWUpdate hawkBit Configuration tool', '', 1), ('swupdate-progress', 'progress', u'SWUpdate progress tool', '', 1), - ('swupdate-sysrestart', 'sysrestart', u'SWUpdate sysrestart tool', '', 1), ] diff --git a/doc/source/index.rst b/doc/source/index.rst index e20d0824..c07b79ca 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -58,10 +58,7 @@ Utilities and tools :maxdepth: 2 swupdate-client.rst - swupdate-hawkbitcfg.rst - swupdate-sendtohawkbit.rst swupdate-progress.rst - swupdate-sysrestart.rst swupdate-ipc.rst ############################################ diff --git a/doc/source/swupdate-hawkbitcfg.rst b/doc/source/swupdate-hawkbitcfg.rst deleted file mode 100644 index 0a356612..00000000 --- a/doc/source/swupdate-hawkbitcfg.rst +++ /dev/null @@ -1,25 +0,0 @@ -.. SPDX-FileCopyrightText: 2013-2021 Stefano Babic -.. SPDX-License-Identifier: GPL-2.0-only - -swupdate-hawkbitcfg -=================== - -swupdate-hawkbitcfg is a small tool that tries to connect to a running instance -of SWUpdate and configures hawkBit's parameter. - -SYNOPSIS --------- - -swupdate-hawkbitcfg [option] - -DESCRIPTION ------------ - --h - help --p - allows one to set the polling time (in seconds) --e - enable suricatta mode --d - disable suricatta mode diff --git a/doc/source/swupdate-sendtohawkbit.rst b/doc/source/swupdate-sendtohawkbit.rst deleted file mode 100644 index 03159e84..00000000 --- a/doc/source/swupdate-sendtohawkbit.rst +++ /dev/null @@ -1,21 +0,0 @@ -.. SPDX-FileCopyrightText: 2013-2021 Stefano Babic -.. SPDX-License-Identifier: GPL-2.0-only - -swupdate-sendtohawkbit -====================== - -swupdate-sendtohawkbit is a small tool that tries to connect to a running -instance of SWUpdate and uses it as proxy to send data to the hawkBit Server. -A typical use case is acknowledgement for activation by an application or -operator after a new software has been installed. The tool can forward the -result for the activation to the hawkBit server. - -SYNOPSIS --------- - -swupdate-sendtohawkbit .. - -DESCRIPTION ------------ - -See hawkBit API to get more information on the parameters. diff --git a/doc/source/swupdate-sysrestart.rst b/doc/source/swupdate-sysrestart.rst deleted file mode 100644 index 7148d37c..00000000 --- a/doc/source/swupdate-sysrestart.rst +++ /dev/null @@ -1,23 +0,0 @@ -.. SPDX-FileCopyrightText: 2013-2021 Stefano Babic -.. SPDX-License-Identifier: GPL-2.0-only - -swupdate-sysrestart -=================== - -swupdate-sysrestart is a restart controller. It checks the update status -and in case of success, it reboots all devices that were updated. - -SYNOPSIS --------- - -swupdate-sysrestart [option] - -DESCRIPTION ------------ - --r - optionally reboot the target after a successful update --w - waits for a SWUpdate connection instead of exit with error --s - path to progress IPC socket diff --git a/tools/Makefile b/tools/Makefile index 5e43f91d..2dd6717f 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -10,11 +10,7 @@ lib-y += \ swupdate-client.o \ - swupdate-gethawkbitstatus.o \ swupdate-progress.o \ - swupdate-hawkbitcfg.o \ - swupdate-sendtohawkbit.o \ - swupdate-sysrestart.o \ swupdate-ipc.o # # Uncomment the next lines to integrate the compiling/linking of diff --git a/tools/swupdate-gethawkbitstatus.c b/tools/swupdate-gethawkbitstatus.c deleted file mode 100644 index cd480ed5..00000000 --- a/tools/swupdate-gethawkbitstatus.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2021 Weidmueller Interface GmbH & Co. KG - * Roland Gaudig - * - * SPDX-License-Identifier: GPL-2.0-only - */ - -/* - * This is a small example how to retrieve the hawkBit server status - * from surricata. - */ - -#include - -#if defined(CONFIG_JSON) -#include - -#include - -int main(int __attribute__ ((__unused__)) argc, - char __attribute__ ((__unused__)) *argv[]) -{ - ipc_message msg; - struct json_object *parsed_json; - struct json_object *server; - struct json_object *status; - struct json_object *time; - - msg.type = SWUPDATE_SUBPROCESS; - msg.data.procmsg.source = SOURCE_SURICATTA; - msg.data.procmsg.cmd = CMD_GET_STATUS; - - msg.data.procmsg.buf[0] = '\0'; - msg.data.procmsg.len = 0; - msg.data.procmsg.timeout = 10; /* Wait 10 s for Suricatta response */ - - int rc = ipc_send_cmd(&msg); - - if (rc) { - fprintf(stderr, "Error: ipc_send_cmd failed\n"); - exit(1); - } - - if (msg.type == ACK) { - parsed_json = json_tokener_parse(msg.data.procmsg.buf); - json_object_object_get_ex(parsed_json, "server", &server); - json_object_object_get_ex(server, "status", &status); - json_object_object_get_ex(server, "time", &time); - - printf("status: %d, time: %s\n", - json_object_get_int(status), - json_object_get_string(time)); - exit(0); - } else { - printf("Error: suricatta did respond with NACK.\n"); - exit(1); - } -} -#else -#include - -#warning "swupdate-gethawkbitstatus needs json-c, replaced with dummy" - -int main(int __attribute__((__unused__)) argc, - char __attribute__((__unused__)) **argv) -{ - fprintf(stderr, "json-c not available, exiting..\n"); - exit(1); -} -#endif diff --git a/tools/swupdate-hawkbitcfg.c b/tools/swupdate-hawkbitcfg.c deleted file mode 100644 index c390ec72..00000000 --- a/tools/swupdate-hawkbitcfg.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * (C) Copyright 2017 - * Stefano Babic, DENX Software Engineering, sbabic@denx.de. - * - * SPDX-License-Identifier: GPL-2.0-only - */ - -/* - * This is a simple example how to send a command to - * a SWUpdate's subprocess. It sends a "feedback" - * to the suricatta module and waits for the answer. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "network_ipc.h" - -static struct option long_options[] = { - {"help", no_argument, NULL, 'h'}, - {"polling-time", required_argument, NULL, 'p'}, - {"enable", no_argument, NULL, 'e'}, - {"disable", no_argument, NULL, 'd'}, - {"trigger", no_argument, NULL, 't'}, - {NULL, 0, NULL, 0} -}; - -static void usage(char *programname) -{ - fprintf(stdout, "%s (compiled %s)\n", programname, __DATE__); - fprintf(stdout, "Usage %s [OPTION]\n", - programname); - fprintf(stdout, - " -p, --polling-time : Set polling time (0=from server) to ask the backend server\n" - " -e, --enable : Enable polling of backend server\n" - " -d, --disable : Disable polling of backend server\n" - " -t, --trigger : Poll backend server immediately\n" - " -h, --help : print this help and exit\n" - ); -} - -static void send_msg(ipc_message *msg) -{ - int rc; - - fprintf(stdout, "Sending: '%s'", msg->data.procmsg.buf); - rc = ipc_send_cmd(msg); - - fprintf(stdout, " returned %d\n", rc); - if (rc == 0) { - fprintf(stdout, "Server returns %s\n", - (msg->type == ACK) ? "ACK" : "NACK"); - if (msg->data.procmsg.len > 0) { - fprintf(stdout, "Returned message: %s\n", - msg->data.procmsg.buf); - } - } -} - -/* - * Simple example, it does nothing but calling the library - */ -int main(int argc, char *argv[]) { - ipc_message msg; - size_t size; - char *buf; - int c; - unsigned long polling_time; - bool enable = false; - int opt_e = 0; - int opt_p = 0; - int opt_t = 0; - - if (argc < 2) { - usage(argv[0]); - exit(1); - } - - memset(&msg, 0, sizeof(msg)); - msg.data.procmsg.source = SOURCE_SURICATTA; - msg.type = SWUPDATE_SUBPROCESS; - - size = sizeof(msg.data.procmsg.buf); - buf = msg.data.procmsg.buf; - - /* Process options with getopt */ - while ((c = getopt_long(argc, argv, "p:edh", - long_options, NULL)) != EOF) { - switch (c) { - case 'p': - opt_p = 1; - msg.data.procmsg.cmd = CMD_CONFIG; - polling_time = strtoul(optarg, NULL, 10); - break; - case 'e': - case 'd': - msg.data.procmsg.cmd = CMD_ENABLE; - opt_e = 1; - enable = (c == 'e'); - break; - case 't': - msg.data.procmsg.cmd = CMD_ENABLE; - opt_t = 1; - break; - case 'h': - usage(argv[0]); - exit(0); - break; - default: - usage(argv[0]); - exit(1); - break; - } - } - - /* - * Build a json string with the command line parameters - * do not check anything, let SWUpdate - * doing the checks - * An error or a NACK is returned in - * case of failure - */ - if (opt_p) { - snprintf(buf, size, "{ \"polling\" : \"%lu\"}", polling_time); - msg.data.procmsg.len = strnlen(buf, size); - send_msg(&msg); - } - if (opt_e) { - snprintf(buf, size, "{ \"enable\" : %s}", enable ? "true" : "false"); - msg.data.procmsg.len = strnlen(buf, size); - send_msg(&msg); - } - if (opt_t) { - snprintf(buf, size, "{ \"trigger\" : true}"); - msg.data.procmsg.len = strnlen(buf, size); - send_msg(&msg); - } - - exit(0); -} diff --git a/tools/swupdate-sendtohawkbit.c b/tools/swupdate-sendtohawkbit.c deleted file mode 100644 index 763e5b35..00000000 --- a/tools/swupdate-sendtohawkbit.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * (C) Copyright 2017 - * Stefano Babic, DENX Software Engineering, sbabic@denx.de. - * - * SPDX-License-Identifier: GPL-2.0-only - */ - -/* - * This is a simple example how to send a command to - * a SWUpdate's subprocess. It sends a "feedback" - * to the suricatta module and waits for the answer. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "network_ipc.h" - -static void usage(char *program) { - printf("%s ..\n", program); -} - -int fd; -int verbose = 1; - -/* - * Simple example, it does nothing but calling the library - */ -int main(int argc, char *argv[]) { - int rc, written, i; - ipc_message msg; - size_t size; - char *buf; - - if (argc < 3) { - usage(argv[0]); - exit(1); - } - - memset(&msg, 0, sizeof(msg)); - msg.data.procmsg.source = SOURCE_SURICATTA; - msg.data.procmsg.cmd = CMD_ACTIVATION; - msg.type = SWUPDATE_SUBPROCESS; - - size = sizeof(msg.data.procmsg.buf); - buf = msg.data.procmsg.buf; - - /* - * Build a json string with the command line parameters - * do not check anything, let SWUpdate - * doing the checks - * An error or a NACK is returned in - * case of failure - */ - for (i = 1; i < argc; i++) { - switch (i) { - case 1: - written = snprintf(buf, size, "{ \"id\" : \"%lu\"", strtoul(argv[i], NULL, 10)); - break; - case 2: - written = snprintf(buf, size, ", \"status\" : \"%s\"", argv[i]); - break; - case 3: - written = snprintf(buf, size, ",\"finished\" : \"%s\"", argv[i]); - break; - case 4: - written = snprintf(buf, size, ",\"execution\" : \"%s\"", argv[i]); - break; - case 5: - written = snprintf(buf, size, ",\"details\" : [ \"%s\"", argv[i]); - break; - default: - written = snprintf(buf, size, ",\"%s\"", argv[i]); - break; - } - - buf += written; - size -= written; - - if (size <= 0) - break; - } - - if (i > 5) - (void)snprintf(buf, size, "]}"); - else - (void)snprintf(buf, size, "}"); - - fprintf(stdout, "Sending: '%s'", msg.data.procmsg.buf); - msg.data.procmsg.len = strnlen(msg.data.procmsg.buf, sizeof(msg.data.procmsg.buf)); - - rc = ipc_send_cmd(&msg); - - fprintf(stdout, " returned %d\n", rc); - if (!rc) - fprintf(stdout, "Server returns %s\n", - (msg.type == ACK) ? "ACK" : "NACK"); - - exit(0); -} - diff --git a/tools/swupdate-sysrestart.c b/tools/swupdate-sysrestart.c deleted file mode 100644 index 078da4bd..00000000 --- a/tools/swupdate-sysrestart.c +++ /dev/null @@ -1,271 +0,0 @@ -/* - * (C) Copyright 2016 - * Stefano Babic, DENX Software Engineering, sbabic@denx.de. - * - * SPDX-License-Identifier: GPL-2.0-only - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(CONFIG_CURL) -#include -#include - -#define MAX_DEVS 100 -#define PATTERN "REMOTE:" - - -/* Store the ip addresses of device to be rebooted */ -static char ipaddrs[MAX_DEVS][NI_MAXHOST]; - -static bool is_ipaddress(char *ipaddr) -{ - struct sockaddr_in sa; - int result = inet_pton(AF_INET, ipaddr, &(sa.sin_addr)); - return result == 1; -} - -static struct option long_options[] = { - {"help", no_argument, NULL, 'h'}, - {"wait", no_argument, NULL, 'w'}, - {"socket", required_argument, NULL, 's'}, - {NULL, 0, NULL, 0} -}; - -static void usage(char *programname) -{ - fprintf(stdout, "%s (compiled %s)\n", programname, __DATE__); - fprintf(stdout, "Usage %s [OPTION]\n", - programname); - fprintf(stdout, - " -w, --wait : wait for a connection with SWUpdate\n" - " -s, --socket : path to progress IPC socket\n" - " -h, --help : print this help and exit\n" - ); -} - -static void restart_system(unsigned int ndevs) -{ - int dev; - CURL *curl_handle; /* CURL handle */ - char url[NI_MAXHOST + 20]; - CURLcode curlrc; - struct ifaddrs *ifaddr, *ifa; - char local[NI_MAXHOST]; - - /* - * Drop local ip address from the list to avoid that - * this board reboots before sending all messages - * A local reboot will be done by calling reboot() - */ - if (getifaddrs(&ifaddr) != -1) { - for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) { - if ((ifa->ifa_addr == NULL) || (ifa->ifa_addr->sa_family != AF_INET)) - continue; - if (getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in), - local, NI_MAXHOST, NULL, 0, NI_NUMERICHOST)) - continue; - - for (dev = 0; dev < ndevs; dev++) { - if (!strcmp(local, ipaddrs[dev])) { - printf("LOCAL IP : %s %s\n", local, ipaddrs[dev]); - ipaddrs[dev][0] = '\0'; - } - } - } - } - - freeifaddrs(ifaddr); - - for (dev = 0; dev < ndevs; dev++) { - if (!strlen(ipaddrs[dev])) - continue; - - curl_handle = curl_easy_init(); - /* something very bad, it should never happen */ - if (!curl_handle) - exit(2); - snprintf(url, sizeof(url), "http://%s:8080/restart", ipaddrs[dev]); - if ((curl_easy_setopt(curl_handle, CURLOPT_POST, 1L) != CURLE_OK) || - /* get verbose debug output please */ - (curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, - 1L) != CURLE_OK) || - (curl_easy_setopt(curl_handle, CURLOPT_URL, - url) != CURLE_OK) || - (curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, - "swupdate=reboot") != CURLE_OK) || - (curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, - "libcurl-agent/1.0") != CURLE_OK)) { - fprintf(stderr, "Error setting curl options\n"); - exit(2); - } - - fprintf(stdout, "Rebooting %s\n", url); - - curlrc = curl_easy_perform(curl_handle); - if (curlrc != CURLE_OK && curlrc != CURLE_GOT_NOTHING) { - fprintf(stderr, "Cannot reboot %s, try the next one, error(%d) : %s\n", - ipaddrs[dev], curlrc, curl_easy_strerror(curlrc)); - } - curl_easy_cleanup(curl_handle); - } -} - -int main(int argc, char **argv) -{ - int connfd; - struct progress_msg msg; - int opt_w = 0; - int c; - int ret; - int ndevs = 0; - - RECOVERY_STATUS status = IDLE; /* Update Status (Running, Failure) */ - - /* Process options with getopt */ - while ((c = getopt_long(argc, argv, "whs:", - long_options, NULL)) != EOF) { - switch (c) { - case 'w': - opt_w = 1; - break; - case 's': - SOCKET_PROGRESS_PATH = strdup(optarg); - break; - case 'h': - usage(argv[0]); - exit(0); - break; - default: - usage(argv[0]); - exit(1); - break; - } - } - - /* initialize CURL */ - ret = curl_global_init(CURL_GLOBAL_DEFAULT); - if (ret != CURLE_OK) { - fprintf(stderr, "CURL cannot be initialized, exiting..\n"); - exit(1); - } - - connfd = -1; - while (1) { - if (connfd < 0) { - connfd = progress_ipc_connect(opt_w); - } - - /* - * if still fails, try later - */ - if (connfd < 0) { - sleep(1); - continue; - } - - if (progress_ipc_receive(&connfd, &msg) <= 0) { - continue; - } - - /* - * Something happens, show the info - */ - if ((status == IDLE) && (msg.status != IDLE)) { - fprintf(stdout, "\nUpdate started !\n"); - fprintf(stdout, "Interface: "); - switch (msg.source) { - case SOURCE_UNKNOWN: - fprintf(stdout, "UNKNOWN\n\n"); - break; - case SOURCE_WEBSERVER: - fprintf(stdout, "WEBSERVER\n\n"); - break; - case SOURCE_SURICATTA: - fprintf(stdout, "BACKEND\n\n"); - break; - case SOURCE_DOWNLOADER: - fprintf(stdout, "DOWNLOADER\n\n"); - break; - case SOURCE_LOCAL: - fprintf(stdout, "LOCAL\n\n"); - break; - } - - } - - if (msg.infolen > 0) { - /* - * check that msg is NULL terminated - */ - if (msg.infolen > sizeof(msg.info) - 1) { - msg.infolen = sizeof(msg.info) - 1; - } - msg.info[msg.infolen] = '\0'; - char *ipaddr = strstr(msg.info, PATTERN); - char *end; - if (ipaddr && (strlen(ipaddr) > strlen(PATTERN))) { - ipaddr += strlen(PATTERN); - end = strchr(ipaddr, '}'); - if (end) - *end = '\0'; - if (is_ipaddress(ipaddr)) { - memset(ipaddrs[ndevs], 0, NI_MAXHOST); - strncpy(ipaddrs[ndevs], ipaddr, sizeof(ipaddrs[ndevs])); - fprintf(stdout, "Remote device:%s\n", ipaddr); - ndevs++; - } - } else - fprintf(stdout, "INFO : %s\n", msg.info); - } - - switch (msg.status) { - case SUCCESS: - fprintf(stdout, "Ready to reboot !\n"); - restart_system(ndevs); - sleep(5); - - if (system("reboot") < 0) { /* It should never happen */ - fprintf(stdout, "Please reset the board.\n"); - } - break; - case FAILURE: - ndevs = 0; - break; - case DONE: - fprintf(stdout, "\nDONE.\n"); - break; - default: - break; - } - - status = msg.status; - } -} -#else -#warning "swupdate-sysrestart needs libcurl, replaced with dummy" - -int main(int __attribute__((__unused__)) argc, char __attribute__((__unused__)) **argv) -{ - fprintf(stderr, "Curl not available, exiting..\n"); - exit(1); -} -#endif