Skip to content

Instantly share code, notes, and snippets.

@tahl
Created March 11, 2012 11:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tahl/2016019 to your computer and use it in GitHub Desktop.
Save tahl/2016019 to your computer and use it in GitHub Desktop.
andadb2.1
#!/bin/bash
#
#Android ADB Installer 2.1 for Linux Mint 11 and Ubuntu 11.04
#New: MTP Support and adb right click to push support
#Script written by @ArchDukeDoug and parts of @_CorCor67's scripting code used with permission as well.
#ADB Push script adapted to work from MappaM and pietro_spina's code on the xda-developer's forums.
#Thanks to @BoneyNicole, @tabbwabb, and @animedbz16 for putting up with me and proofreading and/or testing the script.
#Script version: 2.1
menu=
until [ "$menu" = "0" ]; do
clear
echo ""
echo "***************************************************"
echo "** Android ADB Installer 2.1 **"
echo "** Main Menu **"
echo "***************************************************"
echo "** 1 - Resolve dependencies ( Run this first )**"
echo "** 2 - Install Android SDK & Android NDK **"
echo "** 3 - Install adb & fastboot **"
echo "** 4 - Nautilus right-click to adb push support **"
echo "** 5 - MTP Support for Galaxy Nexus **"
echo "** 6 - Create/update the 99-android.rules file **"
echo "** 7 - Install aapt & apktool **"
echo "** 8 - Install git-repo **"
echo "** 9 - Help and information **"
echo "** 0 - Exit **"
echo "***************************************************"
echo ""
echo -n "Enter selection: "
read menu
echo ""
case $menu in
#############################################################
#############################################################
1 )
if [ ! -f /var/lib/apt/lists/archive.canonical.com_dists_oneiric_partner_binary-i386_Packages ]
then sudo -v; sudo add-apt-repository "deb http://archive.canonical.com/ $(lsb_release -s -c) partner"
else echo "repository already exists."
fi
sudo -v; sudo apt-get update
#Determine if the operating system is 32 or 64-bit and then install ia32-libs if necessary.
d=ia32-libs
if [[ `getconf LONG_BIT` = "64" ]];
then
echo "64-bit operating system detected. Checking to see if $d is installed."
if [[ $(dpkg-query -f'${Status}' --show $d 2>/dev/null) = *\ installed ]]; then
echo "$d already installed."
else
echo "Installing now..."
sudo -v; sudo apt-get --force-yes -y install $d
fi
else
echo "32-bit operating system detected. Skipping."
fi
#Check if openjdk-7-jre-headless is installed
c=openjdk-7-jre-headless
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if openjdk-7-jre is installed
c=openjdk-7-jdk
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if Eclipse is installed
c=eclipse
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if Python is installed
c=python
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if git-core is installed
c=git-core
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if gnupupg is installed
c=gnupg
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if flex is installed
c=flex
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if bison is installed
c=bison
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if gperf is installed
c=gperf
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if build-essential is installed
c=build-essential
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if zip is installed
c=zip
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if curl is installed
c=curl
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if zlib1g-dev is installed
c=zlib1g-dev
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if libc6-dev is installed
c=libc6-dev
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if lib32ncurses5-dev is installed
c=lib32ncurses5-dev
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if x11proto-core-dev is installed
c=x11proto-core-dev
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if libx11-dev is installed
c=libx11-dev
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if lib32readline5-dev is installed
c=lib32readline5-dev
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if lib32z-dev is installed
c=lib32z-dev
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if libgl1-mesa is installed
c=libgl1-mesa-dev
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if g++-multilib is installed
c=g++-multilib
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if mingw32 is installed
c=mingw32
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if tofrodos is installed
c=tofrodos
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if python-markdown is installed
c=python-markdown
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check if libxml2-utils is installed
c=libxml2-utils
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
#Check for ~/bin
if [ ! -d ~/bin ]
then
mkdir ~/bin
else
echo "~/bin already exists. Skipping."
fi
#Set ~/bin to path
if grep -q /home/$USER/bin /home/$USER/.bashrc;
then
echo "$HOME/bin set up already."
else
echo "PATH=$PATH:$HOME/bin" >> $HOME/.bashrc
fi
#Create a symlink for libX11
if [ -f "/usr/lib/i386-linux-gnu/libX11.so" ]
then
sudo -v; sudo rm /usr/lib/i386-linux-gnu/libX11.so; sudo -v; sudo ln -s /usr/lib/i386-linux-gnu/libX11.so.6 /usr/lib/i386-linux-gnu/libX11.so
else
sudo -v; sudo ln -s /usr/lib/i386-linux-gnu/libX11.so.6 /usr/lib/i386-linux-gnu/libX11.so
fi
;;
#############################################################
#############################################################
2 )
#Download and install the Android SDK
if [ ! -d "/usr/local/android-sdk" ]; then
for a in $( wget -qO- http://developer.android.com/sdk/index.html | egrep -o "http://dl.google.com[^\"']*linux.tgz" ); do
wget $a && tar --wildcards --no-anchored -xvzf android-sdk_*-linux.tgz; sudo -v; sudo mv android-sdk-linux /usr/local/android-sdk; sudo -v; sudo chmod 777 -R /usr/local/android-sdk; rm android-sdk_*-linux.tgz;
done
else
echo "Android SDK already installed to /usr/local/android-sdk. Skipping."
fi
#Create Symlink for Dalvik Debug Monitor Server (DDMS)
if [ -f /bin/ddms ]
then
sudo -v; sudo rm /bin/ddms; sudo -v; sudo ln -s /usr/local/android-sdk/tools/ddms /bin/ddms
else
sudo -v; sudo ln -s /usr/local/android-sdk/tools/ddms /bin/ddms
fi
#Download and install the Android NDK.
if [ ! -d "/usr/local/android-ndk" ]; then
for b in $( wget -qO- http://developer.android.com/sdk/ndk/index.html | egrep -o "http://dl.google.com[^\"']*linux-x86.tar.bz2"
); do wget $b && tar --wildcards --no-anchored -xjvf android-ndk-*-linux-x86.tar.bz2; sudo -v; sudo mv android-ndk-*/ /usr/local/android-ndk; sudo -v; sudo chmod 777 -R /usr/local/android-ndk; rm android-ndk-*-linux-x86.tar.bz2;
done
else
echo "Android NDK already installed to /usr/local/android-ndk. Skipping."
fi
;;
#############################################################
#############################################################
3 )
#Create a symlink for Android Debug Bridge (adb)
if [ -f /bin/adb ];
then
sudo -v; sudo rm /bin/adb; sudo -v; sudo ln -s /usr/local/android-sdk/platform-tools/adb /bin/adb
else
sudo -v; sudo ln -s /usr/local/android-sdk/platform-tools/adb /bin/adb
fi
#Create a symlink for Fastboot
if [ -f /bin/fastboot ];
then
sudo -v; sudo rm /bin/fastboot; sudo -v; sudo ln -s /usr/local/android-sdk/platform-tools/fastboot /bin/fastboot
else
sudo -v; sudo ln -s /usr/local/android-sdk/platform-tools/fastboot /bin/fastboot
fi
#Installing adb!
if [ ! -f "/usr/local/android-sdk/platform-tools/adb" ];
then
mkdir $HOME/.android; touch $HOME/.android/androidtool.cfg; echo "sdkman.force.http=true" > $HOME/.android/androidtool.cfg; nohup /usr/local/android-sdk/tools/android update sdk > /dev/null 2>&1
else
echo "Android Debug Bridge already detected."
fi
;;
#############################################################
#############################################################
4 )
#ADB Install APK
nautilus="adb install APKs" #name of right click command
if [ ! -f "/home/$USER/.gnome2/nautilus-scripts/$nautilus" ];
then
touch "$nautilus"; chmod +x "$nautilus"; echo "#!/bin/sh" > "$nautilus";
echo "" >> "$nautilus"; echo "i=1" >> "$nautilus"; echo "(" >> "$nautilus";
echo "for thing in \"\$@\"" >> "$nautilus";
echo "do" >> "$nautilus";
echo "" >> "$nautilus";
echo -e '\t echo "15" ; sleep 1' >> "$nautilus";
echo -e '\t echo $(($i * 100 / $#))' >>"$nautilus";
echo -e '\t echo "# Installing \"${thing}\"" ;' >>"$nautilus";
echo -e '\t adb install "${thing}"' >>"$nautilus";
echo -e "\t i=\$((\$i+1))" >>"$nautilus";
echo 'done; i=$(($i-1)) ; echo "# $i APKs installed." ) | zenity --progress --pulsate --auto-kill --width=300 --text "Installing files..." --title "Installing APKs"' >>"$nautilus";
mv "$nautilus" /home/$USER/.gnome2/nautilus-scripts/
else
touch "$nautilus"; chmod +x "$nautilus"; echo "#!/bin/sh" > "$nautilus";
echo "" >> "$nautilus"; echo "i=1" >> "$nautilus"; echo "(" >> "$nautilus";
echo "for thing in \"\$@\"" >> "$nautilus";
echo "do" >> "$nautilus";
echo "" >> "$nautilus";
echo -e '\t echo "15" ; sleep 1' >> "$nautilus";
echo -e '\t echo $(($i * 100 / $#))' >>"$nautilus";
echo -e '\t echo "# Installing \"${thing}\"" ;' >>"$nautilus";
echo -e '\t adb install "${thing}"' >>"$nautilus";
echo -e "\t i=\$((\$i+1))" >>"$nautilus";
echo 'done; i=$(($i-1)) ; echo "# $i APKs installed." ) | zenity --progress --pulsate --auto-kill --width=300 --text "Installing files..." --title "Installing APKs"' >>"$nautilus";
mv "$nautilus" /home/$USER/.gnome2/nautilus-scripts/
fi
#ADB Push to Downloads
nautilus="adb push to Download" #name of right click command
adbpath="/sdcard/Download" # path on phone to push to
if [ ! -f "/home/$USER/.gnome2/nautilus-scripts/$nautilus" ];
then
touch "$nautilus"; chmod +x "$nautilus"; echo "#!/bin/sh" > "$nautilus";
echo "" >> "$nautilus"; echo "i=1" >> "$nautilus"; echo "(" >> "$nautilus";
echo "adbpath=\"$adbpath\"" >> "$nautilus";
echo "for thing in \"\$@\"" >> "$nautilus";
echo "do" >> "$nautilus";
echo "" >> "$nautilus";
echo 'echo "15" ; sleep 1' >>"$nautilus";
echo 'echo $(($i * 100 / $#))' >>"$nautilus";
echo 'echo "# Pushing \"${thing}\"" ;' >>"$nautilus";
echo 'adb push "${thing}" $adbpath' >>"$nautilus";
echo "i=\$((\$i+1))" >>"$nautilus";
echo 'done; i=$(($i-1)) ; echo"# $i files pushed." ) | zenity --progress --pulsate --auto-kill --width=300 --text "Copying files..." --title "Pushing files to $adbpath"' >>"$nautilus";
mv "$nautilus" /home/$USER/.gnome2/nautilus-scripts/
else
touch "$nautilus"; chmod +x "$nautilus"; echo "#!/bin/sh" > "$nautilus";
echo "adbpath=\"$adbpath\"" >> "$nautilus";
echo "" >> "$nautilus"; echo "i=1" >> "$nautilus"; echo "(" >> "$nautilus";
echo "for thing in \"\$@\"" >> "$nautilus";
echo "do" >> "$nautilus";
echo "" >> "$nautilus";
echo -e '\t echo "15" ; sleep 1' >> "$nautilus";
echo -e '\t echo $(($i * 100 / $#))' >>"$nautilus";
echo -e '\t echo "# Pushing \"${thing}\"" ;' >>"$nautilus";
echo -e '\t adb push "${thing}" $adbpath' >>"$nautilus";
echo -e "\t i=\$((\$i+1))" >>"$nautilus";
echo 'done; i=$(($i-1)) ; echo "# $i files pushed." ) | zenity --progress --pulsate --auto-kill --width=300 --text "Copying files..." --title "Pushing files to $adbpath"' >>"$nautilus";
mv "$nautilus" /home/$USER/.gnome2/nautilus-scripts/
fi
#ADB Push to SDCard
nautilus="adb push to SDCard" #name of right click command
adbpath="/sdcard/" # path on phone to push to
if [ ! -f "/home/$USER/.gnome2/nautilus-scripts/$nautilus" ];
then
touch "$nautilus"; chmod +x "$nautilus"; echo "#!/bin/sh" > "$nautilus";
echo "" >> "$nautilus"; echo "i=1" >> "$nautilus"; echo "(" >> "$nautilus";
echo "adbpath=\"$adbpath\"" >> "$nautilus";
echo "for thing in \"\$@\"" >> "$nautilus";
echo "do" >> "$nautilus";
echo "" >> "$nautilus";
echo 'echo "15" ; sleep 1' >>"$nautilus";
echo 'echo $(($i * 100 / $#))' >>"$nautilus";
echo 'echo "# Pushing \"${thing}\"" ;' >>"$nautilus";
echo 'adb push "${thing}" $adbpath' >>"$nautilus";
echo "i=\$((\$i+1))" >>"$nautilus";
echo 'done; i=$(($i-1)) ; echo"# $i files pushed." ) | zenity --progress --pulsate --auto-kill --width=300 --text "Copying files..." --title "Pushing files to $adbpath"' >>"$nautilus";
mv "$nautilus" /home/$USER/.gnome2/nautilus-scripts/
else
touch "$nautilus"; chmod +x "$nautilus"; echo "#!/bin/sh" > "$nautilus";
echo "adbpath=\"$adbpath\"" >> "$nautilus";
echo "" >> "$nautilus"; echo "i=1" >> "$nautilus"; echo "(" >> "$nautilus";
echo "for thing in \"\$@\"" >> "$nautilus";
echo "do" >> "$nautilus";
echo "" >> "$nautilus";
echo -e '\t echo "15" ; sleep 1' >> "$nautilus";
echo -e '\t echo $(($i * 100 / $#))' >>"$nautilus";
echo -e '\t echo "# Pushing \"${thing}\"" ;' >>"$nautilus";
echo -e '\t adb push "${thing}" $adbpath' >>"$nautilus";
echo -e "\t i=\$((\$i+1))" >>"$nautilus";
echo 'done; i=$(($i-1)) ; echo "# $i files pushed." ) | zenity --progress --pulsate --auto-kill --width=300 --text "Copying files..." --title "Pushing files to $adbpath"' >>"$nautilus";
mv "$nautilus" /home/$USER/.gnome2/nautilus-scripts/
fi
#ADB Push to Movies
nautilus="adb push to Movies" #name of right click command
adbpath="/sdcard/Movies" # path on phone to push to
if [ ! -f "/home/$USER/.gnome2/nautilus-scripts/$nautilus" ];
then
touch "$nautilus"; chmod +x "$nautilus"; echo "#!/bin/sh" > "$nautilus";
echo "" >> "$nautilus"; echo "i=1" >> "$nautilus"; echo "(" >> "$nautilus";
echo "adbpath=\"$adbpath\"" >> "$nautilus";
echo "for thing in \"\$@\"" >> "$nautilus";
echo "do" >> "$nautilus";
echo "" >> "$nautilus";
echo 'echo "15" ; sleep 1' >>"$nautilus";
echo 'echo $(($i * 100 / $#))' >>"$nautilus";
echo 'echo "# Pushing \"${thing}\"" ;' >>"$nautilus";
echo 'adb push "${thing}" $adbpath' >>"$nautilus";
echo "i=\$((\$i+1))" >>"$nautilus";
echo 'done; i=$(($i-1)) ; echo"# $i files pushed." ) | zenity --progress --pulsate --auto-kill --width=300 --text "Copying files..." --title "Pushing files to $adbpath"' >>"$nautilus";
mv "$nautilus" /home/$USER/.gnome2/nautilus-scripts/
else
touch "$nautilus"; chmod +x "$nautilus"; echo "#!/bin/sh" > "$nautilus";
echo "adbpath=\"$adbpath\"" >> "$nautilus";
echo "" >> "$nautilus"; echo "i=1" >> "$nautilus"; echo "(" >> "$nautilus";
echo "for thing in \"\$@\"" >> "$nautilus";
echo "do" >> "$nautilus";
echo "" >> "$nautilus";
echo -e '\t echo "15" ; sleep 1' >> "$nautilus";
echo -e '\t echo $(($i * 100 / $#))' >>"$nautilus";
echo -e '\t echo "# Pushing \"${thing}\"" ;' >>"$nautilus";
echo -e '\t adb push "${thing}" $adbpath' >>"$nautilus";
echo -e "\t i=\$((\$i+1))" >>"$nautilus";
echo 'done; i=$(($i-1)) ; echo "# $i files pushed." ) | zenity --progress --pulsate --auto-kill --width=300 --text "Copying files..." --title "Pushing files to $adbpath"' >>"$nautilus";
mv "$nautilus" /home/$USER/.gnome2/nautilus-scripts/
fi
#ADB Push to Music
nautilus="adb push to Music" #name of right click command
adbpath="/sdcard/Music" # path on phone to push to
if [ ! -f "/home/$USER/.gnome2/nautilus-scripts/$nautilus" ];
then
touch "$nautilus"; chmod +x "$nautilus"; echo "#!/bin/sh" > "$nautilus";
echo "" >> "$nautilus"; echo "i=1" >> "$nautilus"; echo "(" >> "$nautilus";
echo "adbpath=\"$adbpath\"" >> "$nautilus";
echo "for thing in \"\$@\"" >> "$nautilus";
echo "do" >> "$nautilus";
echo "" >> "$nautilus";
echo 'echo "15" ; sleep 1' >>"$nautilus";
echo 'echo $(($i * 100 / $#))' >>"$nautilus";
echo 'echo "# Pushing \"${thing}\"" ;' >>"$nautilus";
echo 'adb push "${thing}" $adbpath' >>"$nautilus";
echo "i=\$((\$i+1))" >>"$nautilus";
echo 'done; i=$(($i-1)) ; echo"# $i files pushed." ) | zenity --progress --pulsate --auto-kill --width=300 --text "Copying files..." --title "Pushing files to $adbpath"' >>"$nautilus";
mv "$nautilus" /home/$USER/.gnome2/nautilus-scripts/
else
touch "$nautilus"; chmod +x "$nautilus"; echo "#!/bin/sh" > "$nautilus";
echo "adbpath=\"$adbpath\"" >> "$nautilus";
echo "" >> "$nautilus"; echo "i=1" >> "$nautilus"; echo "(" >> "$nautilus";
echo "for thing in \"\$@\"" >> "$nautilus";
echo "do" >> "$nautilus";
echo "" >> "$nautilus";
echo -e '\t echo "15" ; sleep 1' >> "$nautilus";
echo -e '\t echo $(($i * 100 / $#))' >>"$nautilus";
echo -e '\t echo "# Pushing \"${thing}\"" ;' >>"$nautilus";
echo -e '\t adb push "${thing}" $adbpath' >>"$nautilus";
echo -e "\t i=\$((\$i+1))" >>"$nautilus";
echo 'done; i=$(($i-1)) ; echo "# $i files pushed." ) | zenity --progress --pulsate --auto-kill --width=300 --text "Copying files..." --title "Pushing files to $adbpath"' >>"$nautilus";
mv "$nautilus" /home/$USER/.gnome2/nautilus-scripts/
fi
#ADB Push to Pictures
nautilus="adb push to Pictures" #name of right click command
adbpath="/sdcard/Pictures" # path on phone to push to
if [ ! -f "/home/$USER/.gnome2/nautilus-scripts/$nautilus" ];
then
touch "$nautilus"; chmod +x "$nautilus"; echo "#!/bin/sh" > "$nautilus";
echo "" >> "$nautilus"; echo "i=1" >> "$nautilus"; echo "(" >> "$nautilus";
echo "adbpath=\"$adbpath\"" >> "$nautilus";
echo "for thing in \"\$@\"" >> "$nautilus";
echo "do" >> "$nautilus";
echo "" >> "$nautilus";
echo 'echo "15" ; sleep 1' >>"$nautilus";
echo 'echo $(($i * 100 / $#))' >>"$nautilus";
echo 'echo "# Pushing \"${thing}\"" ;' >>"$nautilus";
echo 'adb push "${thing}" $adbpath' >>"$nautilus";
echo "i=\$((\$i+1))" >>"$nautilus";
echo 'done; i=$(($i-1)) ; echo"# $i files pushed." ) | zenity --progress --pulsate --auto-kill --width=300 --text "Copying files..." --title "Pushing files to $adbpath"' >>"$nautilus";
mv "$nautilus" /home/$USER/.gnome2/nautilus-scripts/
else
touch "$nautilus"; chmod +x "$nautilus"; echo "#!/bin/sh" > "$nautilus";
echo "adbpath=\"$adbpath\"" >> "$nautilus";
echo "" >> "$nautilus"; echo "i=1" >> "$nautilus"; echo "(" >> "$nautilus";
echo "for thing in \"\$@\"" >> "$nautilus";
echo "do" >> "$nautilus";
echo "" >> "$nautilus";
echo -e '\t echo "15" ; sleep 1' >> "$nautilus";
echo -e '\t echo $(($i * 100 / $#))' >>"$nautilus";
echo -e '\t echo "# Pushing \"${thing}\"" ;' >>"$nautilus";
echo -e '\t adb push "${thing}" $adbpath' >>"$nautilus";
echo -e "\t i=\$((\$i+1))" >>"$nautilus";
echo 'done; i=$(($i-1)) ; echo "# $i files pushed." ) | zenity --progress --pulsate --auto-kill --width=300 --text "Copying files..." --title "Pushing files to $adbpath"' >>"$nautilus";
mv "$nautilus" /home/$USER/.gnome2/nautilus-scripts/
fi
#ADB Push To...
nautilus="adb push to ..." #name of right click command
if [ ! -f "/home/$USER/.gnome2/nautilus-scripts/$nautilus" ];
then
touch "$nautilus"; chmod +x "$nautilus"; echo "#!/bin/sh" > "$nautilus";
echo 'adbpath=`zenity --entry --text "Enter the directory on the Android device" --entry-text="/sdcard/"`' >> "$nautilus";
echo "" >> "$nautilus";
echo 'for i in "" "/"' >> "$nautilus";
echo 'do' >> "$nautilus";
echo "" >> "$nautilus";
echo -e '\t if [ "$i" = "$adbpath" ]' >> "$nautilus";
echo -e '\t then' >> "$nautilus";
echo -e '\t\t zenity --error --text "You have to copy the files somewhere..."' >> "$nautilus";
echo -e 'fi' >> "$nautilus";
echo 'done' >> "$nautilus";
echo "" >> "$nautilus"; echo "i=1" >> "$nautilus"; echo "(" >> "$nautilus";
echo "for thing in \"\$@\"" >> "$nautilus";
echo "do" >> "$nautilus";
echo "" >> "$nautilus";
echo 'echo "15" ; sleep 1' >>"$nautilus";
echo 'echo $(($i * 100 / $#))' >>"$nautilus";
echo 'echo "# Pushing \"${thing}\"" ;' >>"$nautilus";
echo 'adb push "${thing}" $adbpath' >>"$nautilus";
echo "i=\$((\$i+1))" >>"$nautilus";
echo 'done; i=$(($i-1)) ; echo"# $i files pushed." ) | zenity --progress --pulsate --auto-kill --width=300 --text "Copying files..." --title "Pushing files to $adbpath"' >>"$nautilus";
mv "$nautilus" /home/$USER/.gnome2/nautilus-scripts/
else
touch "$nautilus"; chmod +x "$nautilus"; echo "#!/bin/sh" > "$nautilus";
echo 'adbpath=`zenity --entry --text "Enter the directory on the Android device" --entry-text="/sdcard/"`' >> "$nautilus";
echo "" >> "$nautilus";
echo 'for i in "" "/"' >> "$nautilus";
echo 'do' >> "$nautilus";
echo "" >> "$nautilus";
echo -e '\t if [ "$i" = "$adbpath" ]' >> "$nautilus";
echo -e '\t then' >> "$nautilus";
echo -e '\t\t zenity --error --text "You have to copy the files somewhere..."' >> "$nautilus";
echo -e 'fi' >> "$nautilus";
echo 'done' >> "$nautilus";
echo "" >> "$nautilus"; echo "i=1" >> "$nautilus"; echo "(" >> "$nautilus";
echo "for thing in \"\$@\"" >> "$nautilus";
echo "do" >> "$nautilus";
echo "" >> "$nautilus";
echo 'echo "15" ; sleep 1' >>"$nautilus";
echo 'echo $(($i * 100 / $#))' >>"$nautilus";
echo 'echo "# Pushing \"${thing}\"" ;' >>"$nautilus";
echo 'adb push "${thing}" $adbpath' >>"$nautilus";
echo "i=\$((\$i+1))" >>"$nautilus";
echo 'done; i=$(($i-1)) ; echo"# $i files pushed." ) | zenity --progress --pulsate --auto-kill --width=300 --text "Copying files..." --title "Pushing files to $adbpath"' >>"$nautilus";
mv "$nautilus" /home/$USER/.gnome2/nautilus-scripts/
fi
;;
#############################################################
#############################################################
5 )
#Check if mtpfs is installed
c=mtpfs
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null
fi
if [ ! -d "/media/GalaxyNexus" ];
then
sudo mkdir /media/GalaxyNexus; sudo chmod 775 /media/GalaxyNexus
else
echo "GalaxyNexus folder already exists"
fi
if [ -f "/etc/udev/rules.d/51-android.rules" ];
then
echo "Creating a backup of your 51-android.rules"; sudo mv /etc/udev/rules.d/51-android.rules /etc/udev/rules.d/51-android.rules.backup; touch 51-android.rules; echo "SUBSYSTEMS==\"usb\", ATTRS{idVendor}==\"04e8\", ATTRS{idProduct}==\"6860\", MODE=\"777\", OWNER=\"$USER\" #Galaxy Nexus" > 51-android.rules; sudo mv 51-android.rules /etc/udev/rules.d/51-android.rules; sudo chmod a+r /etc/udev/rules.d/51-android.rules
else
touch 51-android.rules; echo "SUBSYSTEMS==\"usb\", ATTRS{idVendor}==\"04e8\", ATTRS{idProduct}==\"6860\", MODE=\"777\", OWNER=\"$USER\" #Galaxy Nexus" > 51-android.rules; sudo mv 51-android.rules /etc/udev/rules.d/51-android.rules; sudo chmod a+r /etc/udev/rules.d/51-android.rules
fi
#Set android-connect to path
if grep -q android-connect /home/$USER/.bashrc;
then
echo "android-connect already set up."
else
echo "" >> ~/.bashrc; echo "alias android-connect=\"mkdir /home/$USER/GalaxyNexus && chmod 777 /home/$USER/GalaxyNexus && mtpfs -o allow_other /home/$USER/GalaxyNexus\"" >> ~/.bashrc
fi
#Set android-disconnect to path
if grep -q android-disconnect /home/$USER/.bashrc;
then
echo "android-connect already set up."
else
echo "" >> ~/.bashrc; echo "alias android-disconnect=\"fusermount -u /home/$USER/GalaxyNexus && rmdir /home/$USER/GalaxyNexus\"" >> ~/.bashrc
fi
#Check if fuse is installed, generate new Fuse file
c=fuse
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."; sudo mv /etc/fuse.conf /etc/fuse.conf.backup; touch fuse.conf; echo "# Set the maximum number of FUSE mounts allowed to non-root users." >> fuse.conf; echo "# The default is 1000." >> fuse.conf; echo "#" >> fuse.conf; echo "#mount_max = 1000" >> fuse.conf; echo "" >> fuse.conf; echo "# Allow non-root users to specify the 'allow_other' or 'allow_root'" >> fuse.conf; echo "# mount options." >> fuse.conf; echo "#" >> fuse.conf; echo "user_allow_other" >> fuse.conf; sudo mv fuse.conf /etc/fuse.conf; sudo adduser $USER fuse
else
echo "$c was not found, installing..." 2>&1
sudo -v; sudo apt-get --force-yes -y install $c 2>/dev/null; sudo mv /etc/fuse.conf /etc/fuse.conf.backup; touch fuse.conf; echo "# Set the maximum number of FUSE mounts allowed to non-root users." >> fuse.conf; echo "# The default is 1000." >> fuse.conf; echo "#" >> fuse.conf; echo "#mount_max = 1000" >> fuse.conf; echo "" >> fuse.conf; echo "# Allow non-root users to specify the 'allow_other' or 'allow_root'" >> fuse.conf; echo "# mount options." >> fuse.conf; echo "#" >> fuse.conf; echo "user_allow_other" >> fuse.conf; sudo mv fuse.conf /etc/fuse.conf; sudo adduser $USER fuse
fi
;;
#############################################################
#############################################################
6 )
#Downloads the latest version of 99-android.rules
wget http://dl.dropbox.com/u/4413349/scripts/99-android.rules
sudo -v; sudo mv -f 99-android.rules /etc/udev/rules.d/
;;
#############################################################
#############################################################
7 )
#Download and install apktool-install.
if [ ! -f /usr/local/bin/aapt ]; then
wget http://android-apktool.googlecode.com/files/apktool-install-linux-r04-brut1.tar.bz2 && tar --wildcards --no-anchored -xjvf apktool-install-linux-r04-brut1.tar.bz2; sudo -v; sudo mv aapt /usr/local/bin/; sudo -v; sudo mv apktool /usr/local/bin/; sudo -v; sudo chmod 777 /usr/local/bin/aapt; sudo -v; sudo chmod 777 /usr/local/bin/apktool; rm apktool-install-linux-r04-brut1.tar.bz2; rm -rf apktool-install-linux-r04-brut1/;
else
echo "apktool-install already installed to /usr/local/bin. Skipping."
fi
#Download and install apktool.
if [ ! -f "/usr/local/bin/apktool.jar" ]; then
wget http://android-apktool.googlecode.com/files/apktool1.4.3.tar.bz2 && tar --wildcards --no-anchored -xjvf apktool1.4.3.tar.bz2; sudo -v; sudo mv apktool.jar /usr/local/bin/; sudo -v; sudo chmod 777 /usr/local/bin/apktool.jar; rm apktool1.4.3.tar.bz2; rm -rf apktool1.4.3/;
else
echo "apktool already installed to /usr/local/bin. Skipping."
fi
;;
#############################################################
#############################################################
8 )
#Check for repo
if [ ! -f /usr/local/bin/repo ];
then
wget https://dl-ssl.google.com/dl/googlesource/git-repo/repo; sudo -v; sudo mv repo /usr/local/bin/repo; sudo -v; sudo chmod a+x /usr/local/bin/repo
else
echo "/usr/local/bin/repo already exists."
fi
#Check for ~/bin
if [ ! -d ~/bin ]
then
mkdir ~/bin
else
echo "~/bin already exists. Skipping."
fi
#Set ~/bin to path
if grep -q /home/$USER/bin /home/$USER/.bashrc;
then
echo "$HOME/bin set up already."
else
echo "PATH=$PATH:$HOME/bin" >> $HOME/.bashrc
fi
;;
#############################################################
#############################################################
9 )
clear
echo "1 - This option will resolve the missing dependencies required the installs to function properly"
echo " - depending on your mirror download speed this can take a long time to complete."
echo "2 - Installs the Android SDK to /usr/local/android-sdk and the"
echo " Android NDK to the directory /usr/local/android/ndk"
echo "3 - This installs the adb and fastboot, accessible from terminal at any location. If you have"
echo " trouble installing this please type the following command in terminal:"
echo " /usr/local/android-sdk/tools/android update sdk"
echo "4 - Adds right click to adb push support to Nautilus. Files will be pushed"
echo " to the /sdcard/Download/ folder on your phone."
echo "5 - Installs MTP support for the Galaxy Nexus to Linux. Use the commands: android-connect and"
echo " android-disconnect to mount and unmount your device to /home/$USER/GalaxyNexus"
echo "6 - Downloads or updates your 99-android.rules file to the /etc/udev/rules.d/ directory."
echo "7 - This installs aapt and apktool to /usr/local/bin/ accessible anywhere."
echo " http://code.google.com/p/android-apktool/"
echo "8 - This installs git-repo to /usr/local/bin/repo (Please note: This requires Python 2.x)"
echo " http://code.google.com/p/git-repo/"
echo "Please press enter to continue."
read enter
;;
#############################################################
#############################################################
0 ) exit ;;
* ) echo "Please choose from the list above"
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment