#!/usr/bin/env bash

cd ~

sudo apt-get install -y unzip wget tar

echo """
export PATH=\\$PATH:/home/vagrant/platform-tools:/home/vagrant/build-tools/25.0.1:/home/vagrant/tools
export ANDROID_HOME=/home/vagrant
""" >> /etc/profile.d/vagrant_env.sh

chmod a+x /etc/profile.d/vagrant_env.sh
source /etc/profile.d/vagrant_env.sh

wynurz node5 && sudo npm install -g --unsafe-perm bower gulp cordova@6.5.0 karma &
wynurz get-adt25 &

wynurz jdk

wait %2
sudo chown -R vagrant:vagrant /home/vagrant
cd /home/vagrant
sudo chmod -R 777 tools
export
ls -la
mkdir "$ANDROID_HOME/licenses"
echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
echo -e "\n504667f4c0de7af1a06de9f4b1727b84351f2910" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
echo y | ./tools/bin/sdkmanager "build-tools;25.0.1" "build-tools;24.0.0" "platforms;android-25" "platforms;android-24" "platforms;android-23" "platform-tools" "extras;android;m2repository" "extras;google;m2repository" "extras;google;google_play_services"

wait %1
