Advertisement
Guest User

Untitled

a guest
Feb 16th, 2011
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.92 KB | None | 0 0
  1. #!/system/bin/sh
  2. #
  3. # loadpreinstalls.sh - installs apps / does other kewl stuff
  4. #
  5. # Copyright (C) 2010 Jared Rummler (JRummy16)
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  19. #
  20.  
  21. LIBERTY_DIR=/data/liberty/app
  22. CONTROL_FILE=/data/liberty/init.d.conf
  23. INSTALL_FROM_SD=/mnt/sdcard/liberty/install_apps
  24. GET_URL_LIST=http://www.froyoroms.com/files/developers/jrummy/JRummy/DroidX/ROM/Liberty/Downloads/downloads.list
  25. URL_LIST=/data/liberty/download.list
  26.  
  27. . $CONTROL_FILE
  28.  
  29. pm setInstallLocation $APP_INSTALL_LOCATION
  30. echo "Set install location to "`pm getInstallLocation | sed -e 's|^..||' -e 's|.$||'`"" | tee -a $LOG_FILE
  31.  
  32. if [ `ls $LIBERTY_DIR | wc -l` -gt 0 ]; then
  33.     for apk in `ls $LIBERTY_DIR`
  34.     do
  35.         echo -n "Installing $apk ... " | tee -a $LOG_FILE
  36.         if [ -z "`pm install -r $LIBERTY_DIR/$apk 2>/dev/null`" ]; then
  37.             echo "failed!" | tee -a $LOG_FILE
  38.         else
  39.             echo "done!" | tee -a $LOG_FILE
  40.             rm $LIBERTY_DIR/$apk
  41.             echo "Removed `basename $apk`" | tee -a $LOG_FILE
  42.         fi
  43.     done
  44. fi
  45.  
  46. while test -z "$(mount | grep sdcard)" ; do
  47.     sleep 2s
  48. done
  49.  
  50. busybox mkdir -p $(dirname $INSTALL_FROM_SD)/install_complete
  51.  
  52. if [ `ls $INSTALL_FROM_SD | wc -l` -gt 0 ]; then
  53.     for apk in `ls $INSTALL_FROM_SD`
  54.     do
  55.         echo -n "Installing $apk ... " | tee -a $LOG_FILE
  56.         if [ -z "`pm install -r $INSTALL_FROM_SD/$apk 2>/dev/null`" ]; then
  57.             echo "failed!" | tee -a $LOG_FILE
  58.         else
  59.             echo "done!" | tee -a $LOG_FILE
  60.             busybox cp -f $INSTALL_FROM_SD/$apk $(dirname $INSTALL_FROM_SD)/install_complete
  61.             busybox rm -f $INSTALL_FROM_SD/$apk
  62.         fi
  63.     done
  64. fi
  65.  
  66. if test `ls /system/etc/animations | grep zip | wc -l` -gt 0; then
  67.     sysrw
  68.     for i in /system/etc/animations/*.zip; do
  69.         busybox mkdir -p ${i%.*}
  70.         unzip -o $i -d ${i%.*}
  71.         busybox rm -f $i
  72.         echo "Set up $(basename $i) animation" | tee -a $LOG_FILE
  73.     done
  74. fi
  75.  
  76. sysrw
  77. if [ -e /system/bin/adbd ]; then
  78.     echo "Set new adbd" | tee -a $LOG_FILE
  79.     busybox mount -orw,remount /
  80.     mv /sbin/adbd /sbin/adbd.old
  81.     busybox cp /system/bin/adbd /sbin/adbd
  82.     busybox mount -oro,remount /
  83.     if test ! -z "$(ps | grep adbd)"; then
  84.         busybox kill $(ps | grep adbd)
  85.     fi
  86. fi
  87.  
  88. while test -z "$(mount|grep sdcard)"; do
  89.     sleep 5s
  90. done
  91.  
  92. busybox mkdir -p /mnt/sdcard/liberty/downloads
  93. . /system/lib/libgnakfoorp.so;gnak
  94.  
  95. while test -z "$(ps|grep pppd-ril)"; do
  96.     sleep 5s
  97. done
  98.  
  99. wget $GET_URL_LIST -O $URL_LIST
  100.  
  101. for url in `cat $URL_LIST`; do
  102.     if test ! -e /mnt/sdcard/liberty/downloads/$(basename $url); then
  103.         wget $url -O /mnt/sdcard/liberty/downloads/$(basename $url)
  104.     else
  105.         echo "Skipped download for $(basename $url). File exists." | tee -a $LOG_FILE
  106.     fi
  107.     if test ! -e /system/etc/installed.list; then
  108.         touch /system/etc/installed.list
  109.     fi
  110.     if test "`echo ${url##*.}`" = "apk" -a -z "`grep "$(basename $url)" /system/etc/installed.list`"; then
  111.         echo "apk found!" | tee -a $LOG_FILE
  112.         echo -n "Installing $(basename $url) ... " | tee -a $LOG_FILE
  113.         if [ -z "`pm install -r /mnt/sdcard/liberty/downloads/$(basename $url) 2>/dev/null`" ]; then
  114.             echo "failed!" | tee -a $LOG_FILE
  115.         else
  116.             echo "done!" | tee -a $LOG_FILE
  117.             echo "$(basename $url)" >> /system/etc/installed.list
  118.         fi
  119.     elif test "`echo ${url##*.}`" = "sh" -a ! -e /system/xbin/$(basename "${url%.*}"); then
  120.         echo "script found!" | tee -a $LOG_FILE
  121.         echo -n "Installing script ..." | tee -a $LOG_FILE
  122.         busybox cp -f /mnt/sdcard/liberty/downloads/$(basename $url) /system/xbin/$(basename "${url%.*}")
  123.         chmod 755 /system/xbin/$(basename "${url%.*}")
  124.         echo "done!" | tee -a $LOG_FILE
  125.         echo "$(basename "${url%.*}")" >> /system/etc/installed.list
  126.     elif test "`echo ${url##*.}`" = "liberty_script" -a -z "`grep "$(basename $url)" /system/etc/installed.list`"; then
  127.         echo "Found liberty script!" | tee -a $LOG_FILE
  128.         echo "Executing script ... " | tee -a $LOG_FILE
  129.         chmod 755 /mnt/sdcard/liberty/downloads/$(basename $url)
  130.         sh /mnt/sdcard/liberty/downloads/$(basename $url)
  131.         echo "$(basename $url)" >> /system/etc/installed.list
  132.     elif test "`echo ${url##*.}`" = "update_package" -a -z "`grep "$(basename $url)" /system/etc/installed.list`"; then
  133.         echo "Found update package!" | tee -a $LOG_FILE
  134.         echo "Installing update package ... " | tee -a $LOG_FILE
  135.         mkdir /cache/recovery
  136.         echo "install_zip SDCARD:liberty/downloads/$(basename $url)" > /cache/recovery/extendedcommand
  137.         rb -bs
  138.     fi
  139.     sed -i "s|$url||g" $URL_LIST
  140. done
  141. sysro
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement