libdigiapix: add udev rules for digiapix API
These udev rules allow to use the digiapix API by a normal user that belongs to the 'digiapix' group. https://jira.digi.com/browse/DEL-5232 Signed-off-by: Javier Viguera <javier.viguera@digi.com>
This commit is contained in:
parent
1104e5737f
commit
a45357940a
|
|
@ -0,0 +1,22 @@
|
|||
# libdigiapix: configure interfaces so they can be used by group 'digiapix'
|
||||
|
||||
SUBSYSTEM=="i2c-dev", GROUP="digiapix", MODE="0660"
|
||||
SUBSYSTEM=="spidev", GROUP="digiapix", MODE="0660"
|
||||
|
||||
#
|
||||
# Use two different rules for GPIO's.
|
||||
#
|
||||
# 1. The first rule (gpiochip0) allows to configure the GROUP and MODE of
|
||||
# the 'export' and 'unexport' files. This is basically executed once on
|
||||
# boot and it's needed so a normal user (with group 'digiapix')
|
||||
# is able to export/unexport gpios.
|
||||
#
|
||||
# 2. The second rule configures the GROUP and MODE of the sysfs files that
|
||||
# are created whenever a 'gpio' is exported.
|
||||
#
|
||||
# This way we filter out multiple gpiochipX events that we don't want to attend
|
||||
#
|
||||
SUBSYSTEM=="gpio", KERNEL=="gpiochip0", ACTION=="add", RUN="/etc/udev/scripts/digiapix.sh"
|
||||
SUBSYSTEM=="gpio", KERNEL!="gpiochip*", ACTION=="add", RUN="/etc/udev/scripts/digiapix.sh"
|
||||
|
||||
SUBSYSTEM=="pwm", ACTION=="add", RUN="/etc/udev/scripts/digiapix.sh"
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2017, Digi International Inc.
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, you can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
|
||||
if basename "${DEVPATH}" | grep -qs "gpiochip0$"; then
|
||||
# Use 'gpiochip0' event to set group and mode for 'export/unexport' files
|
||||
chown root:digiapix /sys/class/gpio/export /sys/class/gpio/unexport
|
||||
chmod g+w /sys/class/gpio/export /sys/class/gpio/unexport
|
||||
elif basename "${DEVPATH}" | grep -qs "pwmchip[0-9]\+$"; then
|
||||
# Set group and mode for pwmchip's 'export/unexport' files
|
||||
chown root:digiapix /sys${DEVPATH}/export /sys${DEVPATH}/unexport
|
||||
chmod g+w /sys${DEVPATH}/export /sys${DEVPATH}/unexport
|
||||
else
|
||||
# Change group and mode of the sysfs files created whenever a 'gpioX'
|
||||
# or 'pwmX' is exported
|
||||
chown -h root:digiapix /sys${DEVPATH}/*
|
||||
chmod g+w /sys${DEVPATH}/*
|
||||
fi
|
||||
|
|
@ -18,7 +18,9 @@ LIBDIGIAPIX_GIT_URI ?= "${@base_conditional('DIGI_INTERNAL_GIT', '1' , '${LIBDIG
|
|||
|
||||
SRC_URI = " \
|
||||
${LIBDIGIAPIX_GIT_URI};branch=${SRCBRANCH} \
|
||||
file://99-digiapix.rules \
|
||||
file://board.conf \
|
||||
file://digiapix.sh \
|
||||
"
|
||||
|
||||
S = "${WORKDIR}/git"
|
||||
|
|
@ -28,7 +30,12 @@ inherit pkgconfig useradd
|
|||
do_install() {
|
||||
oe_runmake 'DESTDIR=${D}' install
|
||||
|
||||
install -d ${D}${sysconfdir}/
|
||||
# Install udev rules for digiapix
|
||||
install -d ${D}${sysconfdir}/udev/rules.d ${D}${sysconfdir}/udev/scripts
|
||||
install -m 0644 ${WORKDIR}/99-digiapix.rules ${D}${sysconfdir}/udev/rules.d/
|
||||
install -m 0755 ${WORKDIR}/digiapix.sh ${D}${sysconfdir}/udev/scripts/
|
||||
|
||||
# Install board config file
|
||||
install -m 0644 ${WORKDIR}/board.conf ${D}${sysconfdir}/libdigiapix.conf
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue