Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Greetings.
  4. printf "\n"
  5. echo "################################################"
  6. echo "# #"
  7. echo "# Quart Bilişim OIM Signer and Aligner #"
  8. echo "# #"
  9. echo "# Drag and drop available for files/paths. #"
  10. echo "# #"
  11. echo "################################################"
  12. printf "\n\n"
  13.  
  14. # Fake loading
  15. printf "\e[32mChecking paths...\e[0m\n"
  16. sleep 1
  17.  
  18. # Define unsigned apk file
  19. export UNSIGNED_APK="$(pwd)/platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk"
  20.  
  21. # Check unsigned_apk until it's exists and a real apk file
  22. while [[ ! -f $UNSIGNED_APK ]] || [[ $UNSIGNED_APK != *".apk"* ]]; do
  23. printf "\e[91mRelease APK file \"$UNSIGNED_APK\" not found or not an apk file.\nPlease provide a release apk path...\e[0m\n"
  24. read -p 'Give full path of the release apk or drop apk file into the terminal: ' UNSIGNED_APK
  25. done
  26.  
  27. # Get keystore file
  28. read -p "Keystore name/path [eg. ./app.keystore]: " KEYSTORE_NAME
  29.  
  30. # check keystore_name until it's existst and a real keystore file
  31. while [[ ! -f $KEYSTORE_NAME ]] || [[ $KEYSTORE_NAME != *".keystore"* ]]; do
  32. printf "\e[91mKeystore file \"$KEYSTORE_NAME\" not found or not a keystore.\nPlease provide a keystore path...\e[0m\n"
  33. read -p 'Give full path of the keystore or drop the file into the terminal: ' KEYSTORE_NAME
  34. done
  35.  
  36. # Get other things
  37. read -sp "Store password: " STORE_PASSWORD
  38. printf "\n"
  39. read -p "Keystore alias [app]: " KEYSTORE_ALIAS
  40. read -sp "Password: " PASSWORD
  41. printf "\n"
  42.  
  43. # Create final apk filename
  44. export FINAL_APK_NAME="$KEYSTORE_ALIAS-final.apk"
  45.  
  46. # Build app
  47. cordova build android -release -keystore=$KEYSTORE_NAME -storePassword=$STORE_PASSWORD -alias=$KEYSTORE_ALIAS -password=$PASSWORD
  48.  
  49. # Sign apk file
  50. jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore $KEYSTORE_NAME $UNSIGNED_APK $KEYSTORE_ALIAS
  51.  
  52. # Check if final_apk file exists and delete
  53. if [ -f $FINAL_APK_NAME ]; then
  54. echo "File $FINAL_APK_NAME exists. Deleting..."
  55. rm -rf $FINAL_APK_NAME
  56. fi
  57.  
  58. # Align new apk file
  59. zipalign -v 4 $UNSIGNED_APK $FINAL_APK_NAME
  60.  
  61. clear
  62.  
  63. printf "\n\e[32mNew apk file \"\e[5m$FINAL_APK_NAME\e[0m\e[32m\" created in \"$(pwd)\".\e[0m \n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement