Cwm - Recreate tree from .dup nandroids [Linux only] - Android Software/Hacking General [Developers Only]

Newer cwm's now do nandroid's via .dup files.
These files are nothing but metadata that links each backup to the real files in the clockworkmod/blobs directory.
This script merely allows you to recreate a tree from a .dup file + blobs directory. This is helpful if you want to extract a few files from a backup and not have to restore it.
link
To use :
wget -O recreate.sh http://goo.gl/wz3IU
chmod 755 recreate.sh
./recreate.sh

Totally off topic but I haven't seen you around here in years. You rooted my Nexus One for me via TeamView back when the N1 first came out.
Crazy how long ago that seems when I couldn't even root my first Android device, haha.
Anyway, sorry to go off topic.
Just wanted to say thanks all these years later. You got my going in the XDA Android scene and here I am a few years later tweaking ROMs and starting to learn to build from source.
Sent from my SGH-T999 using xda premium

Don't mention it
Glad to see it got you motivated.
Yea I don't post around much anymore. I just wrote this quick thing for myself thought I'd share it

hi. i found this thread while searching and thought it would be a really useful tool. i was having problems with my cwm6 backups and so made the following amendments to the script :
IFS=$'\n' <- added new line
while read line; do
if [ "$line" != "dedupe 2" ]; then
inc=$(($inc+1))
prog=$(($inc / $chunk))
type=$(echo $line | cut -f1) <- removed -d " "
item=$(echo $line | cut -f8) <- removed -d " "
link=$(echo $line | cut -f9) <- added new line
hashFolder=$(echo $line | cut -f9 | cut -d "/" -f1) <- removed -d " "
hashFile=$(echo $line | cut -f9 | cut -d "/" -f2) <- removed -d " "
if [ "$type" = "f" -a ! -z "$hashFolder" -a ! -z "$hashFile" ]; then
if [ -f "$blobFolder/$hashFolder/$hashFile" ]; then
cp "$blobFolder/$hashFolder/$hashFile" "$outputFolder/$item"
else
echo "No blob for " $item " found"
fi
elif [ "$type" = "l" ]; then <- added new line
ln -s $link $item <- added new line
else
mkdir -p $outputFolder/$item
fi
if [ $last -ne $prog ]; then
if [ $(($prog % 10)) -eq 0 ]; then
echo -n $prog%
elif [ $(($prog % 4)) -eq 0 ]; then
echo -n '.'
fi
last=$prog
fi
fi
this accommodated the tabs, filenames containing spaces, and links in my dup files.

Related

[Script] Chroot Control Script

One of the fun things you can do on your Android device, is to play around with different ways of getting a real distro (Debian, Ubuntu etc.) working along side the Android system. There are several (A lot) of tutorials in here on how to do this, so this part will not be covered here. This thread only contains some scripts that will help make it easier working with the chroot.
Most of the scripts that comes with the endless pool of chroot tutorials, is only made to mount and unmount the distro image in the most simple way. But nothing that helps walking in and out of the chroot without mount/unmount, and nothing that takes different services, busy devices etc. into consideration.
The debian.sh script in this thread has many tasks. It will on execution check to see if the image is mounted or not. If the image is mounted, it will just enter the chroot. If not, it will mount the image and then enter the chroot. On exit it will provide you with the option of exiting the chroot or exit and unmount.
Also it provides 4 custom scripts that is placed and executed inside the chroot. One for mount, unmount, enter chroot, leave chroot. This makes it possible to control chroot services much easier.
The script debian.sh is executed using the command "debian". You can also unmount the chroot from within the android shell by executing "debian unmount" instead of entering the chroot and then exit choosing to unmount.
The unmount process has several and different unmount attempts in case of busy devices, running services etc. which will make sure that the chroot is successfully unmounted.
File: /system/bin/debian
Code:
#!/system/bin/sh
su -c "/system/bin/debian.sh [email protected]"
File: /system/bin/debian.sh
Code:
#!/system/bin/sh
createLinuxBoot() {
if [ ! -f $FILESYSTEM ]; then
echo "Missing the $DIST filesystem image!"
return 0
elif [ ! -z "$(mount | grep "$MOUNTPOINT ")" ]; then
# If the loop device is already mounted, we do nothing.
echo " - $DIST is already mounted. Entering chroot..."
else
echo " - Executing mount proccess of $DIST..."
if [ ! -d $MOUNTPOINT ]; then
# Create the mount point if it does not already exist
busybox mkdir -p $MOUNTPOINT 2> /dev/null
if [ ! -d $MOUNTPOINT ]; then
echo "It was not possible to create the missing mount location ($MOUNTPOINT)!"
return 0
fi
fi
# Android places loop devices in /dev/block/ instead of root /dev/
# If there are none in /dev/ we create links between /dev/loopX and /dev/block/loopX so that losetup will work as it should.
if [ ! -e /dev/loop0 ]; then
for i in 0 1 2 3 4 5 6 7
do
# Create each block device
mknod /dev/loop$i b 7 $i
done
fi
# Android also placed the frame buffer in /dev/grapichs instead of /dev
if [ ! -e /dev/fb0 ]; then
mknod /dev/fb0 b 29 0
fi
# Locate the current loop device file
if [ ! -z "$(losetup | grep "$FILESYSTEM")" ]; then
# If the filesystem file is already attached to an loop device, we get the path to the device file.
loblk=$(losetup | grep "$FILESYSTEM" | cut -d ":" -f 1)
else
# If the filesystem file is not yet attached, we attach it.
loblk=$(losetup -f)
losetup $loblk $FILESYSTEM 2> /dev/null
# Make sure that the device was successfully attached to a loop device file
if [ -z "$(losetup | grep "$FILESYSTEM")" ]; then
echo "It was not possible to attach the $DIST filesystem to a loop device!"
return 0
fi
fi
# Mount the filesystem
mount $loblk $MOUNTPOINT 2> /dev/null
if [ ! -z "$(mount | grep "$MOUNTPOINT ")" ]; then
# Bind some Android dirs to the linux filesystem
for i in $MOUNT_BIND
do
# Bind the dirs if they are not already binded
if [ -z "$(mount | grep "$MOUNTPOINT/$i ")" ]; then
# Create any missing dirs in the mountpoint
if [ ! -d $MOUNTPOINT/$i ]; then
busybox mkdir -p $MOUNTPOINT/$i 2> /dev/zero
fi
mount --bind /$i $MOUNTPOINT/$i
fi
done
# FIX the "stdin: is not a tty" error in direct hadware case.
if [ -z "$(mount | grep "$MOUNTPOINT/dev/pts ")" ]; then
mount -t devpts devpts $MOUNTPOINT/dev/pts
fi
# For the network.
#sysctl -w net.ipv4.ip_forward=1
echo 1 > /proc/sys/net/ipv4/ip_forward
# Cleanup tmp folder.
rm -rf $MOUNTPOINT/tmp/*
else
echo "It was not possible to mount $DIST at the specified location ($MOUNTPOINT)!"
return 0
fi
if [ -f $MOUNTPOINT/etc/init.chroot/rc_mount.sh ]; then
# Execute the mount init file, if it exists
chroot $MOUNTPOINT /etc/init.chroot/rc_mount.sh
fi
echo " - $DIST was successsfully mounted. Entering chroot..."
fi
return 1
}
removeLinuxBoot() {
if [ -z "$(mount | grep "$MOUNTPOINT ")" ]; then
# If linux is not mounted, then do nothing.
echo " - $DIST is already unmounted. Exiting..."
else
echo " - Executing unmount process of $DIST..."
if [ -f $MOUNTPOINT/etc/init.chroot/rc_unmount.sh ]; then
# Execute the unmount init script, if it exist.
chroot $MOUNTPOINT /etc/init.chroot/rc_unmount.sh
fi
sync
# The sleep part is very important. It may take some time before /dev is no longer busy
# after executing some services in the rc_unmount.sh script.
sleep 1
# Make sure that we have an loop device file to use
if [ ! -z "$(losetup | grep "$FILESYSTEM")" ]; then
# Get the loop device file
loblk=$(losetup | grep "$FILESYSTEM" | cut -d ":" -f 1)
for i in $UMOUNT_BIND
do
# Unmount all binding dirs
if [ ! -z "$(mount | grep "$MOUNTPOINT/$i ")" ]; then
umount $MOUNTPOINT/$i 2> /dev/zero
fi
done
sync
# Unmount the device
# In most cases one umount attempt will be enough.
# However it may take up to 3 tries in order to make it work.
# It depends on the types of services running or has been running before unmounting.
umount $MOUNTPOINT 2> /dev/null && sleep 1 2> /dev/zero
if [ ! -z "$(mount | grep "$MOUNTPOINT ")" ]; then
sync
umount $MOUNTPOINT 2> /dev/null && sleep 1 2> /dev/zero
fi
# If the device could not be unmounted
if [ ! -z "$(mount | grep "$MOUNTPOINT ")" ]; then
echo " - Unable to unmount $DIST. Will attempt to kill attached processes..."
# Try to kill all processes holding the device
fuser -k -9 $loblk
sync
# Use umount with the -l option to take care of the rest
umount -l $MOUNTPOINT 2> /dev/null && sleep 1
fi
# Make sure the device has been successfully unmounted
if [ -z "$(mount | grep "$MOUNTPOINT ")" ]; then
# Try to detach the device from the loop device file
losetup -d $loblk 2> /dev/null
# Make sure that the device was successfully detached
if [ -z "$(losetup | grep "$FILESYSTEM")" ]; then
echo "$DIST has been successfully unmounted!"
else
echo "$DIST has been successfully unmounted, but was not able not detach the loop device!"
fi
else
echo "$DIST could not be successfully unmounted!"
fi
else
echo "Could not locate the loop device. $DIST was not unmounted!"
fi
fi
}
if [ -z "$EXPORTED" ]; then
export EXPORTED="TRUE"
# Basic needed variables
export TERM=linux
export HOME=/root
export USER=root
export LOGNAME=root
export UID=0
export SHELL=bash
# Here you can add all of the paths that should be binded. One list for mount and one reversed list for unmount.
export MOUNT_BIND="dev dev/pts dev/cpuctl proc sys sys/kernel/debug system d vendor acct sdcard cache sd-ext data"
export UMOUNT_BIND="dev/cpuctl dev/pts dev proc sys/kernel/debug d sys vendor acct sdcard cache sd-ext system data"
# Here you can change mount and image paths
export DIST="Debian" # The name of the distro. Is used for the messages.
export FILESYSTEM=/mnt/sdcard/debian.img # Path to the distro image file
export MOUNTPOINT=/data/debian # Path where the distro is to be mounted
fi
export OLDPATH=$PATH
export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/root/bin:$PATH
if [ "$1" = "unmount" ]; then
removeLinuxBoot
else
createLinuxBoot
if [ $? -eq 1 ]; then
if [ -f $MOUNTPOINT/etc/init.chroot/rc_enter.sh ]; then
chroot $MOUNTPOINT /etc/init.chroot/rc_enter.sh
fi
chroot $MOUNTPOINT /bin/bash -i
if [ -f $MOUNTPOINT/etc/init.chroot/rc_leave.sh ]; then
chroot $MOUNTPOINT /etc/init.chroot/rc_leave.sh
fi
echo -n " - Type [Y] to unmount $DIST or random key to exit chroot ]# "
read ACTION
if [ "$ACTION" = "y" ] || [ "$ACTION" = "Y" ]; then
removeLinuxBoot
fi
fi
fi
# Restore the PATH variable when executing chroot
export PATH=$OLDPATH
By default debian.sh will look for /mnt/sdcard/debian.img and mount it at /data/debian
The script has build-in first-time-install functionality that will create missing directories etc. Just change the variable "FILESYSTEM" in debian.sh to the correct path and filename of your distro image, and it will handle the rest.
Chroot Init Scripts
Inside your chroot, you can create the directory /etc/init.chroot and create the fallowing files.
rc_mount.sh - Executed after mount
rc_unmount.sh - Executed before unmount
rc_enter.sh - Executed when entering chroot
rc_leave.sh - Executed when leaving chroot
Here are an example of a mount and unmount script used to control tightvncserver.
File: (chroot) /etc/init.chroot/rc_mount.sh
Code:
#!/bin/sh
# Make sure that the vncserver is completly stopped before starting.
if [ ! -f /tmp/.X11-unix/X1 ] && [ ! -f /tmp/.X1-lock ]; then
# Start vncserver
vncserver -geometry 800x480 :1
else
# This is in case something went wrong the last time
# it was shut down. Perhaps an uncomplete unmount.
vncserver -kill :1 2> /dev/zero
unset /tmp/.X11-unix/X1 2> /dev/zero 2> /dev/zero
unset /tmp/.X1-lock 2> /dev/zero 2> /dev/zero
vncserver -geometry 800x480 :1
fi
File: (chroot) /etc/init.chroot/rc_unmount.sh
Code:
#!/bin/sh
# Only stop this if it is started
if [ -f /tmp/.X11-unix/X1 ] || [ -f /tmp/.X1-lock ]; then
vncserver -kill :1
# Make sure that these are removed
unset /tmp/.X11-unix/X1 2> /dev/zero
unset /tmp/.X1-lock 2> /dev/zero
fi
Using these scripts, the VNC Server is started on chroot mount and stopped on chroot unmount. You can still leave and enter the chroot keeping the VNC Server running.

[Mod][Flash] Universal Bootanimation Flash Update.zip - Sense|AOSP|Sprint|HTC|Verizon

Hello World.
Tommy here. This time I have a nifty little trick for you guys.
This took a little creative thinking but I think I got it pretty good. I was chatting with some Team Ramen Noodles guys and someone asked how an AOSP botanimaiton zip can be flashed on a Sense ROM. This was the lightbulb moment
Instructions for dev:
Download from link below.
Place the file "bootanimation.zip" inside the update.zip. I put a placeholder so you would know where to replace it.
Optionally, you can put a sound "android_audio.mp3". If you don't want it, then just leave it out. Not necessary.
When you open it up, you will see two place holder files, "bootanimaion.zip__HERE" and "android_audo.mp3__HERE". You can delete them if you want, but they don't do anything. Just for reference.
Files must be named "bootanimation.zip" and "android_audio.zip", otherwise won't work.
The script "tt_uni_boot" looks for the animation and sound in the rom, and replaces it depending on what it finds.
This works on AOSP, Sense, Sprint, HTC, and Verizion
The update.zip below is what you should use as your base if you want to make your bootanimation universal for all roms.
Also, if anyone wants to flash it as is, it contains this lovely animation:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Original Thread Here
Universal Bootanimation update.zip v0.0.1 - January 08, 2012
Enjoy!
Please report feedback. I and dean_fx tested it before I posted, but if you want different feature or something like that let me know.
Tommy
edit1.
And in case anyone wants to adapt my script, I am more than happy to share. Just give a little credit
Sharing means caring. And collaborative efforts yield better results.
Code:
#!/system/bin/bash
#tommytomatoe
#universal animation flasher
# creating logfile "lockscreen" on sdcard
log=sdcard/bootanimation.log
touch $log
# mounting system as R/W
busybox mount -o remount,rw /system
echo "/system mounted as R/W" > $log
echo "" >> $log
# doing some checks
# bootanimation locatioon
if busybox [ -e /system/customize/resource/bootanimation.zip ]; then
BOOT_ANI=/system/customize/resource/bootanimation.zip
elif busybox [ -e /data/local/bootanimation.zip ]; then
BOOT_ANI=/data/local/bootanimation.zip
elif busybox [ -e /system/media/bootanimation.zip ]; then
BOOT_ANI=/system/media/bootanimation.zip
elif busybox [ -e /system/customize/resource/spc_bootanimation.zip ]; then
BOOT_ANI=/system/customize/resource/spc_bootanimation.zip
elif busybox [ -e /data/local/spc_bootanimation.zip ]; then
BOOT_ANI=/data/local/spc_bootanimation.zip
elif busybox [ -e /system/media/spc_bootanimation.zip ]; then
BOOT_ANI=/system/media/spc_bootanimation.zip
elif busybox [ -e /system/customize/resource/VZW_bootanimation.zip ]; then
BOOT_ANI=/system/customize/resource/VZW_bootanimation.zip
elif busybox [ -e /data/local/VZW_bootanimation.zip ]; then
BOOT_ANI=/data/local/VZW_bootanimation.zip
elif busybox [ -e /system/media/VZW_bootanimation.zip ]; then
BOOT_ANI=/system/media/VZW_bootanimation.zip
elif busybox [ -e /system/customize/resource/hTC_bootanimation.zip ]; then
BOOT_ANI=/system/customize/resource/hTC_bootanimation.zip
elif busybox [ -e /data/local/hTC_bootanimation.zip ]; then
BOOT_ANI=/data/local/hTC_bootanimation.zip
elif busybox [ -e /system/media/hTC_bootanimation.zip ]; then
BOOT_ANI=/system/media/hTC_bootanimation.zip
else
echo "Bootanimation does not exist" >> $log
exit 1
fi
# bootanimation sound location
if busybox [ -e /system/customize/resource/android_media.mp3 ]; then
BOOT_SOUND=/system/customize/resource/android_media.mp3
elif busybox [ -e /data/local/android_media.mp3 ]; then
BOOT_SOUND=/data/local/android_media.mp3
elif busybox [ -e /system/media/android_media.mp3 ]; then
BOOT_SOUND=/system/media/android_media.mp3
elif busybox [ -e /system/customize/resource/android_audio.mp3 ]; then
BOOT_SOUND=/system/customize/resource/android_audio.mp3
elif busybox [ -e /data/local/android_audio.mp3 ]; then
BOOT_SOUND=/data/local/android_audio.mp3
elif busybox [ -e /system/media/android_audio.mp3 ]; then
BOOT_SOUND=/system/media/android_audio.mp3
elif busybox [ -e /system/customize/resource/SPC_animation_final.mp3 ]; then
BOOT_SOUND=/system/customize/resource/SPC_animation_final.mp3
elif busybox [ -e /data/local/SPC_animation_final.mp3 ]; then
BOOT_SOUND=/data/local/SPC_animation_final.mp3
elif busybox [ -e /system/media/SPC_animation_final.mp3 ]; then
BOOT_SOUND=/system/media/SPC_animation_final.mp3
else
echo "Bootanimation sound does not exist" >> $log
fi
echo "$BOOT_ANI" >> $log
echo "$BOOT_SOUND" >> $log
echo "" >> $log
# moving animation
busybox mv -f /data/local/tmp/bootanimation.zip $BOOT_ANI
if busybox [ -e /data/local/tmp/bootanimation.zip ] ; then
buxybox rm -f /data/local/tmp/bootanimation.zip
fi
if busybox [ -e $BOOT_ANI ] ; then
echo "SUCCESS! Bootanimation moved to $BOOT_ANI" >> $log
else
echo "FAILURE! Bootanimation not moved to $BOOT_ANI" >> $log
fi
echo "" >> $log
# moving busybox mv -f /data/local/tmp/bootanimation.zip $BOOT_ANI
busybox mv -f /data/local/tmp/android_audio.mp3 $BOOT_SOUND
if busybox [ -e /data/local/tmp/android_audio.mp3 ] ; then
buxybox rm -f /data/local/tmp/android_audio.mp3
fi
if busybox [ -e $BOOT_SOUND ] ; then
echo "SUCCESS! Bootanimation sound moved to $BOOT_SOUND" >> $log
else
echo "FAILURE! Bootanimation sound moved to $BOOT_SOUND" >> $log
fi
echo "" >> #log
echo "Universal Bootanimation Flasher Commencing" >> $log
Nice one Tommy.
Edit. got the error tried couple ways going into, will check back soon.
Edit2. smooth sailing...
Tekn010933 said:
Nice one Tommy.
Edit. got the error tried couple ways going into, will check back soon.
Click to expand...
Click to collapse
Fixed!
I always type https instead of http out of habbit
Thanks Tommy, I've downloaded it and stored it in my vault..haha...NEVER know when this might come in handy!!
Thanks for sharing with us!
KIOWA69 said:
Thanks for sharing with us!
Click to expand...
Click to collapse
My pleasure! It was a fun one to do.
Sent from my PC36100 using Tapatalk
tommytomatoe said:
Hello World.
Tommy here. This time I have a nifty little trick for you guys.
This took a little creative thinking but I think I got it pretty good. I was chatting with some Team Ramen Noodles guys and someone asked how an AOSP botanimaiton zip can be flashed on a Sense ROM. This was the lightbulb moment
Instructions for dev:
Download from link below.
Place the file "bootanimation.zip" inside the update.zip. I put a placeholder so you would know where to replace it.
Optionally, you can put a sound "android_audio.mp3". If you don't want it, then just leave it out. Not necessary.
When you open it up, you will see two place holder files, "bootanimaion.zip__HERE" and "android_audo.mp3__HERE". You can delete them if you want, but they don't do anything. Just for reference.
Files must be named "bootanimation.zip" and "android_audio.zip", otherwise won't work.
The script "tt_uni_boot" looks for the animation and sound in the rom, and replaces it depending on what it finds.
This works on AOSP, Sense, Sprint, HTC, and Verizion
The update.zip below is what you should use as your base if you want to make your bootanimation universal for all roms.
Also, if anyone wants to flash it as is, it contains this lovely animation:
Original Thread Here
Universal Bootanimation update.zip v0.0.1 - January 08, 2012
Enjoy!
Please report feedback. I and dean_fx tested it before I posted, but if you want different feature or something like that let me know.
Tommy
edit1.
And in case anyone wants to adapt my script, I am more than happy to share. Just give a little credit
Sharing means caring. And collaborative efforts yield better results.
Code:
#!/system/bin/bash
#tommytomatoe
#universal animation flasher
# creating logfile "lockscreen" on sdcard
log=sdcard/bootanimation.log
touch $log
# mounting system as R/W
busybox mount -o remount,rw /system
echo "/system mounted as R/W" > $log
echo "" >> $log
# doing some checks
# bootanimation locatioon
if busybox [ -e /system/customize/resource/bootanimation.zip ]; then
BOOT_ANI=/system/customize/resource/bootanimation.zip
elif busybox [ -e /data/local/bootanimation.zip ]; then
BOOT_ANI=/data/local/bootanimation.zip
elif busybox [ -e /system/media/bootanimation.zip ]; then
BOOT_ANI=/system/media/bootanimation.zip
elif busybox [ -e /system/customize/resource/spc_bootanimation.zip ]; then
BOOT_ANI=/system/customize/resource/spc_bootanimation.zip
elif busybox [ -e /data/local/spc_bootanimation.zip ]; then
BOOT_ANI=/data/local/spc_bootanimation.zip
elif busybox [ -e /system/media/spc_bootanimation.zip ]; then
BOOT_ANI=/system/media/spc_bootanimation.zip
elif busybox [ -e /system/customize/resource/VZW_bootanimation.zip ]; then
BOOT_ANI=/system/customize/resource/VZW_bootanimation.zip
elif busybox [ -e /data/local/VZW_bootanimation.zip ]; then
BOOT_ANI=/data/local/VZW_bootanimation.zip
elif busybox [ -e /system/media/VZW_bootanimation.zip ]; then
BOOT_ANI=/system/media/VZW_bootanimation.zip
elif busybox [ -e /system/customize/resource/hTC_bootanimation.zip ]; then
BOOT_ANI=/system/customize/resource/hTC_bootanimation.zip
elif busybox [ -e /data/local/hTC_bootanimation.zip ]; then
BOOT_ANI=/data/local/hTC_bootanimation.zip
elif busybox [ -e /system/media/hTC_bootanimation.zip ]; then
BOOT_ANI=/system/media/hTC_bootanimation.zip
else
echo "Bootanimation does not exist" >> $log
exit 1
fi
# bootanimation sound location
if busybox [ -e /system/customize/resource/android_media.mp3 ]; then
BOOT_SOUND=/system/customize/resource/android_media.mp3
elif busybox [ -e /data/local/android_media.mp3 ]; then
BOOT_SOUND=/data/local/android_media.mp3
elif busybox [ -e /system/media/android_media.mp3 ]; then
BOOT_SOUND=/system/media/android_media.mp3
elif busybox [ -e /system/customize/resource/android_audio.mp3 ]; then
BOOT_SOUND=/system/customize/resource/android_audio.mp3
elif busybox [ -e /data/local/android_audio.mp3 ]; then
BOOT_SOUND=/data/local/android_audio.mp3
elif busybox [ -e /system/media/android_audio.mp3 ]; then
BOOT_SOUND=/system/media/android_audio.mp3
elif busybox [ -e /system/customize/resource/SPC_animation_final.mp3 ]; then
BOOT_SOUND=/system/customize/resource/SPC_animation_final.mp3
elif busybox [ -e /data/local/SPC_animation_final.mp3 ]; then
BOOT_SOUND=/data/local/SPC_animation_final.mp3
elif busybox [ -e /system/media/SPC_animation_final.mp3 ]; then
BOOT_SOUND=/system/media/SPC_animation_final.mp3
else
echo "Bootanimation sound does not exist" >> $log
fi
echo "$BOOT_ANI" >> $log
echo "$BOOT_SOUND" >> $log
echo "" >> $log
# moving animation
busybox mv -f /data/local/tmp/bootanimation.zip $BOOT_ANI
if busybox [ -e /data/local/tmp/bootanimation.zip ] ; then
buxybox rm -f /data/local/tmp/bootanimation.zip
fi
if busybox [ -e $BOOT_ANI ] ; then
echo "SUCCESS! Bootanimation moved to $BOOT_ANI" >> $log
else
echo "FAILURE! Bootanimation not moved to $BOOT_ANI" >> $log
fi
echo "" >> $log
# moving busybox mv -f /data/local/tmp/bootanimation.zip $BOOT_ANI
busybox mv -f /data/local/tmp/android_audio.mp3 $BOOT_SOUND
if busybox [ -e /data/local/tmp/android_audio.mp3 ] ; then
buxybox rm -f /data/local/tmp/android_audio.mp3
fi
if busybox [ -e $BOOT_SOUND ] ; then
echo "SUCCESS! Bootanimation sound moved to $BOOT_SOUND" >> $log
else
echo "FAILURE! Bootanimation sound moved to $BOOT_SOUND" >> $log
fi
echo "" >> #log
echo "Universal Bootanimation Flasher Commencing" >> $log
Click to expand...
Click to collapse
I do something a little different, I take the file.from aosp, its named bootanimation.zip, rename it to spc_bootanimation.zip and place it in system/cutomize/resource. Using root explorer. I reboot, and.it works. I use the ics animation on my on my swag rom.
Sent from my PC36100 using xda premium
davidstjohn1 said:
I do something a little different, I take the file.from aosp, its named bootanimation.zip, rename it to spc_bootanimation.zip and place it in system/cutomize/resource. Using root explorer. I reboot, and.it works. I use the ics animation on my on my swag rom.
Sent from my PC36100 using xda premium
Click to expand...
Click to collapse
Yep. That is the tradition method. But now the maker of the bootanimation just needs to post one zip that works on all roms. How handy
Sent from my PC36100 using Tapatalk
If I ever post another boot animation, you better believe I'm using this! Would save a ton of random "where does this go?" questions..
Sent from my PC36100 using xda premium
This looks familiar. Hmmmmm. Lol.
Great work Tommy!
Sent from my RamenizedEvo on Cricket.
tommytomatoe said:
Yep. That is the tradition method. But now the maker of the bootanimation just needs to post one zip that works on all roms. How handy
Sent from my PC36100 using Tapatalk
Click to expand...
Click to collapse
Tommy,
You are thanked x2.
You're as busy as a cat covering up sh*t.
I've been trying to quantify your knowledge and sum it up in a few words. I finally figured it out. You, my friend, are an "idea man". Your knowledge keeps expanding because of the unique ideas you formulate when you are challenged with each new endeavor. Yet, it goes beyond just that. You have the generosity to share your ideas and solutions with the community, which encourages others to participate. The kindness and respect that you show to all members of this community is refreshing and much appreciated. Thank you for all your contributions.
Mark
First off, great concept!
However, looking through the bash script i noticed what appear to be a few bugs.
1: some typos in the comments and echoed text.
2: you check for an existing sound and set it to BOOT_SOUND but if not found the script continues without BOOT_SOUND initialised to anything.
3: you typed "buxybox" instead of "busybox" in two locations (durring the move process)
4: when replacing the animation you move the new file to BOOT_ANI, then check for and delete the temp file. Then you check if BOOT_ANI exists and report success or failure. The problem as written is that BOOT_ANI always exists, regardless if the move operation succeeded. Same problem for the sound.
I'm working on a fix for these issues and will post it later today, after i have a chance to test it.
-SLS-
SouL Shadow said:
First off, great concept!
However, looking through the bash script i noticed what appear to be a few bugs.
1: some typos in the comments and echoed text.
2: you check for an existing sound and set it to BOOT_SOUND but if not found the script continues without BOOT_SOUND initialised to anything.
3: you typed "buxybox" instead of "busybox" in two locations (durring the move process)
4: when replacing the animation you move the new file to BOOT_ANI, then check for and delete the temp file. Then you check if BOOT_ANI exists and report success or failure. The problem as written is that BOOT_ANI always exists, regardless if the move operation succeeded. Same problem for the sound.
I'm working on a fix for these issues and will post it later today, after i have a chance to test it.
-SLS-
Click to expand...
Click to collapse
Thanks for those notes I caught most of these errors directly after I made posted. But this was just a fun idea I had to help out someone.
1. Yep. lol. locatioon isn't a word.
2. Good point. Bad logic on my part. But the script works regardless. If there is no "BOOt_SOUND" then there will be nothing to move and so the script will just error out during this part. No big deal since there isn't a sound anyways...but it should be fixed regardless.
3. buxybox is also not a word. lol. This was my first typo I noticed after putting the script up. I didn't bother to go in and fix it because the command is actually redundant. In the busybox mv -f command, the file is moved from the original location. No need to "busybox rm" it, or in my case "buxybox"
4. I actually didn't think about this. I wrote the script with intent to put any bootanimation where it belongs. I put the logs in there just for testing purposes and didn't consider that the animation/sound would exist regardless of failure.
Feel free to improve the script at your convenience! That is why I posted it so other users can improve.
While these errors should be fixed, the script still works as intended Only detail oriented people will notice.
I already have an updated version prepared but I will wait for your version. I will post it up
Just got home and about to begin working on this. just wanted to note that the check for a BOOT_SOUND is important in the case where a user doesn't currently have sound and is flashing one that does include a sound. In that scenario they would end up with only the new animation and no sound.
I think i have a solution to choose a default location when no sound is currently present. Will test and report back.
-SLS-
ok, after a little work, some testing, and many many delays, my update to your original script:
http://www.soulshadow.net/android/tt_uni_boot
a few things to note:
- i left the first line unchanged, however to work on my evo running CM 7.1 i had to change the path to /system/xbin/bash. *** Also works using /system/bin/sh ***
- I added more logging
- I added more conditional checks and changed the execution order. can now be used to replace an animation, a sound, or both. depending which files are included in the zip.
- Added a "default" location if no existing animation or sound is found.
- Currently only supports single phone distribution. Meaning, each phone model still requires a different animation zip file because of display size differences. hopefully this limitation can be eliminated with planned run time discovery, creating a truly universal script.
To Do:
- check and possibly reorder the animation and sound search order.
- find out which location should be used as a default
- check permissions on installed files
- run time discovery of phone specs (manufacturer, model, rom) to aid in installation choices.
- remove or back up existing files first
- read command line arguments to change run time functionality and allow for usage from within an app
I am currently working on some of the additional features, but wanted to share what i have so far.
Enjoy!
-SLS-
SouL Shadow said:
ok, after a little work, some testing, and many many delays, my update to your original script:
http://www.soulshadow.net/android/tt_uni_boot
a few things to note:
- i left the first line unchanged, however to work on my evo running CM 7.1 i had to change the path to /system/xbin/bash. *** Also works using /system/bin/sh ***
- I added more logging
- I added more conditional checks and changed the execution order. can now be used to replace an animation, a sound, or both. depending which files are included in the zip.
- Added a "default" location if no existing animation or sound is found.
- Currently only supports single phone distribution. Meaning, each phone model still requires a different animation zip file because of display size differences. hopefully this limitation can be eliminated with planned run time discovery, creating a truly universal script.
To Do:
- check and possibly reorder the animation and sound search order.
- find out which location should be used as a default
- check permissions on installed files
- run time discovery of phone specs (manufacturer, model, rom) to aid in installation choices.
- remove or back up existing files first
- read command line arguments to change run time functionality and allow for usage from within an app
I am currently working on some of the additional features, but wanted to share what i have so far.
Enjoy!
-SLS-
Click to expand...
Click to collapse
Thanks man! Glad someone took this script and adding to it. Thank you!
Sent from my PC36100 using Tapatalk
Dead links
canievision said:
Dead links
Click to expand...
Click to collapse
Ive been meaning to re-upload. Will do in a few days.
Sent from my EVO using Tapatalk 2
Hey can i get that flashable zip? the links seem to be dead
imilleson said:
Hey can i get that flashable zip? the links seem to be dead
Click to expand...
Click to collapse
I would like this also

Script: Check Samsung ROMs tar.md5 format using Linux/bash

Hi,
The Samsung ODIN .tar.md5 format files contain an embedded md5sum signature for download checking. I found this handy bash script for checking .tar.md5 format for md5sum. Original sources are (thanks to contributors!)
http://stackoverflow.com/questions/...how-to-remove-md5-extension/17751305#17751305
http://stackoverflow.com/questions/...-case-in-bash-shell-scripting/2264435#2264435
I've added lowercase conversion and echoing both signatures, just for checking.
The script (source it and you'll have check_tar_md5 command in your env).
Code:
#! /bin/bash
check_tar_md5 () {
local file="${1:?Required: file to check}"
[[ ! -f "$file" ]] && {
echo "File not found: $file" >&2
return 1
}
local filename="$(basename "$file")"
if [ "${filename##*.}" = md5 ]; then filename="${filename%.*}"; fi;
local md5_line_length=$(printf "%032d *%s\n" 0 "$filename" | wc -c)
local embedded_md5=$(tail -c $md5_line_length "$file" | tr [A-Z] [a-z] | ( read md5 rest; echo $md5 ) )
local actual_md5=$(head -c -$md5_line_length "$file" | md5sum | ( read md5 rest; echo $md5 ) )
echo "Embedded md5: " $embedded_md5
echo "Actual md5: " $actual_md5
if [ $embedded_md5 = $actual_md5 ]; then
echo "$file: OK"
else
echo "$file: FAILED"
return 1
fi
}
[[ ! -z "$1" ]] && check_tar_md5 "$1"

[SCRIPT] Helium server PC download - separation

This is simple linux script I've made to separate all apps from one big zip file made by Helium sever -> PC download. Helium wiki says to don't try to do anything with this file, but I didn't want to restore all that stuff that I've backuped before bootloader unlock on my nexus 4. I'm sure it can be writed better, but it's working
Just place script file and unziped backup folder (must be named "backup") in one directory. After execution of the script everything should be ready to copying to carbon folder on your sd card/internal memory and restoring like after normal backup.
Tested on Ubuntu 14.04.
I'm not responsible for data loss or any other problem. Use at your own risk.
Constructive criticism welcome.
Code:
#!/bin/bash
DIRECTORY='./backup'
if [ -f $DIRECTORY/backup.json ]; then
cp $DIRECTORY/backup.json $DIRECTORY/temp.json
sed -e "s/{\"packages\"://g" $DIRECTORY/temp.json > $DIRECTORY/temp2.json
tr '[]' ' ' < $DIRECTORY/temp2.json | tee $DIRECTORY/temp.json
tr '}' '\n' < $DIRECTORY/temp.json | tee $DIRECTORY/temp2.json
sed -e "s/,{/{/g" $DIRECTORY/temp2.json > $DIRECTORY/temp.json
sed -e 's/^[ \t]*//' $DIRECTORY/temp.json > $DIRECTORY/temp2.json
sed '/^$/d' $DIRECTORY/temp2.json > $DIRECTORY/temp.json
sed 's/\([^|]\)$/\1}/' $DIRECTORY/temp.json > $DIRECTORY/temp_last.json
fi;
count=`ls -1 $DIRECTORY/*.ab 2>/dev/null | wc -l`
if [ $count != 0 ]; then
for i in $DIRECTORY/*.ab ; do
AB=$(basename $i)
mkdir -p $DIRECTORY/${AB%.*}
mv -i $DIRECTORY/$AB $DIRECTORY/${AB%.*}/
if [ -f $DIRECTORY/${AB%.*}.png ]; then
mv -i $DIRECTORY/${AB%.*}.png $DIRECTORY/${AB%.*}/._${AB%.*}.png
fi;
if [ ! -f $DIRECTORY/${AB%.*}/${AB%.*}.json ];then
touch $DIRECTORY/${AB%.*}/${AB%.*}.json
fi;
while read p; do
if [[ "$p" =~ "${AB%.*}" ]]; then
echo "$p" > $DIRECTORY/${AB%.*}/${AB%.*}.json
fi;
done <$DIRECTORY/temp_last.json
done;
fi;
rm $DIRECTORY/temp.json
rm $DIRECTORY/temp2.json
rm $DIRECTORY/temp_last.json
exit;

Can somebody help me with this shell script?

Basically what I want to do is convert this into batch script for windows and by using Linux Binaries from Sourceforge create a script that basically does the same thing except it doesnt have to be pushed into my Phone's system it works directly in windows using ADB commands!
The script in question looks like this
Spoiler: THIS Script
Bash:
#adb shell mkdir /data/media/0/PartitionImages
#adb push .\backupPartitions.sh /data/media/0/PartitionImages/backupPartitions.sh
#adb shell chmod 0755 /data/media/0/PartitionImages/backupPartitions.sh
#adb shell /data/media/0/PartitionImages/backupPartitions.sh
#adb pull /data/media/0/PartitionImages .\PartitionImages
max_blocks=102400
names=""
compress=0
while getopts "h?bzn:" opt; do
case "$opt" in
h|\?)
echo "Usage $0 [-z] [-b MaxBlocks] [-n partition1 ] [-n partition2 ]"
echo " options:"
echo "-z optional to tar.gz the output folder default=false"
echo "-b 102400 optional maximum number of blocks of the partition - 0 will dump all partitions default=$max_blocks"
echo "-n partitionName... optional - one or more partitions to dump"
exit 0
;;
z) compress=1
;;
b) max_blocks=$OPTARG
;;
n) names+=" $OPTARG"
;;
esac
done
script=$(readlink -f "$0")
script_path=$(dirname "$script")
serial=$(cat /sys/class/android_usb/f_accessory/device/iSerial)
serial_date=$serial/$(date +"%Y_%m_%d_%H_%M_%S")
output_path=$script_path/$serial_date
echo "********************************"
echo "Backup partitions TO $output_path"
echo "********************************"
mkdir -p $output_path
part_dir=$(find /dev/block/platform -name by-name)
partitions=$(ls -la $part_dir | awk '{if ( $10 == "->") print $9 ">" $11 }')
getprop > $output_path/build.prop
echo "Id Name Size MD5" > $output_path/partitions.txt
for f in $partitions
do
part_id=$(echo $f | sed 's/^[^>]*>\/dev\/block\///')
part_name=$(echo $f | sed 's/>.*//')
size=$(cat /proc/partitions | awk -v p=$part_id '{if ( $4 == p ) print $3}')
checksum="0"
skip=0
if [ $max_blocks -gt 0 -a $size -gt $max_blocks ]
then
skip=1
echo "Skipping $part_name Id $part_id due to size"
else
if [ "$names" -ne "" ]
then
if echo $names | grep -w $part_name > /dev/null; then
skip=0
else
skip=1
echo "Skipping $part_name Id $part_id"
fi
fi
fi
if [ "$skip" -eq "0" ]
then
echo "Processing $part_name Id $part_id Size $size";
dd if=/dev/block/$part_id of=$output_path/$part_name.img
checksum=$(md5sum -b $output_path/$part_name.img | sed 's/ .*//')
fi
echo "$part_id $part_name $size $checksum" >> $output_path/partitions.txt
done
if [ "$compress" -eq "1" ]
then
cd $script_path
tar cz $serial_date > $output_path.tar.gz
rm -rf $output_path
fi
its from an old Xda Dev thread original post and author
givitago​​
I tried by guidelines from an "Appendix N. Converting DOS Batch Files to Shell Scripts" from another site to turn the shell script variables into batch script ones but since I got no experience with either of them my attempt turned into an amalgamation of the two's code in one..
Spoiler: it turned Into THIS
Code:
::adb shell mkdir /data/media/0/PartitionImages
::adb push .\backupPartitions.sh /data/media/0/PartitionImages/backupPartitions.sh
::adb shell chmod 0755 /data/media/0/PartitionImages/backupPartitions.sh
::adb shell /data/media/0/PartitionImages/backupPartitions.sh
::adb pull /data/media/0/PartitionImages .\PartitionImages
%max_blocks==102400
%names==""
%compress==0
while getopts "h?bzn:" opt; do
case "$opt" in
h|\?)
echo "Usage $0 [-z] [-b MaxBlocks] [-n partition1 ] [-n partition2 ]"
echo " options:"
echo "-z optional to tar.gz the output folder default=false"
echo "-b 102400 optional maximum number of blocks of the partition - 0 will dump all partitions default=$max_blocks"
echo "-n partitionName... optional - one or more partitions to dump"
exit 0
;;
z) compress=1
;;
b) max_blocks=$OPTARG
;;
n) names+=" $OPTARG"
;;
esac
done
%script%==%(echo %CD% "%0")
%script_path%==(dirname "%script")
%serial%==%(adb shell cat /sys/class/android_usb/f_accessory/device/iSerial)
%serial_date%==%serial% /%(date +"%Y_%m_%d_%H_%M_%S")
%output_path%==%script_path%/%serial_date%
echo "********************************"
echo "Backup partitions TO $output_path"
echo "********************************"
mkdir -p %output_path%
%part_dir%==%(adb shell find /dev/block/platform -name by-name)
%partitions%==%(ls -la %part_dir% | awk '{if ( %10 == "->") print %9 ">" %11 }')
adb shell getprop > %output_path%/build.prop
echo "Id Name Size MD5" > %output_path%/partitions.txt
for %%i in %partitions do
%part_id=%(echo %f | sed 's/^[^>]*>\/dev\/block\///')
%part_name=%(echo %f | sed 's/>.*//')
%size=%(adb shell cat /proc/partitions | awk -v p==%part_id% '{if ( %4 == p ) print %3}')
checksum="0"
skip==0
if [ %max_blocks -gt 0 -a %size -gt %max_blocks ]
then
skip=1
echo "Skipping %part_name% Id %part_id% due to size"
else
if [ "%names" -ne "" ]
then
if echo %names | grep -w %part_name% > /dev/null; then
skip==0
else
skip==1
echo "Skipping %part_name% Id %part_id%"
fi
fi
fi
if [ "$skip" -eq "0" ]
then
echo "Processing %part_name% Id %part_id% Size %size";
'adb shell pull' /dev/block/%part_id% %output_path%/%part_name%.img
checksum==%(md5sum -b %output_path%/%part_name%.img | sed 's/ .*//')
fi
echo "%part_id% %part_name% %size %checksum" >> %output_path%/partitions.txt
done
if [ "%compress" -eq "1" ]
then
cd %script_path%
tar cz %serial_date% > %output_path%.tar.gz
rm -rf %output_path%
fi
additionally I have pretty much all linux commands's binaries on the same folder as the .bat script so as long as the syntax is correct and nothing finniky going on it should work technically but since I got no experience I can't do this on my own...
You may use the DOS script used here
[TOOL][ADB][WIN]Android Partitions Backupper / Cloner
Hi all, wrote a Windows CMD script that backups / clones partitions of an Android device via ADB because I wasn't content with any 3rd-party APK what claims to do this job. The backups /clones are stored on Windows computer as...
forum.xda-developers.com
as a template.
jwoegerbauer said:
You may use the DOS script used here
[TOOL][ADB][WIN]Android Partitions Backupper / Cloner
Hi all, wrote a Windows CMD script that backups / clones partitions of an Android device via ADB because I wasn't content with any 3rd-party APK what claims to do this job. The backups /clones are stored on Windows computer as...
forum.xda-developers.com
as a template.
Click to expand...
Click to collapse
I have tried that script itself and it failed at "DM-Verity" and SELinux enforcement also for some reason no logs at all in temp folder

Categories

Resources