-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adjusted install script to function correctly if not run as sudo maki…
…ng sudo optional for pyenv or other python environment managers
- Loading branch information
1 parent
2f05bfc
commit cb5098d
Showing
1 changed file
with
12 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,15 @@ echo "This may take a couple minutes to install, grab some coffee :)" | |
echo "But don't forget to come back, I'll have questions later!" | ||
echo "" | ||
INITIALSTATE_AUTH_SVC=${INITIALSTATE_AUTH_SVC:="auth"} | ||
SUDO='' | ||
|
||
# if this script is being run by root user | ||
# then we need to modify file saving commands | ||
# to make sure ownership is correct | ||
if [ "$EUID" -eq 0 ]; then | ||
SUDO="sudo -u $SUDO_USER" | ||
fi | ||
|
||
|
||
function check_for_easy_install { | ||
if hash easy_install 2>/dev/null; then | ||
|
@@ -129,7 +138,7 @@ function download_script { | |
echo "invalid credentials, let's try that again!" | ||
download_script | ||
else | ||
echo "$python_example" | sudo -u $SUDO_USER tee "$example_location" > /dev/null | ||
echo "$python_example" | $SUDO tee "$example_location" > /dev/null | ||
fi | ||
else | ||
echo -n "Enter iot.app.initialstate.com user email: " | ||
|
@@ -158,7 +167,7 @@ function download_script { | |
echo "there's currently an issue with this endpoint, try again later or email [email protected]. Thanks!" | ||
exit 1 | ||
else | ||
echo "$python_example" | sudo -u $SUDO_USER tee "$example_location" > /dev/null | ||
echo "$python_example" | $SUDO tee "$example_location" > /dev/null | ||
fi | ||
fi | ||
|
||
|
@@ -181,7 +190,7 @@ function download_script_old { | |
echo "invalid credentials, let's try that again!" | ||
download_script | ||
else | ||
echo "$python_example" | sudo -u $SUDO_USER tee "$example_location" > /dev/null | ||
echo "$python_example" | $SUDO tee "$example_location" > /dev/null | ||
fi | ||
} | ||
|
||
|