From patchwork Tue Jul 23 10:24:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1135536 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=true.cz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QCmy7rWv"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 45tF3T3Xpwz9s4Y for ; Tue, 23 Jul 2019 20:25:09 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:Message-Id:Date:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=zW19UtiLUGNave/5EFgsX2YGA9uyZ4ItcH3TAEP6q5g=; b=QCmy7rWvmZs28f FswEh+Lj/+hAUW8FDUxOeUFwROdxNEdAOn7h+U1kUqq04i5J5dS1Ug1ON0/RcJavpIShzoRDtx+i+ fBYQ1OeHYaJljNMbzxDugLtd67r1GPdFyVdpvTzkjKuzvNvrEgSsK6/ne+zAV/UoWp/LLFXc321+i rO1gWV5LvKJ7dmWt3qgu9Cj2wbNOuCQHFxcpdjwc5cdzWzQmxz3diI3XZH9PVjbj1QbsSZQzdnVWd SKR4kHyx8c53tciwZRjMvav9mibHz/nKClywcSVRSTOOfDOYG8xSwjvtUyi6OhWAGYZGrb1Sd8BEI XK/mvpn8QsOz4oaHPBkA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hpryh-0007tN-SM; Tue, 23 Jul 2019 10:25:03 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hprye-0007fA-6n for openwrt-devel@lists.openwrt.org; Tue, 23 Jul 2019 10:25:01 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id E589E3C67; Tue, 23 Jul 2019 12:24:58 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id aa90040e; Tue, 23 Jul 2019 12:24:52 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Date: Tue, 23 Jul 2019 12:24:51 +0200 Message-Id: <20190723102452.30621-1-ynezz@true.cz> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190723_032500_402061_BFB23A94 X-CRM114-Status: UNSURE ( 6.25 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.217.244.18 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record Subject: [OpenWrt-Devel] [PATCH 1/2] base-files: implement generic service_running X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Petr_=C5=A0tetiar?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org DRY is good, otherwise we're going to suffer with a copy&paste disease in the init scripts. Signed-off-by: Petr Štetiar --- package/base-files/files/etc/rc.common | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common index 75dbeedf34d4..3bd382ae27ac 100755 --- a/package/base-files/files/etc/rc.common +++ b/package/base-files/files/etc/rc.common @@ -95,7 +95,11 @@ service_data() { } service_running() { - return 0 + [ -n "$USE_PROCD" ] || return 0 + + local service="${1:-$(basename $initscript)}" + local instance="${2:-*}" + procd_running "$service" "${instance}" "$@" } ${INIT_TRACE:+set -x} @@ -104,6 +108,9 @@ ${INIT_TRACE:+set -x} [ -n "$USE_PROCD" ] && { EXTRA_COMMANDS="${EXTRA_COMMANDS} running trace" + EXTRA_HELP="\ + running Check if service is running + " . $IPKG_INSTROOT/lib/functions/procd.sh basescript=$(readlink "$initscript") From patchwork Tue Jul 23 10:24:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1135537 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=true.cz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="OaEcDhIW"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 45tF3m2bGmz9s4Y for ; Tue, 23 Jul 2019 20:25:24 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sQ766tLCUESAMR8HHGhk3NNXEn7hH2ARrzDNjVAH+kM=; b=OaEcDhIWT2g5cz eOoFYMnJ84V9H5kcknooZ3AUQuejLP4ekebauns+Qf4KT2dzKoBo/HIBVnGsUfAuQ5lJD9wQxBL5W M93s15YOpQBOyVZWu4gqarPToUyPrZwOaNpG0XI8fydDz+sTn/KlVFzKhPnf0CjAvN1gfW4w4icIh LC5/XE4ysPlCyC4Ov4VNN2bpG60a4+Ees0vo6iko1Xl/WcRa3/yh39YLGXUlvo3TdxHe85BpphrNH X/xdzBTRR6GM1IQUERjRHyobYmMxRVcNiEoqipVlq9RvG6w+t3d7075+ahrSAkwJ+20Zi4VrHYVgu LLOuZUOY6gW36Jo4q7Ow==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hpryy-0000cs-CS; Tue, 23 Jul 2019 10:25:20 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hpryi-0007vn-JL for openwrt-devel@lists.openwrt.org; Tue, 23 Jul 2019 10:25:06 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 319CB3C68; Tue, 23 Jul 2019 12:25:03 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id b9c876a8; Tue, 23 Jul 2019 12:24:56 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Date: Tue, 23 Jul 2019 12:24:52 +0200 Message-Id: <20190723102452.30621-2-ynezz@true.cz> In-Reply-To: <20190723102452.30621-1-ynezz@true.cz> References: <20190723102452.30621-1-ynezz@true.cz> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190723_032505_042687_0333B974 X-CRM114-Status: UNSURE ( 5.23 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.217.244.18 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record Subject: [OpenWrt-Devel] [PATCH 2/2] netifd, lldpd, rpcd, log: use generic service_running X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Petr_=C5=A0tetiar?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org commit eb204d14f75c ("base-files: implement generic service_running") introduced generic service_running so it's not needed to copy&paste same 3 lines over and over again. Signed-off-by: Petr Štetiar --- package/network/config/netifd/files/etc/init.d/network | 5 ----- package/network/services/lldpd/files/lldpd.init | 4 ---- package/system/rpcd/files/rpcd.init | 4 ---- package/system/ubox/files/log.init | 4 ---- 4 files changed, 17 deletions(-) diff --git a/package/network/config/netifd/files/etc/init.d/network b/package/network/config/netifd/files/etc/init.d/network index 2321a309a5ce..dc208c4ce0a1 100755 --- a/package/network/config/netifd/files/etc/init.d/network +++ b/package/network/config/netifd/files/etc/init.d/network @@ -40,11 +40,6 @@ stop_service() { sleep 1 } -service_running() { - ubus -t 30 wait_for network.interface - /sbin/wifi reload_legacy -} - validate_atm_bridge_section() { uci_validate_section network "atm-bridge" "${1}" \ diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index bc429de484d3..9fb3a8255995 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -96,10 +96,6 @@ start_service() { procd_close_instance } -service_running() { - pgrep -x /usr/sbin/lldpd &> /dev/null -} - reload_service() { running || return 1 $LLDPCLI -u $LLDPSOCKET &> /dev/null <<-EOF diff --git a/package/system/rpcd/files/rpcd.init b/package/system/rpcd/files/rpcd.init index 77ebcbe6cb7b..447133c67a5a 100755 --- a/package/system/rpcd/files/rpcd.init +++ b/package/system/rpcd/files/rpcd.init @@ -18,7 +18,3 @@ start_service() { reload_service() { procd_send_signal rpcd } - -service_running() { - procd_running rpcd -} diff --git a/package/system/ubox/files/log.init b/package/system/ubox/files/log.init index ba9c124c8ba6..250f805b4406 100644 --- a/package/system/ubox/files/log.init +++ b/package/system/ubox/files/log.init @@ -96,7 +96,3 @@ start_service() config_foreach validate_log_section system start_service_file config_foreach validate_log_section system start_service_remote } - -service_running() { - procd_running log -}