Advertisement
Blade83

Android APK (re)installer

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