diff --git a/functions/system.sh b/functions/system.sh index 79cf59205..c240ff8f2 100644 --- a/functions/system.sh +++ b/functions/system.sh @@ -162,6 +162,14 @@ permissions_corrections() { echo "FAILED (please execute after openHAB was installed)" exit 1 fi + + if is_pine64; then + cond_redirect groupadd gpio + cond_redirect cp $BASEDIR/includes/PINE64-80-gpio-noroot.rules /etc/udev/rules.d/80-gpio-noroot.rules + cond_redirect sed -i -e '$i \chown -R root:gpio /sys/class/gpio \n' /etc/rc.local + cond_redirect sed -i -e '$i \chmod -R ug+rw /sys/class/gpio \n' /etc/rc.local + fi + cond_redirect adduser openhab dialout cond_redirect adduser openhab tty cond_redirect adduser openhab gpio @@ -217,6 +225,14 @@ pine64_platform_scripts() { fi } +pine64_fix_systeminfo_binding() { # This will maybe be fixed upstreams some day. Keep an eye open. + echo -n "$(timestamp) [openHABian] Enable PINE64 support for systeminfo binding... " + cond_redirect apt install -y udev:armhf + cond_redirect ln -s /lib/arm-linux-gnueabihf/ /lib/linux-arm + cond_redirect ln -s /lib/linux-arm/libudev.so.1 /lib/linux-arm/libudev.so + if [ $? -eq 0 ]; then echo "OK"; else echo "FAILED"; fi +} + pine64_fixed_mac() { echo -n "$(timestamp) [openHABian] Assigning fixed MAC address to eth0 (longsleep)... " if ! grep -q "mac_addr=" /boot/uEnv.txt; then diff --git a/includes/PINE64-80-gpio-noroot.rules b/includes/PINE64-80-gpio-noroot.rules new file mode 100644 index 000000000..9f84f5407 --- /dev/null +++ b/includes/PINE64-80-gpio-noroot.rules @@ -0,0 +1,7 @@ +# /etc/udev/rules.d/80-gpio-noroot.rules +# Corrects sys GPIO permissions on the Pine64 so non-root users in the gpio group can manipulate bits +# +# Change group to gpio +SUBSYSTEM=="gpio", PROGRAM="/bin/sh -c '/bin/chown -R root:gpio /sys/devices/soc.0/*pinctrl/gpio'" +# Change user permissions to ensure user and group have read/write permissions +SUBSYSTEM=="gpio", PROGRAM="/bin/sh -c '/bin/chmod -R ug+rw /sys/devices/soc.0/*pinctrl/gpio'" diff --git a/openhabian-setup.sh b/openhabian-setup.sh index 606dafe31..6fd71e630 100755 --- a/openhabian-setup.sh +++ b/openhabian-setup.sh @@ -60,6 +60,7 @@ if [[ -n "$UNATTENDED" ]]; then if is_pi; then memory_split; enable_rpi_audio; fi if is_pine64; then pine64_platform_scripts; fi if is_pine64; then pine64_fixed_mac; fi + if is_pine64; then pine64_fix_systeminfo_binding; fi basic_packages needed_packages bashrc_copy