Fixup sensehat to not use sudo if not needed

This commit is contained in:
Nick O'Leary 2018-09-26 16:06:16 +01:00
parent 35cbcb3345
commit 010e8aa9b3
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 12 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-pi-sense-hat",
"version" : "0.0.17",
"version" : "0.0.18",
"description" : "A Node-RED node to interact with a Raspberry Pi Sense HAT",
"repository" : {
"type":"git",

View File

@ -1,4 +1,14 @@
#!/bin/bash
BASEDIR=$(dirname $0)
sudo python -u $BASEDIR/sensehat.py $@
ID=$(id -u)
# Avoid using sudo if we're already root
SUDO=sudo
if [ $ID -eq 0 ]
then
SUDO=""
fi
$SUDO python -u $BASEDIR/sensehat.py $@