Advertisement
Blade83

Android APK (re)installer

Dec 12th, 2013
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.49 KB | None | 0 0
  1. #!/system/bin/bash
  2. # Author: Johannes Krämer
  3. # Email: dev@blade83.de
  4.  
  5. # This Script is for Android Phones!
  6. # You need a rootet Phone and the curl Library
  7. # Download here: http://curl.haxx.se/download.html#Linux
  8. # Copy the Binary Files (data/local/bin/*) to /system/bin/ on your Android Phone.
  9.  
  10. # Usage:
  11. # Open a Terminal on your Phone and type in app_reinstall developerbase
  12.  
  13.  
  14. clear
  15.  
  16. if [ $UID != '0' ]; then
  17.     echo -e "\033[31mYou need SuperUser rights!\033[32m"
  18.     exit 1
  19. fi
  20.  
  21. function usage()
  22. {
  23.     echo -e "\033[32mapp_reinstall:
  24. $*
  25.  
  26. Usage:
  27. app_reinstall <subdomainname> or
  28. sh app_reinstall <subdomainname>
  29.  
  30. " >&2
  31.     exit 2
  32. }
  33.  
  34. if [ $# -lt 1 ]; then
  35.     usage "needs a <subdomainname>"
  36. fi
  37.  
  38. param1=$(echo "$1" | sed 's/[a-z/A-Z]//g')
  39. if [ "$param1" ]; then
  40.     usage "wrong <subdomainname> character(s) found"
  41. fi
  42.  
  43. echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  44. echo -e "|Collect installed TMedia Applications:|\n\n\033[33m"
  45.  
  46. # Change here the search Parameters! if you use the bundle ID de.yourCompanyName.appname
  47. # then change it to  installedPackages=`pm list packages | grep yourCompanyName`
  48. installedPackages=`pm list packages | grep timbuli`
  49. echo "$installedPackages" | sed -e 's/package:/\n/g'
  50.  
  51. echo -e "\033[0m"
  52. packageExists=$(echo "$installedPackages" | grep "$1")
  53. if [ "$packageExists" ]; then
  54.     echo -e "\nUninstalling current Version from System"
  55.     # change here your Package Name!!!!!
  56.     pm uninstall "de.timbulimedia.$1"
  57. fi
  58.  
  59. # change here your Package Name <timbulimedia>
  60. if [ -f "/mnt/sdcard/Download/de.timbulimedia.$1.apk" ]; then
  61.         echo -e "\n\nRemoving old *.apk Files"
  62.     # change here your Package Name !!!!!
  63.     rm "/mnt/sdcard/Download/de.timbulimedia.$1.apk"
  64.     echo -e "Done"
  65. fi
  66.  
  67. echo -e "\nSearching for download... \n"
  68. # change here your server APK url !!!!!
  69. serverStatus=`curl -Is "http://$1.timbulimedia.de/APP/de.timbulimedia.$1.apk" | head -n 1`
  70. if [ "$(echo "$serverStatus" | grep -E -o "[0-9]{3}+")" -eq 200 ]; then
  71.         # change here your Package Name and APK URL <timbulimedia>!!!!!
  72.     curl -o "/mnt/sdcard/Download/de.timbulimedia.$1.apk" "http://$1.timbulimedia.de/APP/de.timbulimedia.$1.apk"
  73.     echo -e "\nDownload complete. \n"
  74.     echo -e "Installing new Application... \n"
  75.     # change here your Package Name <timbulimedia>!!!!!
  76.     pm install "/mnt/sdcard/Download/de.timbulimedia.$1.apk" &> /dev/null
  77.     echo -e "\nApplication was successful updated! \n"
  78. else
  79.     echo -e "\n\033[31mCan not find \"$1\"!\033[32m \n\n\n"
  80. fi
  81. echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement