Skip to content

Commit

Permalink
Check for sudo and ensure apt-get update is run at least once
Browse files Browse the repository at this point in the history
  • Loading branch information
rageshkrishna committed Mar 2, 2016
1 parent 1544674 commit 471b6ce
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,43 @@

readonly PROGDIR=$(readlink -m $(dirname $0))
readonly ARTIFACTS_DIR="/shippableci"
readonly SUDO=`which sudo`
IS_APT_UPDATED=false

update_apt() {
if [ "$IS_APT_UPDATED" == true ]; then return; fi
$SUDO apt-get update
IS_APT_UPDATED=true
}

check_sudo() {
echo "Looking for sudo..."
{
SUDO=$(which sudo)
} || {
echo "Could not find sudo. Installing..."
}

if [ -z "$SUDO" ]; then
update_apt
apt-get install -y sudo
echo "Installed sudo"
SUDO=$(which sudo)
else
echo "Found sudo at $SUDO"
fi
}

check_git() {
echo "Looking for git..."
{
GIT=$(which git)
} || {
echo "Could not find git. Installing git-core..."
echo "Could not find git. Installing git..."
}

if [ -z "$GIT" ]; then
$SUDO apt-get install -y git-core
update_apt
$SUDO apt-get install -y git
echo "Installed git-core"
else
echo "Found git at $GIT"
Expand All @@ -29,6 +54,7 @@ check_ssh_agent() {
}

if [ -z "$SSH_AGENT" ]; then
update_apt
$SUDO apt-get install -y openssh-client
echo "Installed openssh-client"
else
Expand All @@ -45,6 +71,7 @@ check_python() {
}

if [ -z "$PYTHON" ]; then
update_apt
$SUDO apt-get install -y python
echo "Installed python"
else
Expand Down Expand Up @@ -85,6 +112,7 @@ run_build() {
}

main() {
check_sudo
check_git
check_ssh_agent
check_python
Expand Down
Binary file modified dist/main/main
Binary file not shown.

0 comments on commit 471b6ce

Please sign in to comment.