rorschack

typical zipalignment script

Apr 15th, 2016
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.16 KB | None | 0 0
  1. ZDB=/data/zipit.db
  2. [ -f \$ZDB ] || : > \$ZDB
  3. _log=/data/zipsql.log
  4. cat /dev/null > \$_log
  5. date +"%h, %d -- %R" > \$_log
  6. echo -e "\\\n\\\t-----ZIPALIGN-----\\\n" >> \$_log
  7.  
  8. ##Zipalign
  9. stdate=\$(date +%s)
  10. mount -o remount,rw /system
  11. for app in \`ls -d /system/app/* /data/app/* /system/priv-app/*\`; do
  12.     apk=\$(ls \$app/*.apk)
  13.     [[ \$apk -ot \$ZDB && \$(grep -F \$app \$ZDB) ]] && {
  14.         printf "Already checked %s in %s\\n" "\${app##*/}" "\$(cut -d/ -f2 <<<\$app | tr 'a-z' 'A-Z')" >> \$_log
  15.         continue
  16.     }
  17.     zipalign -c 4 \$apk && {
  18.         grep -ixq \$app \$ZDB || echo \$app >> \$ZDB
  19.         printf "Already aligned %s in %s\\n" "\${app##*/}" "\$(cut -d/ -f2 <<<\$app | tr 'a-z' 'A-Z')" >> \$_log
  20.     } || {
  21.         printf "Now ZipAligning %s in %s\\n" "\${app##*/}" "\$(cut -d/ -f2 <<<\$app | tr 'a-z' 'A-Z')" >> \$_log
  22.         zipalign -f 4 \$apk \$apk.zipped && {
  23.             mv -f \${apk}.zipped \$apk
  24.             grep -iF \$app \$ZDB || echo \$app >> \$ZDB
  25.         } || {
  26.             echo "Error ZipAligning \$app" >> \$_log
  27.         }
  28.     }
  29. done
  30. diff=\$((\`date +%s\`-stdate))
  31. echo -e "\\\nZipaligning finished in \$diff seconds !!" >> \$_log
  32.  mount -o remount,noatime,nodiratime,ro,barrier=0,exec,suid /system 2>/dev/null
Add Comment
Please, Sign In to add comment