From f911866912599a90cee1a09a76e9bf0106c8676e Mon Sep 17 00:00:00 2001 From: Geo Van Osterom Date: Sat, 29 Mar 2014 21:23:25 -0400 Subject: [PATCH 1/2] Check if in git repo --- install.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/install.sh b/install.sh index 7070b41..a4ea766 100755 --- a/install.sh +++ b/install.sh @@ -35,6 +35,11 @@ if [[ $EUID -ne 0 ]]; then exit 1 fi +# Make sure we're running in our git directory +if ![ -a .git ]; then + echo "It doesn't seem we're running from the right place. Please make sure you are running from the brewpi-tools directory" +fi + ############ ### Functions to catch/display errors during setup ############ From cd1bb2bcd01735fcd7b269ca0dd92bdd782d4ef4 Mon Sep 17 00:00:00 2001 From: Geo Van Osterom Date: Sat, 29 Mar 2014 22:36:09 -0400 Subject: [PATCH 2/2] check if install dir is brewpi-owned If the directory install.sh is being run out of is owned by root, when we run the git commands as brewpi, we will get a permission denied error as we are not allowed to be operating in that dir as a non-root user --- install.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index a4ea766..709a4f5 100755 --- a/install.sh +++ b/install.sh @@ -36,8 +36,15 @@ if [[ $EUID -ne 0 ]]; then fi # Make sure we're running in our git directory -if ![ -a .git ]; then +if [ ! -d .git ]; then echo "It doesn't seem we're running from the right place. Please make sure you are running from the brewpi-tools directory" + exit 1 +fi + +owner=$( stat -c "%U" . ) +if [ "$owner" != "pi" ] && [ "$owner" != "brewpi" ]; then + echo "This script needs to run from either the pi or brewpi userspace- try moving these files to /home/pi and running again" + exit 1 fi ############