meta-digi/meta-digi-dey/recipes-digi/libdigiapix/libdigiapix-git/digiapix.sh

32 lines
1.4 KiB
Bash

#!/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