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
2 changed files with 12 additions and 2 deletions

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 $@