From 700e848e9aee508b09170f169961fe175869eac1 Mon Sep 17 00:00:00 2001 From: anthraxx Date: Wed, 26 Aug 2015 22:24:51 +0200 Subject: [PATCH] don't setup (export/unexport) gpio pins on execution This fixes the issue that the new firmware recreates the whole gpio file structure on unexport/export so the ownership of all files is root:root and the gpio group is dropped. Because of this all unexport is removed from the calling scripts and a setup script is added that needs to be invoked once after startup. --- lock | 5 ----- setup | 16 ++++++++++++++++ unlock | 5 ----- 3 files changed, 16 insertions(+), 10 deletions(-) create mode 100755 setup diff --git a/lock b/lock index 66d2537..5d7bbf2 100755 --- a/lock +++ b/lock @@ -2,12 +2,7 @@ . $(dirname $(readlink "$0"))/shared echo "Initializing Space Systems..." -echo "22" > /sys/class/gpio/unexport -echo "22" > /sys/class/gpio/export -sleep 0.5 echo "Securing Communication to Space Systems..." -echo "out" > /sys/class/gpio/gpio22/direction -sleep 0.5 echo "Open Communication Channel..." # Silent, Output to /dev/null, Timeout after 5s and retry 12 times, each doubling the waitingtime until ten minutes. nohup curl -s -o /dev/null -m 5 --connect-timeout 5 --retry 12 "https://hamburg.ccc.de/dooris/status.php?apikey=${password}&action=close" >/dev/null 2>&1 & diff --git a/setup b/setup new file mode 100755 index 0000000..3d2c579 --- /dev/null +++ b/setup @@ -0,0 +1,16 @@ +#!/bin/sh + +echo "Setting up gpio: unlock" +echo "27" > /sys/class/gpio/unexport +echo "27" > /sys/class/gpio/export +echo "out" > /sys/class/gpio/gpio27/direction +chown -R root:gpio /sys/class/gpio/gpio27/* +chmod g+w /sys/class/gpio/gpio27/* + +echo "Setting up gpio: lock" +echo "27" > /sys/class/gpio/unexport +echo "22" > /sys/class/gpio/unexport +echo "22" > /sys/class/gpio/export +echo "out" > /sys/class/gpio/gpio22/direction +chown -R root:gpio /sys/class/gpio/gpio22/* +chmod g+w /sys/class/gpio/gpio22/* diff --git a/unlock b/unlock index b5def6d..59177fc 100755 --- a/unlock +++ b/unlock @@ -2,12 +2,7 @@ . $(dirname $(readlink "$0"))/shared echo "Initializing Space Systems..." -echo "27" > /sys/class/gpio/unexport -echo "27" > /sys/class/gpio/export -sleep 0.5 echo "Securing Communication to Space Systems..." -echo "out" > /sys/class/gpio/gpio27/direction -sleep 0.5 echo "Open Communication Channel..." nohup curl -s -o /dev/null -m 5 --connect-timeout 5 --retry 12 "https://hamburg.ccc.de/dooris/status.php?apikey=${password}&action=open" >/dev/null 2>&1 & echo "Unlocking Space..."