From 8af91ee386fbcacc8d0acf7f7b7eec7b1b1c68c0 Mon Sep 17 00:00:00 2001 From: Geo Van Osterom Date: Wed, 26 Mar 2014 20:05:06 -0400 Subject: [PATCH 1/2] Check network connectivity If there is no internet connection, subsequent downloads will (obviously) not work- lets catch this error early. Current code structure allows the failure to occur but continues on as a success --- install.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/install.sh b/install.sh index 7070b41..757e6f9 100755 --- a/install.sh +++ b/install.sh @@ -51,6 +51,19 @@ die () { exit "$st" } +############ +### Check for network connection +########### +echo -e "\nChecking for internet connection...\n" +ping -c 3 github.com +rcode=$? +if [ $? -ne 0]; then + echo "------------------------------------" + echo "Unable to detect internet connection. Please check your connectivity and try again" + exit 1 +fi +echo -e "Success!\n" + ############ ### Check whether installer is up-to-date ############ From 37d2a46d45bcf27ac24711357fdff80ed4ea3b0f Mon Sep 17 00:00:00 2001 From: Geo Van Osterom Date: Wed, 26 Mar 2014 22:59:51 -0400 Subject: [PATCH 2/2] Run git as user In the off case the user has already set up an ssh key as the non-priv user, this will make sure that same user's ssh key is used to connect with github, instead of the root key which is what would be used when this script is executed via sudo. Logname gives us the initiating user's login name, instead of using root. --- update-tools-repo.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/update-tools-repo.sh b/update-tools-repo.sh index 8656069..69e3d7c 100755 --- a/update-tools-repo.sh +++ b/update-tools-repo.sh @@ -3,11 +3,12 @@ unset CDPATH myPath="$( cd "$( dirname "${BASH_SOURCE[0]}")" && pwd )" cd "$myPath" +username=$(logname) active_branch=$(git symbolic-ref -q HEAD) active_branch=${active_branch##refs/heads/} -git fetch +sudo -u $username git fetch changes=$(git log HEAD..origin/"$active_branch" --oneline) if [ -z "$changes" ]; then