From patchwork Mon Jun 28 07:05:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Crispin X-Patchwork-Id: 1497831 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 (no SPF record) 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; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=kJ3fX1qd; 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 4GCzHp1v7yz9sVt for ; Mon, 28 Jun 2021 17:09:25 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject: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=HKQ3cFS6Q8Qhbe+2FKZk5TXU/PtL1Ox7CHY1ep9sASE=; b=kJ3fX1qdIkOYVm vJsg+09YppmjDJRPxS1qUFRnHm22HIKyhxAPkZ2WhvVEWMhPYtUGi3S+z8m07h+Cj761i1kwOLeQp nhARgk9ujb+or3WAdl6n9nRWeYeVPF56ibfe/5BeRErk8VzN2JRHDqPCQYeQzpsDBojwYcaY5uu1X xSkg1bKtJuARmLHbjyUBAiyr50CCZugXI7bidU8hDvgSJ4IqndPU98QBmmnmodxK8uzJUrv9vexPP NzGGBvqTgpqubUmVpdUNyTY4HG45mUwU/+rwrJG0dl3rXC1sA5bVDqMAqGWVIW6DSgwwVK5gP+sE8 QOQXhO1mnKFqWkzvmXLg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lxlMY-0079qm-BL; Mon, 28 Jun 2021 07:07:22 +0000 Received: from nbd.name ([2a01:4f8:221:3d45::2]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lxlKq-00790W-Tq for openwrt-devel@lists.openwrt.org; Mon, 28 Jun 2021 07:05:38 +0000 Received: from [2a04:4540:1402:6400:2d8:61ff:fef0:a7c3] (helo=bertha9.fritz.box) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1lxlKl-00060V-Li for openwrt-devel@lists.openwrt.org; Mon, 28 Jun 2021 09:05:31 +0200 From: John Crispin To: openwrt-devel@lists.openwrt.org Subject: [PATCH] base-files: add blink and turnoff commands to the led script Date: Mon, 28 Jun 2021 09:05:20 +0200 Message-Id: <20210628070520.153877-1-john@phrozen.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210628_000537_196214_727BCB14 X-CRM114-Status: UNSURE ( 8.54 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: This allows us to make all leds blink or force all leds to off. It is also possible to force the default behaviour to not load any led states/triggers by setting system.@system[-1].leds_off to 1. Signed-off-by: John Crispin --- package/base-files/files/etc/init.d/led | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) Content analysis details: (0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This allows us to make all leds blink or force all leds to off. It is also possible to force the default behaviour to not load any led states/triggers by setting system.@system[-1].leds_off to 1. Signed-off-by: John Crispin --- package/base-files/files/etc/init.d/led | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/package/base-files/files/etc/init.d/led b/package/base-files/files/etc/init.d/led index 51cb8b5178..252bba623a 100755 --- a/package/base-files/files/etc/init.d/led +++ b/package/base-files/files/etc/init.d/led @@ -3,6 +3,9 @@ START=96 +extra_command "turnoff" "Turn all leds off" +extra_command "blink" "Blink all leds" + load_led() { local name local sysfs @@ -121,7 +124,25 @@ load_led() { } } +turnoff() { + for led in `ls /sys/class/leds/`; do + echo none > /sys/class/leds/$led/trigger + echo 0 > /sys/class/leds/$led/brightness + done +} + +blink() { + for led in `ls /sys/class/leds/`; do + echo 0 > /sys/class/leds/$led/brightness + echo timer > /sys/class/leds/$led/trigger + done +} + start() { + [ "$(uci get system.@system[-1].leds_off)" -eq 1 ] && { + turnoff + exit 0 + } [ -e /sys/class/leds/ ] && { [ -s /var/run/led.state ] && { local led trigger brightness @@ -137,5 +158,7 @@ start() { config_load system config_foreach load_led led + . /etc/diag.sh + set_state done } }