forked from hugojosefson/ubuntu-install-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-android-sdk
executable file
·32 lines (23 loc) · 1.42 KB
/
install-android-sdk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
set -e
ORIGINAL_DIR="$(pwd)"
if [ ! -f /opt/android-sdk-linux/tools/android ]; then
which aptitude || sudo apt-get install -y aptitude
which curl || sudo aptitude install -y curl
which wget || sudo aptitude install -y wget
which hxpipe || sudo aptitude install -y html-xml-utils
DOWNLOAD_URL=$(curl --silent --location https://developer.android.com/studio/index.html | hxpipe | grep ^Ahref | grep sdk | grep linux | cut -d ' ' -f 3)
FILENAME=$(echo $DOWNLOAD_URL | rev | cut -d '/' -f 1 | rev)
FILE=$(dirname $(mktemp))/$FILENAME
wget --continue ${DOWNLOAD_URL} -O $FILE
DIR=$(tar tzf $FILE |head -n 1|cut -d '/' -f 1)
sudo chown $USER:$GROUP /opt
tar xzf $FILE -C /opt
fi
java -version || ./install-java
echo "If it hangs on downloading URLs, edit install-android-sdk and uncomment PROXY_ARGUMENTS"
PROXY_ARGUMENTS=""
#PROXY_ARGUMENTS="--proxy-host localhost --proxy-port 3128"
( sleep 2; while [ 1 ]; do sleep 1; echo y; done ) | /opt/android-sdk-linux/tools/android update sdk --no-ui ${PROXY_ARGUMENTS} --filter tool,platform-tool # --all --force
grep -x 'export PATH=/opt/android-sdk-linux/platform-tools:/opt/android-sdk-linux/tools:$PATH' ~/.bashrc || echo -e '\nexport PATH=/opt/android-sdk-linux/platform-tools:/opt/android-sdk-linux/tools:$PATH' >> ~/.bashrc
grep -x 'export ANDROID_HOME=/opt/android-sdk-linux' ~/.bashrc || echo -e '\nexport ANDROID_HOME=/opt/android-sdk-linux' >> ~/.bashrc