From patchwork Mon Mar 18 18:21:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomasz Maciej Nowak X-Patchwork-Id: 1058042 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=fail (p=none dis=none) header.from=o2.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="iuDpOlMm"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=o2.pl header.i=@o2.pl header.b="BmBwrirb"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::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 44NPcr1s7xz9s5c for ; Tue, 19 Mar 2019 05:20:44 +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: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=H/kfL3Y8BUsW+DnC6rMI6pcan7pk30dupA0sR2dm2S8=; b=iuDpOlMmCaONH9 8d6fMnCHo7oLXiB+FlfaohyIzQc3xFXc9PjPCSLaEi4ZflevtdPQtZWTQMKvoAFrrGx4bLh3pIr+s cE8vh22ocYMXdNTo7eYR4qYzL1TymITa5+tToblOP5GEiUU/jfVduX1SnfpwgHJSFYgmwkaPL/KFt 44XvKytnpFLmXVzLT0Op15gV6BgQ+V1WicjkVVXvrklcclW8rTOZcaq1EEerJMekzFtz8ZhKPLqgE CxpCmQz8R3f1ckFCxE58Tgc7+cg2Y1ULDmaXJhwCTj7RIdLWFBeYn6tZEG8uV5EGjFYWAvgWwe/HA N2dJC8tVYePVGGVS6g6Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5ws5-0006Ps-4o; Mon, 18 Mar 2019 18:20:25 +0000 Received: from mx-out.tlen.pl ([193.222.135.175]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5ws0-0006PO-V4 for openwrt-devel@lists.openwrt.org; Mon, 18 Mar 2019 18:20:23 +0000 Received: (wp-smtpd smtp.tlen.pl 7477 invoked from network); 18 Mar 2019 19:20:15 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=o2.pl; s=1024a; t=1552933216; bh=p8OKKH7QezSr+kTG1xaGWuZT9y3fPyTCDXuR2Ysj0IA=; h=From:To:Cc:Subject; b=BmBwrirb3ONcfUos7w73ikHyT5xd6qNdJYFi1nN/y7CcMFfkKF5j8w2Lkr92EPsPd d/a+F1ViIkzSFAubKhMzxphgPOBT2m94nbQX7kflOx4ZsezKd/EnQN1foMEMeCCqjj 6ti41+ruC0qLvEUoFpjgx3nHxriks5BQZkgTVcWo= Received: from 131.ip-164-132-48.eu (HELO localhost.localdomain) (tomek_n@o2.pl@[164.132.48.131]) (envelope-sender ) by smtp.tlen.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 18 Mar 2019 19:20:15 +0100 From: Tomasz Maciej Nowak To: openwrt-devel@lists.openwrt.org Date: Mon, 18 Mar 2019 19:21:35 +0100 Message-Id: <20190318182136.23613-1-tomek_n@o2.pl> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-WP-MailID: f7bb623de7499cba651bd98472fa6dde X-WP-AV: skaner antywirusowy Poczty o2 X-WP-SPAM: NO 000000A [sTPE] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190318_112021_328481_9E2B411E X-CRM114-Status: UNSURE ( 9.24 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [193.222.135.175 listed in wl.mailspike.net] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (tomek_n[at]o2.pl) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Subject: [OpenWrt-Devel] [PATCH 1/2] base-files: add leds migration X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 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 Currently leds migration scripts in ar71xx and lantiq share a lot of logic and introducing leds migration to another target would mean copying this code, again. Therefore move common logic to library in base-files package. Suggested-by: Petr Štetiar Signed-off-by: Petr Štetiar Signed-off-by: Tomasz Maciej Nowak --- .../files/lib/functions/migrations.sh | 39 ++++++++++++++++++ .../etc/uci-defaults/04_led_migration | 39 +----------------- .../etc/uci-defaults/01_led_migration | 40 +------------------ 3 files changed, 43 insertions(+), 75 deletions(-) create mode 100644 package/base-files/files/lib/functions/migrations.sh diff --git a/package/base-files/files/lib/functions/migrations.sh b/package/base-files/files/lib/functions/migrations.sh new file mode 100644 index 0000000000..b180a0242f --- /dev/null +++ b/package/base-files/files/lib/functions/migrations.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +. /lib/functions.sh + +migrate_led_sysfs() { + local cfg="$1"; shift + local tuples="$@" + local sysfs + local name + + config_get sysfs ${cfg} sysfs + config_get name ${cfg} name + + [ -z "${sysfs}" ] && return + + for tuple in ${tuples}; do + local old=${tuple%=*} + local new=${tuple#*=} + local new_sysfs + + new_sysfs=$(echo ${sysfs} | sed "s/${old}/${new}/") + + [ "${new_sysfs}" = "${sysfs}" ] && continue + + uci set system.${cfg}.sysfs="${new_sysfs}" + + logger -t led-migration "sysfs option of LED \"${name}\" updated to ${new_sysfs}" + done; +} + +migrate_leds() { + config_load system + config_foreach migrate_led_sysfs led "$@" +} + +migrations_apply() { + local realm="$1" + [ -n "$(uci changes ${realm})" ] && uci -q commit ${realm} +} diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/04_led_migration b/target/linux/ar71xx/base-files/etc/uci-defaults/04_led_migration index 4dd224b549..5b78d9a910 100644 --- a/target/linux/ar71xx/base-files/etc/uci-defaults/04_led_migration +++ b/target/linux/ar71xx/base-files/etc/uci-defaults/04_led_migration @@ -3,43 +3,8 @@ # Copyright (C) 2013 OpenWrt.org # -LED_OPTIONS_CHANGED=0 - . /lib/functions.sh - -do_led_update_sysfs() -{ - local cfg=$1; shift - local tuples="$@" - local sysfs - local name - - config_get sysfs $cfg sysfs - config_get name $cfg name - - [ -z "$sysfs" ] && return - - for tuple in $tuples; do - local old=${tuple%=*} - local new=${tuple#*=} - local new_sysfs - - new_sysfs=$(echo ${sysfs} | sed "s/${old}/${new}/") - - [ "$new_sysfs" = "$sysfs" ] && continue - - uci set system.${cfg}.sysfs="${new_sysfs}" - LED_OPTIONS_CHANGED=1 - - logger -t led-migration "sysfs option of LED \"${name}\" updated to ${new_sysfs}" - done; -} - -migrate_leds() -{ - config_load system - config_foreach do_led_update_sysfs led "$@" -} +. /lib/functions/migrations.sh board=$(board_name) @@ -76,6 +41,6 @@ wnr612-v2) ;; esac -[ "$LED_OPTIONS_CHANGED" = "1" ] && uci commit system +migrations_apply system exit 0 diff --git a/target/linux/lantiq/base-files/etc/uci-defaults/01_led_migration b/target/linux/lantiq/base-files/etc/uci-defaults/01_led_migration index dc594e35e9..b14751b6e6 100644 --- a/target/linux/lantiq/base-files/etc/uci-defaults/01_led_migration +++ b/target/linux/lantiq/base-files/etc/uci-defaults/01_led_migration @@ -3,37 +3,8 @@ # Copyright (C) 2013 OpenWrt.org # -LED_OPTIONS_CHANGED=0 - . /lib/functions.sh - -do_led_update_sysfs() -{ - local cfg=$1; shift - local tuples="$@" - local sysfs - local name - - config_get sysfs $cfg sysfs - config_get name $cfg name - - [ -z "$sysfs" ] && return - - for tuple in $tuples; do - local old=${tuple%=*} - local new=${tuple#*=} - local new_sysfs - - new_sysfs=$(echo ${sysfs} | sed "s/${old}/${new}/") - - [ "$new_sysfs" = "$sysfs" ] && continue - - uci set system.${cfg}.sysfs="${new_sysfs}" - LED_OPTIONS_CHANGED=1 - - logger -t led-migration "sysfs option of LED \"${name}\" updated to ${new_sysfs}" - done; -} +. /lib/functions/migrations.sh do_internet_led_rename() { @@ -45,16 +16,9 @@ do_internet_led_rename() uci rename system.led_internet=led_dsl uci set system.led_dsl.name=dsl - LED_OPTIONS_CHANGED=1 logger -t led-migration "internet led renamed to dsl" } -migrate_leds() -{ - config_load system - config_foreach do_led_update_sysfs led "$@" -} - case "$(board_name)" in arcadyan,arv452cqw|\ arcadyan,arv7510pw22|\ @@ -77,6 +41,6 @@ netgear,dgn3500b) ;; esac -[ "$LED_OPTIONS_CHANGED" = "1" ] && uci commit system +migrations_apply system exit 0 From patchwork Mon Mar 18 18:21:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Maciej Nowak X-Patchwork-Id: 1058043 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=fail (p=none dis=none) header.from=o2.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PwCS9SiE"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="cyxHTPFq"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=o2.pl header.i=@o2.pl header.b="x/B6IDQ9"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::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 44NPdf13qNz9s7h for ; Tue, 19 Mar 2019 05:21:25 +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: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:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=+ruVHLX/RD1a+9Yg76ROd44Nn56OEe3AdV+DAA+eF9I=; b=PwCS9SiE7n0XqULJ//eQwdBZeg POhiL4/qW4FEayrZXdvUHFoxIVB0DVhHX1Sxxuwknwe4fNNOX8pWDg/30/G4i1IoTsT0ofv0r5+J8 7a7etjOLAhQQTZmS+pVGD9YWB+BwUL3jb7V6OJsKfgKGXjAc1jdVMYALrg+rtyrdwWv03xWxekCig HyjS58hrdNnbEIo2UOYrtJ2D/TPzOTQKb4yTPhrMxAvMOKr/eI1cz7pUMXfFTEjOCk6K8iTo5cLlY 0T0HogBy0ZeNZv3SlVBfMm+yd1zu7SKwEQB8KG3OCGPmemrJySqmeDt7hYNejCOnjHoup9Pdu6fId yuktB6Ag==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5wsq-0006jh-FF; Mon, 18 Mar 2019 18:21:12 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5wsp-0006jX-2F for openwrt-devel@bombadil.infradead.org; Mon, 18 Mar 2019 18:21:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=1V8f01mKNrvIq+PMRonNQ54ntJcmcVTQhdmV183mGMI=; b=cyxHTPFq+eDTKkgyn9h+5fxqhf NCCVSCMO++di/o256ujaEfIWKZMerVzo5bBuHi4P96MZ9YjZiJxA0WsPQZMCL1oAt4xZeq2qHDFIT Npi8KUC8v0vM2nfi2mSHxgr6LCH8oNSGVOFivxp2T5EBofhZvcJezAHOmdK1qD2o94eo1sxie6USn Hs2vtfC4D1QA5MBYYIeKoLaJOo18D2CR1D4BqfmrbZ4kUlnRLi2YjimzUhwnQ1sN8k0JF5us5pIVN pD4mctjrP19AoDtasdVVVMQuZzxnztQnF7EVhtEVmgny9RSJHHP3D4DzOznvnE2S4U3b+L45O9wVq d1/YHOWA==; Received: from mx-out.tlen.pl ([193.222.135.175]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5wsk-0007WW-Q3 for openwrt-devel@lists.openwrt.org; Mon, 18 Mar 2019 18:21:09 +0000 Received: (wp-smtpd smtp.tlen.pl 8389 invoked from network); 18 Mar 2019 19:20:16 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=o2.pl; s=1024a; t=1552933216; bh=1V8f01mKNrvIq+PMRonNQ54ntJcmcVTQhdmV183mGMI=; h=From:To:Subject; b=x/B6IDQ9DYSQ2HxFLw/z//B0ATc3StD48gKdRaUU+IexGAneuiKAQHsm/u18I0nSI pri2ftcIs2Z8/vWqqihivnuVLVkm2QvQKLDMVcqhREXm5jlxyvG9AxV2C/+RcqLW74 mERAexyrMZfh+D84ZJlSJWD2IOF0a+MxLc/B0EbM= Received: from 131.ip-164-132-48.eu (HELO localhost.localdomain) (tomek_n@o2.pl@[164.132.48.131]) (envelope-sender ) by smtp.tlen.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 18 Mar 2019 19:20:16 +0100 From: Tomasz Maciej Nowak To: openwrt-devel@lists.openwrt.org Date: Mon, 18 Mar 2019 19:21:36 +0100 Message-Id: <20190318182136.23613-2-tomek_n@o2.pl> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318182136.23613-1-tomek_n@o2.pl> References: <20190318182136.23613-1-tomek_n@o2.pl> MIME-Version: 1.0 X-WP-MailID: 2b97c18f55ae2082e4613cba3e872e11 X-WP-AV: skaner antywirusowy Poczty o2 X-WP-SPAM: NO 000000A [YZOE] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190318_142107_166834_BBCEF5EB X-CRM114-Status: UNSURE ( 8.23 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [193.222.135.175 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (tomek_n[at]o2.pl) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain Subject: [OpenWrt-Devel] [PATCH 2/2] ath79: engenius epg5000: add leds migration script X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: 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 With transition from ar71xx to ath79 some of devices change their naming of LEDs. When upgrading from ar71xx target images this will require the user to adjust previously working configuration. This commit adds migration script which can be used to rename old names to new ones. With this previously working configuration will be automatically adjusted, wihtout user intervention. This commit adds migration case for EnGenius EPG5000, the wireless LEDs names have changed from epg5000:blue:wlan2-g and epg5000:blue:wlan-5g to epg5000:blue:wlan2g and epg5000:blue:wlan5g. Signed-off-by: Tomasz Maciej Nowak --- .../base-files/etc/uci-defaults/04_led_migration | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 target/linux/ath79/base-files/etc/uci-defaults/04_led_migration diff --git a/target/linux/ath79/base-files/etc/uci-defaults/04_led_migration b/target/linux/ath79/base-files/etc/uci-defaults/04_led_migration new file mode 100644 index 0000000000..2ca87ccb34 --- /dev/null +++ b/target/linux/ath79/base-files/etc/uci-defaults/04_led_migration @@ -0,0 +1,16 @@ +#!/bin/sh + +. /lib/functions.sh +. /lib/functions/migrations.sh + +board=$(board_name) + +case "$board" in +engenius,epg5000) + migrate_leds ":wlan-2g=:wlan2g" ":wlan-5g=:wlan5g" + ;; +esac + +migrations_apply system + +exit 0