From patchwork Thu Dec 21 19:35:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Yeryomin X-Patchwork-Id: 852198 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="ci+i+JYc"; 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 3z2rj93df3z9s7F for ; Fri, 22 Dec 2017 12:37:17 +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=1+UAGgG3n5EdN1pFMyZ+GbjPkm9zxmTzBWDjz6YYRSI=; b=ci+i+JYcLZYKa2 1Xtfq9mOrrgBQk+PEeQzJKyyhOVjSg65YZlxSit33XEx2u2fpoTf8ifWPddildtBjrj/QKX6H9GEP xx+XK8cpqVdY9edvYZ89pZjUyV0+PiyhdSc5WjKkKj3yOQchLk36L8S5CzxSKDYMHEm5TMM/WTUkv AlB9QtE0mIwczmtxUDvRhHIWflj8ewv+7Xizqo9EVxny76CVDKIqOMu70zHuTQF4Rxhhq7Zv8hH8w m724k4pb9XnDk874bvNKIcVATzmgXPnU8e7euuTSjHwBX29XG0NmrdTFIDBDw9zgUVu0h7Wqzw/fA it9/Y71sTCYW4SzNn/dA==; 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 1eSCGw-0004fc-4s; Fri, 22 Dec 2017 01:37:14 +0000 Received: from [213.175.92.62] (helo=mail.pbx.lv) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eSCGA-00048C-Ss for lede-dev@lists.infradead.org; Fri, 22 Dec 2017 01:36:30 +0000 Received: from localhost.localdomain (unknown [213.175.92.61]) by mail.pbx.lv (MailSystem) with ESMTPSA id A76661A3839 for ; Thu, 21 Dec 2017 21:35:28 +0200 (EET) From: Roman Yeryomin To: LEDE Development List Date: Thu, 21 Dec 2017 21:35:02 +0200 Message-Id: <20171221193502.31386-1-roman@advem.lv> X-Mailer: git-send-email 2.14.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171221_173627_189862_4F798ECB X-CRM114-Status: UNSURE ( 6.08 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.1 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.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] 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 STOP but no START, enbale() will return 0 (success), 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. 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() {