From patchwork Fri Dec 22 11:04:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Yeryomin X-Patchwork-Id: 852321 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZMWT9Xyy"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="kQ536uB5"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3z35jj4KtWz9s71 for ; Fri, 22 Dec 2017 22:23:37 +1100 (AEDT) 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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:Message-Id:Date:To: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=6W5Z95m6VEOiHRmkAsWbUuOoL6eajo8ZrxheqLDJm2U=; b=ZMWT9XyyTZ96Jb bmFdlXLj/KY638pFy746ujTkR57/Hwt4l3ACcqgm5NVZp14VITRx0u6sTTGZzJR0bkMcfFxcxBym4 uOEZiFIgogd9HQvEl88nLRFd26jUHSN3MzPipfMFeVyyOJSAvcGRYxNJmIqU2ADBs6Kc5YkXzDNep p8wCWoEPAnAXZ3jMu5iVDTsVmRf0HPqWbTSZWaPOc+BUOP3HynyJ3iZ99fXKDVKQxOyvO49X4uoud Vhy5Gf8p+jbw3dsprsSCJOxUg6c2zFd0PX43b9oO+Z9UXiXU64h0e70CUYQZcFKvkcm7mOsh5v77v 7ql8vTTEN58OCaTNn9WQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eSLQL-0000v3-JR; Fri, 22 Dec 2017 11:23:33 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eSLQ5-0000qK-Ur for lede-dev@bombadil.infradead.org; Fri, 22 Dec 2017 11:23:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Message-Id:Date:Subject:To:From:Sender: Reply-To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=K/r1OgmmIhNEzT39sDzS7fTSjC+25rMhVDd/KbeyCgI=; b=kQ536uB5S1AlHpsJJbURRQQFAX zUmi2v3GOkU6kGR0TAPIFdzuCvb63c/ptdDvuHDSzBDtiay5C4241CnpiciVHSABo1UkoPRfPrEIJ IVFA3hp38N/gD0ToKrGV55JBLXQIMFZu9uFJ5fT1vjwrTbwZl3+CfB7D/H82nKdLZuMky9pGt4H5w IKlRxPOlJK5uF8i2oTb/bRnONTtjRgOCa0/evafjY7m0m59IXZDSpu5j8ccW9kgzOS9rR5hfmiMoU /8DNdCaR6+0UREdoJKr17a49Tz80MhUNRwATe/wna/MxVBQdTKNY+SiRb3gHlfxKuBRXi+Ao9+cnL AAnTeG5A==; Received: from [213.175.92.62] (helo=mail.pbx.lv) by merlin.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eSL8u-0005MO-Jd for lede-dev@lists.infradead.org; Fri, 22 Dec 2017 11:05:39 +0000 Received: from localhost.localdomain (unknown [213.175.92.61]) by mail.pbx.lv (MailSystem) with ESMTPSA id E72FC19E52C for ; Fri, 22 Dec 2017 13:05:20 +0200 (EET) From: Roman Yeryomin To: LEDE Development List Date: Fri, 22 Dec 2017 13:04:46 +0200 Message-Id: <20171222110446.31938-1-roman@advem.lv> X-Mailer: git-send-email 2.14.1 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.1 (-) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.infradead.org summary: Content analysis details: (-1.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.8 RDNS_NONE Delivered to internal network by a host with no rDNS Subject: [LEDE-DEV] [PATCH v2] base-files: rc.common: fix enable() return code and logic X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org In current state, if there is START but no STOP, enbale() will return 1 (failure), which is wrong. Moreover there is no need to check for START/STOP twice. Instead, add err variable to save success state and and return it's value. Also eliminate the need to disable() by using 'ln -sf', which will first delete the old symlink if one exists. Changes from v1: - fixed description Signed-off-by: Roman Yeryomin --- package/base-files/files/etc/rc.common | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common index a2ea6a5679..a08c1f8f48 100755 --- a/package/base-files/files/etc/rc.common +++ b/package/base-files/files/etc/rc.common @@ -41,14 +41,15 @@ disable() { } enable() { + err=1 name="$(basename "${initscript}")" - disable - [ -n "$START" -o -n "$STOP" ] || { - echo "/etc/init.d/$name does not have a START or STOP value" - return 1 - } - [ "$START" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}" - [ "$STOP" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/K${STOP}${name##K[0-9][0-9]}" + [ "$START" ] && \ + ln -sf "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}" && \ + err=0 + [ "$STOP" ] && \ + ln -sf "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/K${STOP}${name##K[0-9][0-9]}" && \ + err=0 + return $err } enabled() {