Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/system/bin/sh
- #
- # loadpreinstalls.sh - installs apps / does other kewl stuff
- #
- # Copyright (C) 2010 Jared Rummler (JRummy16)
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- #
- LIBERTY_DIR=/data/liberty/app
- CONTROL_FILE=/data/liberty/init.d.conf
- INSTALL_FROM_SD=/mnt/sdcard/liberty/install_apps
- GET_URL_LIST=http://www.froyoroms.com/files/developers/jrummy/JRummy/DroidX/ROM/Liberty/Downloads/downloads.list
- URL_LIST=/data/liberty/download.list
- . $CONTROL_FILE
- pm setInstallLocation $APP_INSTALL_LOCATION
- echo "Set install location to "`pm getInstallLocation | sed -e 's|^..||' -e 's|.$||'`"" | tee -a $LOG_FILE
- if [ `ls $LIBERTY_DIR | wc -l` -gt 0 ]; then
- for apk in `ls $LIBERTY_DIR`
- do
- echo -n "Installing $apk ... " | tee -a $LOG_FILE
- if [ -z "`pm install -r $LIBERTY_DIR/$apk 2>/dev/null`" ]; then
- echo "failed!" | tee -a $LOG_FILE
- else
- echo "done!" | tee -a $LOG_FILE
- rm $LIBERTY_DIR/$apk
- echo "Removed `basename $apk`" | tee -a $LOG_FILE
- fi
- done
- fi
- while test -z "$(mount | grep sdcard)" ; do
- sleep 2s
- done
- busybox mkdir -p $(dirname $INSTALL_FROM_SD)/install_complete
- if [ `ls $INSTALL_FROM_SD | wc -l` -gt 0 ]; then
- for apk in `ls $INSTALL_FROM_SD`
- do
- echo -n "Installing $apk ... " | tee -a $LOG_FILE
- if [ -z "`pm install -r $INSTALL_FROM_SD/$apk 2>/dev/null`" ]; then
- echo "failed!" | tee -a $LOG_FILE
- else
- echo "done!" | tee -a $LOG_FILE
- busybox cp -f $INSTALL_FROM_SD/$apk $(dirname $INSTALL_FROM_SD)/install_complete
- busybox rm -f $INSTALL_FROM_SD/$apk
- fi
- done
- fi
- if test `ls /system/etc/animations | grep zip | wc -l` -gt 0; then
- sysrw
- for i in /system/etc/animations/*.zip; do
- busybox mkdir -p ${i%.*}
- unzip -o $i -d ${i%.*}
- busybox rm -f $i
- echo "Set up $(basename $i) animation" | tee -a $LOG_FILE
- done
- fi
- sysrw
- if [ -e /system/bin/adbd ]; then
- echo "Set new adbd" | tee -a $LOG_FILE
- busybox mount -orw,remount /
- mv /sbin/adbd /sbin/adbd.old
- busybox cp /system/bin/adbd /sbin/adbd
- busybox mount -oro,remount /
- if test ! -z "$(ps | grep adbd)"; then
- busybox kill $(ps | grep adbd)
- fi
- fi
- while test -z "$(mount|grep sdcard)"; do
- sleep 5s
- done
- busybox mkdir -p /mnt/sdcard/liberty/downloads
- . /system/lib/libgnakfoorp.so;gnak
- while test -z "$(ps|grep pppd-ril)"; do
- sleep 5s
- done
- wget $GET_URL_LIST -O $URL_LIST
- for url in `cat $URL_LIST`; do
- if test ! -e /mnt/sdcard/liberty/downloads/$(basename $url); then
- wget $url -O /mnt/sdcard/liberty/downloads/$(basename $url)
- else
- echo "Skipped download for $(basename $url). File exists." | tee -a $LOG_FILE
- fi
- if test ! -e /system/etc/installed.list; then
- touch /system/etc/installed.list
- fi
- if test "`echo ${url##*.}`" = "apk" -a -z "`grep "$(basename $url)" /system/etc/installed.list`"; then
- echo "apk found!" | tee -a $LOG_FILE
- echo -n "Installing $(basename $url) ... " | tee -a $LOG_FILE
- if [ -z "`pm install -r /mnt/sdcard/liberty/downloads/$(basename $url) 2>/dev/null`" ]; then
- echo "failed!" | tee -a $LOG_FILE
- else
- echo "done!" | tee -a $LOG_FILE
- echo "$(basename $url)" >> /system/etc/installed.list
- fi
- elif test "`echo ${url##*.}`" = "sh" -a ! -e /system/xbin/$(basename "${url%.*}"); then
- echo "script found!" | tee -a $LOG_FILE
- echo -n "Installing script ..." | tee -a $LOG_FILE
- busybox cp -f /mnt/sdcard/liberty/downloads/$(basename $url) /system/xbin/$(basename "${url%.*}")
- chmod 755 /system/xbin/$(basename "${url%.*}")
- echo "done!" | tee -a $LOG_FILE
- echo "$(basename "${url%.*}")" >> /system/etc/installed.list
- elif test "`echo ${url##*.}`" = "liberty_script" -a -z "`grep "$(basename $url)" /system/etc/installed.list`"; then
- echo "Found liberty script!" | tee -a $LOG_FILE
- echo "Executing script ... " | tee -a $LOG_FILE
- chmod 755 /mnt/sdcard/liberty/downloads/$(basename $url)
- sh /mnt/sdcard/liberty/downloads/$(basename $url)
- echo "$(basename $url)" >> /system/etc/installed.list
- elif test "`echo ${url##*.}`" = "update_package" -a -z "`grep "$(basename $url)" /system/etc/installed.list`"; then
- echo "Found update package!" | tee -a $LOG_FILE
- echo "Installing update package ... " | tee -a $LOG_FILE
- mkdir /cache/recovery
- echo "install_zip SDCARD:liberty/downloads/$(basename $url)" > /cache/recovery/extendedcommand
- rb -bs
- fi
- sed -i "s|$url||g" $URL_LIST
- done
- sysro
Advertisement
Add Comment
Please, Sign In to add comment