Created
April 29, 2012 18:12
-
-
Save dvberkel/2552371 to your computer and use it in GitHub Desktop.
Bash script to automatically install and update the Android SDK
This file contains hidden or 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
#! /usr/bin/env bash | |
# This script downloads the Android SDK. | |
# It depends on the following | |
# | |
# * curl | |
# * tar | |
BASE_DIR=`pwd` | |
DOWNLOAD_DIRECTORY=sdk | |
REMOTE_FILES=(http://dl.google.com/android/{android-sdk_r18-linux.tgz}) | |
echo "Installing Android SDK." | |
if [ ! -d $DOWNLOAD_DIRECTORY ] | |
then | |
echo "Creating directory" $DOWNLOAD_DIRECTORY | |
mkdir $DOWNLOAD_DIRECTORY | |
fi | |
cd $DOWNLOAD_DIRECTORY | |
for FILE in $REMOTE_FILES | |
do | |
START=`expr index $FILE '{'` | |
END=`expr index $FILE '}'` | |
LENGTH=$[ $END - $START - 1 ] | |
NAME=${FILE:START:LENGTH} | |
if [ ! -f $NAME ] | |
then | |
echo "Downloading" $FILE | |
curl $FILE -o $NAME | |
fi | |
done | |
find . -name '*.tgz' | xargs tar xfkvmz | |
while read DIR | |
do | |
cd "$DIR/tools" | |
./android --verbose update sdk --no-ui | |
done < <(find . -name 'android-sdk-*') | |
echo "Finished." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment