[Q] busybox and touch command - Android Q&A, Help & Troubleshooting

Who can help me with the syntax of the command touch?
Using the touch command as follows:
touch -d "01/01/2012 00:00:00" \ data \ data \ com.android.providers.telephony \ databases \ mmssms.db
the system outputs the following message:
unknow option - d etc ...
But Usage Command is:
touch [-c] [-d DATE] FILE [FILE]
BR
die-hard

Yeah, that's weird. It works as you typed it in a regular linux shell, but the busybox on my android gives me the same error. Might be a bug in busybox, or perhaps the date parser in the busybox version is less tolerant on the date format. It may be a config option as well. I know that date/time parsing is very "expensive" in libc and perhaps busybox just doesn't implement it by default.

10x bro,
I solved installing busybox 1.18.0 git

My busybox touch accepts dates in ISO format:
/ # touch -d '2011-1-1 23:1' x
/ # ls -l x
-rw-rw-rw- root shell 0 2011-01-02 00:01 x
Click to expand...
Click to collapse

Hi
I have CM 10.1 with busybox 1.20.2-jb installed. Touch binary doenst have -d option:
Code:
1|[email protected]:/sdcard $ touch --h
touch --h
touch: usage: touch [-alm] [-t time_t] <file>
-t option only accept date in unix timestamp format, but default format ( [[[[cc]yy]MM]dd]hhmm[.ss] ) needed for me.
Can anybody provide touch binary with -d option support or with -t option, that accept date in this format: [[[[cc]yy]MM]dd]hhmm[.ss]?
Second question:
Code:
[email protected]:/ $ awk 'BEGIN {print mktime("1970-01-01 00 00 00")}' <
-5454000
Why awk return -5454000 instead 0?
I tried update busybox to 1.21.0 version, it doesnt help.

memtew said:
Hi
I have CM 10.1 with busybox 1.20.2-jb installed. Touch binary doenst have -d option:
Code:
1|[email protected]:/sdcard $ touch --h
touch --h
touch: usage: touch [-alm] [-t time_t] <file>
-t option only accept date in unix timestamp format, but default format ( [[[[cc]yy]MM]dd]hhmm[.ss] ) needed for me.
Can anybody provide touch binary with -d option support or with -t option, that accept date in this format: [[[[cc]yy]MM]dd]hhmm[.ss]?
Second question:
Code:
[email protected]:/ $ awk 'BEGIN {print mktime("1970-01-01 00 00 00")}' <
-5454000
Why awk return -5454000 instead 0?
I tried update busybox to 1.21.0 version, it doesnt help.
Click to expand...
Click to collapse
Use the touch inside busybox, not the one that comes with the stock rom. Install Busybox from Stericson on your android device. It has also the -d option. You must run it as root, so check that you are superuser if using a script.
Code:
su
busybox touch -c -t YYYYMMDDHHMM[.ss] yourfile

hi,
i have the command working, but is it possible to keep the date and time of each file like "vid_yyyymmdd_hhmmss.mp4" to push it in the command for each file of the folder ?
Thanks.

nobody to help ???

diabolyk said:
hi,
i have the command working, but is it possible to keep the date and time of each file like "vid_yyyymmdd_hhmmss.mp4" to push it in the command for each file of the folder ?
Thanks.
Click to expand...
Click to collapse
You want to rename the files?

scandiun said:
You want to rename the files?
Click to expand...
Click to collapse
no, just change the time of creation of the file

diabolyk34 said:
no, just change the time of creation of the file
Click to expand...
Click to collapse
Don't understand exactly what you want to do.

scandiun said:
Don't understand exactly what you want to do.
Click to expand...
Click to collapse
I have found a command that working well but I should change the files one by one and I would like to find a command which is changing all videos files of a folder.
video name for example : vid_20170717_103251.mp4
need to extract date and time (in the name of the file) to put it in the command.
here the command which is working :
busybox touch -c -t 201707171032 *
and it changes all the files of the folder with the *...
I would like to extract the elements of the name from each file to give it its own date and time.

diabolyk34 said:
I have found a command that working well but I should change the files one by one and I would like to find a command which is changing all videos files of a folder.
video name for example : vid_20170717_103251.mp4
need to extract date and time (in the name of the file) to put it in the command.
here the command which is working :
busybox touch -c -t 201707171032 *
and it changes all the files of the folder with the *...
I would like to extract the elements of the name from each file to give it its own date and time.
Click to expand...
Click to collapse
Ok to do that you need a shell (bash) script. For example this code will get the date in the format you want, now you just need to read it from files and change the timestamp accordingly.
Code:
echo vid_20110717_103251.mp4 | sed 's/vid_*//' | sed 's;.mp4*;;' | sed 's/_//'
Test it online here: http://www.learnshell.org/

scandiun said:
Ok to do that you need a shell (bash) script. For example this code will get the date in the format you want, now you just need to read it from files and change the timestamp accordingly.
Code:
echo vid_20110717_103251.mp4 | sed 's/vid_*//' | sed 's;.mp4*;;' | sed 's/_//'
Test it online here: http://www.learnshell.org/
Click to expand...
Click to collapse
ok thanks for your help, your code is well working
Is it possible to keep all without the seconds (last 2 digits before .mp4) ?
And after that it should put the result in the command 'busybox touch -c -t result name_of_the_file'
and how to repeat that for each file named 'vid_xxxx' ?
thanks a lot

diabolyk34 said:
ok thanks for your help, your code is well working
Is it possible to keep all without the seconds (last 2 digits before .mp4) ?
And after that it should put the result in the command 'busybox touch -c -t result name_of_the_file'
and how to repeat that for each file named 'vid_xxxx' ?
thanks a lot
Click to expand...
Click to collapse
Go to the folder of the vids with "cd /sdcard/DCIM/Videos" or the appropriate and then execute this:
Code:
for i in * ; do touch -c -t "$(echo $i | sed 's/vid_*//' | sed 's;.mp4*;;' | sed 's/_//' | sed 's/..$//')" "$i" ; done
Make sure that in that folder there are only files that have the same exact filename pattern.

scandiun said:
Go to the folder of the vids with "cd /sdcard/DCIM/Videos" or the appropriate and then execute this:
Code:
for i in * ; do touch -c -t "$(echo $i | sed 's/vid_*//' | sed 's;.mp4*;;' | sed 's/_//' | sed 's/..$//')" "$i" ; done
Make sure that in that folder there are only files that have the same exact filename pattern.
Click to expand...
Click to collapse
in the folder there is img and videos but if i should put videos on a separate folder i can...
this code will do all i need ? (i think missing just "busybox" in the code)
extract the name of each file without seconds, put for each one the extraction in the command : busybox touch -c -t 201707181200 vid_20170718_120000.mp4 (for example of a file of today at 12 o'clock)

diabolyk34 said:
in the folder there is img and videos but if i should put videos on a separate folder i can...
this code will do all i need ? (i think missing just "busybox" in the code)
extract the name of each file without seconds, put for each one the extraction in the command : busybox touch -c -t 201707181200 vid_20170718_120000.mp4 (for example of a file of today at 12 o'clock)
Click to expand...
Click to collapse
This code will alter only files starting with vid:
Code:
for i in vid* ; do touch -c -t "$(echo $i | sed 's/vid_*//' | sed 's;.mp4*;;' | sed 's/_//' | sed 's/..$//')" "$i" ; done
You can try with or without busybox first and see which one works for you.

scandiun said:
This code will alter only files starting with vid:
Code:
for i in vid* ; do touch -c -t "$(echo $i | sed 's/vid_*//' | sed 's;.mp4*;;' | sed 's/_//' | sed 's/..$//')" "$i" ; done
You can try with or without busybox first and see which one works for you.
Click to expand...
Click to collapse
thank you very much i will try this in an hour to send you the answer if it's working or not
are you a developper ? cause it seems very hard to know all that...

i have another question, is it possible to put 1 or 2 less than the hour because of GMT ?
201707172000 should be 201707171900...

the answer of the command (not working) is :
touch: invalid date 'VID20170717_2000'
repeat for all lines....
i think it keep too many characters.
characters keeped should be 201707172000 (without "VID" and without "_")
how to delete that from the echo ?

Related

HD2 SD/MALDR System.ext2 Auto Builder V1.0

1. purpose just speeding up the system.ext2 file making.I'm lazy....
2. use it in Ubuntu O.S. with root account
3. decompress this auto builder and put it in folder /root or else place
4. put the CWM ROM's zip file in the folder "cwm_rom" and put the kernel modules *.ko files in the folder " kernel"
5.open terminal, cd the folder of this scripts, and execute it.
bash systemext2builder.sh then it will auto build the system.ext2 for SD ROM.
here is a demo how to use http://www.mediafire.com/?3lj5iuiv6ddcppi or http://dl.dbank.com/c0xn7ck608
Code:
#!/bin/bash
####################################################
# HD2 Android SD/MAGLDR ROM system.ext2 Auto builder.
# version 1.0
# By 3dak on 2011-04-29
##################################################
# to get current script's path
script_dir=`dirname $(readlink -f $0)`
extract_dir=$script_dir/extract
mount_dir=/mnt/system
#check the $mount_dir folder and ensure it is unmount and it's a fresh empty folder
if [ -d "$mount_dir" ] ; then
umount $mount_dir
rm -rf $mount_dir
mkdir $mount_dir
else
mkdir $mount_dir
fi
#to ensure there is no old extract folder or system.ext2
if [ -d "$extract_dir" ] ; then
rm -rf $extract_dir
fi
if [ -f $script_dir/system.ext2 ]; then
rm -f $script_dir/system.ext2
fi
#to get the main file name of the latest MIUI CWM ROM (*.zip) and decompress it!
# Please put the latest MIUI CWM ROM in the folder $script_dir/cwm_rom
build=`ls $script_dir/cwm_rom/*.zip | tail -1`
unzip $build -d $extract_dir/
#now change the cwm_rom kernel to SD version's kernel
#Please put all kernel modules *.ko files in the folder $script_dir/kernel
rm $extract_dir/system/lib/modules/*.ko
cp $script_dir/kernel/*.ko $extract_dir/system/lib/modules/
# Now create a fresh empty 250MB system.ext2 image file and format it.
dd if=/dev/zero of=$script_dir/system.ext2 bs=1048576 count=250
mke2fs -F $script_dir/system.ext2
#Now mount this fresh system.ext2
mount -o loop $script_dir/system.ext2 $mount_dir
#Now copy the CWM ROM's system folder to the $mount_dir (/mnt/system )
cp -ar $extract_dir/system/* $mount_dir/
############################################################
# Read CWM ROM's updater-script
# Createa Symlinks and set permissions of folders and files
#############################################################
updater_script=$extract_dir/META-INF/com/google/android/updater-script
# create symbolic links
SYMLINKS=`grep "symlink" $updater_script | cut -d'"' -f2`
for SYMLINK in $SYMLINKS; do
echo "Creating symolic links for $SYMLINK..."
if [ "$SYMLINK" = "busybox" -o "$SYMLINK" = "iwmulticall" ]; then
LINK_DIR='/system/xbin/'
elif [ "$SYMLINK" = "toolbox" ]; then
LINK_DIR='/system/bin/'
fi
MATCHES=`awk '/symlink\(\"'"$SYMLINK"'/,/\);/ {print}' $updater_script | \
sed "s/symlink(\"$SYMLINK\",//g" | \
sed 's/);//g' | \
sed 's/"//g' | \
sed 'N;s/\n//g' | \
sed 's/ //g' | \
sed 's/,/ /g' | \
sed "[email protected][email protected]@g"`
cd /mnt/$LINK_DIR
for LINK in $MATCHES; do
echo -n "Linking $SYMLINK to $LINK... "
ln -sf $SYMLINK $LINK && echo "done"
done
done
# set permissions
grep "set_perm_recursive" $updater_script | grep -v "tmp" | grep -v "recovery" | \
while read LINE; do
PERM=`echo $LINE | sed 's/set_perm_recursive(//g' | sed 's/);//g' | sed 's/"//g' | sed 's/ //g'`
USER=`echo $PERM | cut -d',' -f1`;
GROUP=`echo $PERM | cut -d',' -f2`;
DIR_PERM=`echo $PERM | cut -d',' -f3`;
FILE_PERM=`echo $PERM | cut -d',' -f4`;
TARGET=`echo $PERM | cut -d',' -f5`;
echo -n "Setting permissions for $TARGET... "
chown -R $USER:$GROUP /mnt$TARGET
chmod -R $DIR_PERM /mnt$TARGET
find /mnt$TARGET -type f -exec chmod $FILE_PERM {} \; && echo "done"
done
grep "set_perm" $updater_script | grep -v "recursive" | grep -v "tmp" | grep -v "recovery" | \
while read LINE; do
PERM=`echo $LINE | sed 's/set_perm(//g' | sed 's/);//g' | sed 's/"//g' | sed 's/ //g'`
USER=`echo $PERM | cut -d',' -f1`;
GROUP=`echo $PERM | cut -d',' -f2`;
FILE_PERM=`echo $PERM | cut -d',' -f3`;
TARGET=`echo $PERM | cut -d',' -f4`;
echo -n "Setting permissions for $TARGET... "
chown $USER:$GROUP /mnt$TARGET
chmod $FILE_PERM /mnt$TARGET && echo "done"
done
#now unmount system.ext2
umount $mount_dir
#cleanup
rm -rf $extract_dir
echo " All Done!"
# EOF by 3dak :) 2011-04-29
if you wanna a system.img file too for DAF ROM, add the follwoing line before this line #now unmount system.ext2
Code:
mkyaffs2image $mount_dir $script_dir/system.img
tools.zip is some tools for rom making. put them in the foloer
/usr/local/bin
Wonderful !
Would love to see such an application for Windows OS ....
that's very cool! now we can make new sd builds by ourselves
thanks 3dak!
3dak said:
1. purpose just speeding up the system.ext2 file making.I'm lazy....
Click to expand...
Click to collapse
Man this way you take away all the fun!!
Joking... I'm lazy, too!
great tool, work great to build miui 1.4.29
Thanks 3dak
It's so bad that I don't use Ubuntu OS!
I am looking for some tool like this for a long time but running in Windows OS!
kimquypticc said:
It's so bad that I don't use Ubuntu OS!
I am looking for some tool like this for a long time but running in Windows OS!
Click to expand...
Click to collapse
Use ubuntu.
Just make a live cd or live flash drive. It's worth it
Sent from my HD2 using XDA app
kimquypticc said:
It's so bad that I don't use Ubuntu OS!
I am looking for some tool like this for a long time but running in Windows OS!
Click to expand...
Click to collapse
Or use it in a VirtualBox.
It's rather easy
peter
this is just Awesome!
Awesome, I will test this soon!
Problem for build mimu 1.5.20
It's a good application.
I put the miui_HD2_1.5.20_3nhrpwvbo7_2.3.zip into the cwm_rom folder, and copy all *.ko files that extracted from the system.ext2's \lib\modules folder in the miui_HD2_1.5.20_3dak_SD_2.3.4_ACA_r518.7z into the kernel folder, then a system.ext2 file was built with no errors.
I replaced the origin system.ext2 from the miui_HD2_1.5.20_3dak_SD_2.3.4_ACA_r518 by this file, run it from my HD2 SD card, all was fine expect the GPRS. The origin system.ext2 hasn't this bug.
What's the different?
Ty 3dak for this. Are there no way to do this in Windows?
giveup said:
It's a good application.
I put the miui_HD2_1.5.20_3nhrpwvbo7_2.3.zip into the cwm_rom folder, and copy all *.ko files that extracted from the system.ext2's \lib\modules folder in the miui_HD2_1.5.20_3dak_SD_2.3.4_ACA_r518.7z into the kernel folder, then a system.ext2 file was built with no errors.
I replaced the origin system.ext2 from the miui_HD2_1.5.20_3dak_SD_2.3.4_ACA_r518 by this file, run it from my HD2 SD card, all was fine expect the GPRS. The origin system.ext2 hasn't this bug.
What's the different?
Click to expand...
Click to collapse
the different is my system.ext2 opened PPP mode while official MIUI ROM didn't.
giveup said:
It's a good application.
copy all *.ko files that extracted from the system.ext2's \lib\modules folder in the ?
Click to expand...
Click to collapse
in Ubuntu, how do you extract files from system.ext2?
Any comprehensive step by step?
ketzazu said:
in Ubuntu, how do you extract files from system.ext2?
Any comprehensive step by step?
Click to expand...
Click to collapse
Just mount it :
mkdir /mnt/mysystemext2
mount -t ext2 -o loop system.ext2 /mnt/mysystemext2
then go to /mnt/mysystemext2 folder to copy or modify
Sent from my HTC HD2 using xda premium
3dak said:
Just mount it :
mkdir /mnt/mysystemext2
mount -t ext2 -o loop system.ext2 /mnt/mysystemext2
then go to /mnt/mysystemext2 folder to copy or modify
Sent from my HTC HD2 using xda premium
Click to expand...
Click to collapse
Thanks! I'll try those commands instead.
3dak said:
Just mount it :
mkdir /mnt/mysystemext2
then go to /mnt/mysystemext2 folder to copy or modify
Sent from my HTC HD2 using xda premium
Click to expand...
Click to collapse
No matter what I do the system.ext2 is always missing in action, nowhere to be found even after I "sudo chmod 777" the folders. I always get the error "system.ext2: No such file or directory"
I have ubuntu installed in a different drive than windows 7
This is what I did: BTW, I always have to sudo since I don't login as root
I put this zipped NAND "Runnymede_0.82.401.1_v1.3_Tmous" to the folder as you instructed,
I extract all the ".ko" files from this ziped ROM and put them in the "kernel" folder as instructed.
I go to terminal and i sudo the bash command. It spits out the system.ext2 file with a lot of other files.
I copy the system.ext2 file to the Desktop.
then mkdir /mnt/mystemext2
then mount -t ext2 -o loop system.ext2 /mnt/mysystemext2
I sudo chmod 777 the folders to be able access them. I even drag the system.ext2 from the Desktop to the /nmt and mnt/systemext2.
Still, all is empty.
What am i doing wrong?
When I try to copy directly system.ext2 to /mnt or /mnt/system.ext2 I get "not enough space error" but I don't see anything in the "lost+found" folder or anywhere else.
And also what program to use in Ubuntu to be able to open and see and edit the contents of system.ext2 in the folder?
PS. What are the instructions to use tools.zip for ROM making?
Thanks!
ketzazu said:
No matter what I do the system.ext2 is always missing in action, nowhere to be found even after I "sudo chmod 777" the folders. I always get the error "system.ext2: No such file or directory"
I have ubuntu installed in a different drive than windows 7
This is what I did: BTW, I always have to sudo since I don't login as root
I put this zipped NAND "Runnymede_0.82.401.1_v1.3_Tmous" to the folder as you instructed,
I extract all the ".ko" files from this ziped ROM and put them in the "kernel" folder as instructed.
I go to terminal and i sudo the bash command. It spits out the system.ext2 file with a lot of other files.
I copy the system.ext2 file to the Desktop.
then mkdir /mnt/mystemext2
then mount -t ext2 -o loop system.ext2 /mnt/mysystemext2
I sudo chmod 777 the folders to be able access them. I even drag the system.ext2 from the Desktop to the /nmt and mnt/systemext2.
Still, all is empty.
What am i doing wrong?
When I try to copy directly system.ext2 to /mnt or /mnt/system.ext2 I get "not enough space error" but I don't see anything in the "lost+found" folder or anywhere else.
And also what program to use in Ubuntu to be able to open and see and edit the contents of system.ext2 in the folder?
PS. What are the instructions to use tools.zip for ROM making?
Thanks!
Click to expand...
Click to collapse
put system.ext2 in your home folder,
then open terminal,
cd ~ (this will goto your home folder)
ls (check if you can see system.ext2, if no, you put it at wrong place)
mkdir /mnt/mysystemext2
mount -t ext2 -o loop system.ext2 /mnt/mysystemext2
-----------------
or if you want to keep the created system.ext2 is mounted, just open the 3daksystemext2builder.sh,
#now unmount system.ext2
umount $mount_dir
change to
#now unmount system.ext2
#umount $mount_dir
this will keep the system.ext2 is at MOUNT status after the system.ext2 created. check folder /mnt/system and modify or copy
remember to umount it after you finish your work,
umount /mnt/system
3dak said:
put system.ext2 in your home folder,
then open terminal,
cd ~ (this will goto your home folder)
ls (check if you can see system.ext2, if no, you put it at wrong place)
mkdir /mnt/mysystemext2
mount -t ext2 -o loop system.ext2 /mnt/mysystemext2
-----------------
or if you want to keep the created system.ext2 is mounted, just open the 3daksystemext2builder.sh,
#now unmount system.ext2
umount $mount_dir
change to
#now unmount system.ext2
#umount $mount_dir
this will keep the system.ext2 is at MOUNT status after the system.ext2 created. check folder /mnt/system and modify or copy
remember to umount it after you finish your work,
umount /mnt/system
Click to expand...
Click to collapse
thanks again! I'll give it a try. But first, I have to figure out how to get damsel Ubuntu out of that sudden "Read only" blues madness.
Thank you finally found learning to learn!!!

[Q] Has anybody know how to root GT-I9001

Hi,
Is there some way to root I9001 now or I have to wait.
Firmware I9001XXKE8
Android 2.3.3
Kernel 2.6.35.7
I tried several methods (Superoneclick 1.7, 1.9.1, Gingerbreak 1.2) available for I9000 but nothing positive.
If someone can guide me in this process will be very appreciated.
Go here for step by step instructions: http://androidhogger.com/how-to-root-samsung-galaxy-s2-heres-the-tutorial.html.
Hi,
It is guide for I9100 but I have I9001 it is completely different hardware, so I doubt that the same guide can be applied to I9001.
Any news on rooting? Have you sucseeded?
No, still waiting, but it starts to sell to mass in Russia so soon will get news.
Since yesterday the new 2.3.4 firmware is out:
http://netload.in/datei5X4ZyAkNkO/I9001XXKP4_v2.3.4.rar.htm
(edit: maybe its not 2.3.4 ... samfirmware write 2.3.3)
... but we wait still for the root...
SPOOKY
afaik 2.3.x cannot be rooted. only 2.2.x
sweetnsour said:
afaik 2.3.x cannot be rooted. only 2.2.x
Click to expand...
Click to collapse
Say what? Ofcourse 2.3.x can be rooted. We just have to get more attention to the 9001 so that the rom builders actively start devving this device.
Any one knows how to root this device?
Sent from my GT-I9001 using XDA Premium App
I'm looking for a solution as well, please don't make me use Touchwiz..
Have tried to look into ways to root this phone. It looks like it'll need to be root in similar way to i9100. So guess will need to wait for dev to come up with a special kernel for rooting.
İ hope they they ll come up with new karnel as soon.as possible
Sent from my GT-I9001 using Tapatalk
sweetnsour said:
afaik 2.3.x cannot be rooted. only 2.2.x
Click to expand...
Click to collapse
Here http://forum.xda-developers.com/archive/index.php/t-1136781.html is afaik 2.3.3 rotted. I think there is a posibility to root I9001.
I hope so ....! Did u try this method?
Sent from my GT-I9001 using Tapatalk
westcrip said:
I hope so ....! Did u try this method?
Sent from my GT-I9001 using Tapatalk
Click to expand...
Click to collapse
Nope but I will try in this weekend. I found how to restore phone when you brick it (if something happen) , and it's not so hard. That's why I will use different method to root it. I just wonder if one of brick is avilable or more. I only know how to unbrick by this method http://www.youtube.com/watch?v=2qB4RNoXTd8 . Its very simple just install software downoladed from http://www.samfirmware.com/WEBPROTECT-i9001.htm our software is in the middle I9001XXKF8 ##. Odin as well recognize my phone.
I have managed it to root the i9001. So far it is very complicated, and the detailed guide as well as the analysis of SMD archives is only in German available:
http://www.android-hilfe.de/samsung...g-galaxy-s-plus-i9001-rooten.html#post1911955
As always: You are responsible for your Phone! If someone bricks his device using this guide, I am not responsible for that! Bad Luck, I have warned you! Its a dangerous job! You really shouldn't do it.
In short:
- extract the PDA SMD File
- mount system.ext4
- copy su binary and Superuser.apk into the mounted image
- adjust the file permissions (especially the suid bit for su)
- umount system.ext4
- repack the PDA SMD.
I have created two Linux bash scripts for extracting and packing SMD Archives. Warning: I'm not very experienced in bash scripting. If someone is here who is capable of making a nice script of it, feel free! The scripts are working, that's all so far. They won't win a price in a beauty contest.
First the extract.sh:
Code:
#!/bin/bash
base=0
length=1
while (( length > 0 ))
do
# calculate Length
let "skip = base + 18"
length=`hexdump -e '"%d"' -s ${skip} -n 2 ${1}`
let "length = length * 65536"
let "skip = base + 16"
length2=`hexdump -e '"%d"' -s ${skip} -n 2 ${1}`
let "length += length2"
let "length = length / 512" # Number of 512-Byte blocks
# calculate offset
let "skip = base + 22"
offset=`hexdump -e '"%d"' -s ${skip} -n 2 ${1}`
let "offset = offset * 65536"
let "skip = base + 20"
offset2=`hexdump -e '"%d"' -s ${skip} -n 2 ${1}`
let "offset += offset2"
let "offset = offset / 512" # Number of 512-Byte blocks
# save header in case of first loop
if (( base == 0 ))
then
dd if=${1} bs=512 of=header count=${offset}
fi
# extract filename
let "skip = base + 32"
filename=`dd if=${1} skip=${skip} count=16 bs=1 2>/dev/null`
# and finally: extract image
if (( length > 0 ))
then
echo "Length: ${length}"
echo "Offset: ${offset}"
echo "Filename: ${filename}"
dd if=${1} bs=512 of=${filename} skip=${offset} count=${length} 2>/dev/null
fi
# next header
let "base += 64"
done
Syntax: ./extract.sh Archive.smd
The script will extract the archive and create a lot of local files (system.ext, boot.img and so on). Well, the content of the Archive obviously.
Root the system.ext4:
I have used the newest su and Superuser.apk from here (3.0-beta4 at the moment. Newer ones should be ok):
http://goo-inside.me/superuser
The steps for rooting a system.ext4:
Code:
mkdir system
sudo mount -o loop system.ext4 system
sudo cp su system/xbin/
sudo chown 0.0 system/xbin/su
sudo chmod 4755 system/xbin/su
sudo cp Superuser.apk system/app/
sudo chown 0.0 system/app/Superuser.apk
sudo chmod 644 system/app/Superuser.apk
sudo umount system
And the pack.sh. Note: The pack.sh so far expects an existing "header" file created from an extract action and all files to be added into the archive. The resulting archive will have the same contents, as the starting archive (of course with a modified system.ext4). MD5 Checksums in the archive are calculated automatically.
Code:
#!/bin/bash
base=16
length=0
filename=dummy
# save the beginning
dd if=header of=newheader bs=1 count=16 2>/dev/null
# First create the MD5 checksums of all included (and maybe modified) files and generate the new header
while [ ! -z "${filename}" ]
do
# Length, offset, etc. is unchanged, just copy it.
let "skip = base"
dd if=header of=newheadertmp bs=1 skip=${skip} count=32 2>/dev/null
cat newheadertmp >> newheader
rm newheadertmp
# extract filename
let "skip = base + 16"
filename=`dd if=header skip=${skip} count=16 bs=1 2>/dev/null`
if [ ! -z "${filename}" ]
then
echo "creating MD5Sum of: ${filename}"
checksum=`md5sum ${filename} | tr '[a-z]' '[A-Z]'`
echo -n ${checksum:0:32} >> newheader
fi
# next header
let "base += 64"
done
# save the rest of the old header.
filesize=$(stat -c%s header)
let "base -= 32"
let "size = filesize - base"
dd if=header of=newheadertmp bs=1 skip=${base} count=${size} 2>/dev/null
cat newheadertmp >> newheader
rm newheadertmp
# the new header is the first content of the new archive.
cat newheader > ${1}
# now add all files to the archive.
filename=dummy
base=16
while [ ! -z "${filename}" ]
do
# extract filename
let "skip = base + 16"
filename=`dd if=header skip=${skip} count=16 bs=1 2>/dev/null`
if [ ! -z "${filename}" ]
then
echo "Adding: ${filename}"
cat ${filename} >> ${1}
fi
# next header
let "base += 64"
done
rm newheader
Syntax: ./pack.sh Archive.smd
Flash the resulting .smd files using Odin Multi Downloader an be happy about a rooted SGS Plus.
Note: The procedure has been tested with European KF6 and KP4 firmware. the scripts are capable of extracting and packing other SMD Archives as well, like Modem or CSC SMDs. But you don't need it for rooting (but maybe for debranding or customizing ROMs).
I'm thinking about an simpler root method like a modified kernel with a "magic" initramfs (like CF Root is working). This would make rooting of course much easier. But I have to investigate a lot of things handling boot.imgs.
Nice one RiverSource! Let's hope this is the start of more to come (ie. easier root, custom roms..).
Hello,
ok, next step for rooting the SGS Plus: The FMROOT (hehe). FMROOT is the original untouched Samsung Kernel with a modified init.rc. The init.rc calls a script which places the su binary and the Superuser.apk into the /system partition.
As always: You are responsible for your Phone! If someone bricks his device using this guide, I am not responsible for that! Bad Luck, I have warned you! Its a dangerous job! You really shouldn't do it.
Howto:
Download the appropriate file for your firmware.
Extract it
There should be 2 Files: AriesVE.ops and FMROOT_?????.smd
Use Odin Multi Downloader
Put "AriesVE.ops" in OPS
Put "FMROOT_?????.smd" in PDA
Flash. Wait 5 Seconds. Phone reboots. Phone is rooted. Normally without loosing data or settings.
Please ask here, if your Firmware is not available. It should be possible to create an appropriate FMROOT Kernel.
Credits:
astuermer for pointing me to the correct su and Superuser binaries.
Chainfire here from XDA Developers. My script is based on the CF-Root
Paul from Madaco. I had a closer look into his "superboot".
Lots and Lots of Custom ROM Developers for i9000 and i9100. I have learned a lot about Android Images on Samsung phones from them.
For the developers: the FMBOOT Script called by init.rc:
Code:
mount -o rw,remount -t ext4 /dev/block/mmcblk0p15 /system
rm /system/xbin/su
rm /system/bin/su
mkdir /system/xbin
cat /fmboot/su > /system/xbin/su
chmod 4755 /system/xbin/su
cat /fmboot/Superuser.apk > /system/app/Superuser.apk
mount -o ro,remount -t ext4 /dev/block/mmcblk0p15 /system
And the calling code inside the init.rc:
Code:
start fmboot
class_start default
## Daemon processes to be run by init.
##
service fmboot /system/bin/sh /fmboot/fmboot.sh
user root
group root
oneshot
If someone is interested, I can post a howto on modifying boot.imgs for SGS Plus. Don't hesitate to ask. BTW, i have also coded a script which is capable of generating SMD archives with any content (not based on a previous SMD archive). I can also post it, if someone is interested.
I think, I will optimize the script in the future. Checking if the phone is already rooted and skip the thing for example. Or adding busybox. Are there any additional ideas?
Thank you very [email protected]@@@ Come on!
THX, THX,..
It works, rooted..!!

[Q] adb works but not extract-files.sh

I am trying to extract vendor files from an i8730 phone using extract-files.sh
I have Linux Mint 14 with android-tools-adb installed as the adb
adb works fine to a point
[email protected] ~ $ adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
333398202BDF00EC device
adb shell and ls shows files on the phone including the vendor folder
If I run ls from my working directly I can see extract-files.sh
Think the solution is in .bashrc but believe I am not doing it right. When I run extract-files.sh I get this
[email protected] ~ $ ./extract-files.sh
bash: ./extract-files.sh: Permission denied
[email protected] ~ $ sudo extract-files.sh
[sudo] password for megan:
sudo: extract-files.sh: command not found
[email protected] ~ $ sudo./extract-files.sh
bash: sudo./extract-files.sh: No such file or directory
location adb shows
/usr/share/doc/android-tools-adb
location bashrc shows
/etc/bash.bashrc
I have edit bashrc
[email protected] ~ $ sudo gedit /etc/bash.bashrc
[sudo] password for megan:
Have added this to the end
export PATH=${PATH}:/home/megan/usr/share/doc/android-tools-adb
Think this is where I have gone wrong. Any suggestions?
Thanks
Bazzan
http://forum.xda-developers.com/showpost.php?p=7146410&postcount=5
unable to create 99-android.rules
MoonBlade said:
http://forum.xda-developers.com/showpost.php?p=7146410&postcount=5
Click to expand...
Click to collapse
Thanks MoonBlade. Think you are suggesting the version on the link so have been working through it. Had to source the files elsewhere as original link is dead. May or may not be a problem.
Got as far as creating the file in /etc/udev/rules.d/ but am unable to create a file in that folder. I am logged in as root. I can view the folder through GUI but not able to create 99-android.rules
Get this mess in terminal
[email protected] ~ $ su
Password:
megan-901 megan # cd /etc/udev/rules.d/
megan-901 rules.d # ls
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 21, in <module>
os.execvp("python3", [sys.argv[0]] + sys.argv)
File "/usr/lib/python2.7/os.py", line 344, in execvp
_execvpe(file, args)
File "/usr/lib/python2.7/os.py", line 380, in _execvpe
func(fullname, *argrest)
OSError: [Errno 2] No such file or directory
megan-901 rules.d #
Not sure the above is anything to do with not being able to write to that folder. Any ideas?
Bazzan
ok im not sure exactly what youre trying to do but it sounds like you want to get files from your phones /vendor/ directory and copy them to a directory on your computer. if this is correct then you need to stop playiing around with your .bashrc and your $PATH appends. all you need to use is adb
you dont have to adb shell. once you run adb shell it opens up a terminal inside your device so if youre trying to run a shell script on your computer from inside an adb shell it just wont work.
a simpler way to put this is, if you want to get /vendor/firmware/bcm4329.bin from your phone and put it on your computer in a folder on your desktop you would run it like this
$adb pull /vendor/firmware/bcm4329.bin /home/megan/Desktop/phonevendorfirmware/bcm439.bin
and the directory and file will automatically be created on your computer. from there you can do what ever you wanted to do to the files that you pulled from the phone.
the same works in reverse if you want to move a file to the phone using $adb push
bazzan said:
[email protected] ~ $ ./extract-files.sh
bash: ./extract-files.sh: Permission denied
Click to expand...
Click to collapse
You need to give execution permissions to the script, this way:
Code:
chmod +x extract-files.sh
And then, run your script like this (if the script doesn't need root permissions, run it without sudo):
Code:
sudo ./extract-files.sh
Many thanks haxin and RoberGalarga
I was given the extract-files.sh by a developer to extract vendor files for ROM development - i8730. He did not have the phone (I don't at the moment as has been wrapped for the kids to give to me for my birthday - practicing on an a Galaxy S)
From peeking inside the file it looks like a batch file that grabs all the content from the vendor folder. Did SQL 10 years ago and looks like that. Essentially does what you gave me haxim, but pulls the content of the entire folder. What is the best way to do that with adb pull?
Gave chmod +x extract-files.sh a try.
Without sudo I get
bash:./extract-files.sh : /bin/sh^M: bad interpreter: No such file or directory
With sudo
sudo: unable to execute ./extract-files.sh: No such file or directory.
Remember I am running this against a i9000, not the phone that I was given the sh file to run against. Get that back the begining of September. Not sure if that makes a difference but if it does not obvious to me.Seems to be falling over on the first line as that appears in the non sudo error message.
Have copied the content of extract-files.sh below.
Thanks again guys. Learning heaps and loving it.
Bazzan
#!/bin/sh
set -e
export DEVICE=express
export VENDOR=samsung
if [ $# -eq 0 ]; then
SRC=adb
else
if [ $# -eq 1 ]; then
SRC=$1
else
echo "$0: bad number of arguments"
echo ""
echo "usage: $0 [PATH_TO_EXPANDED_ROM]"
echo ""
echo "If PATH_TO_EXPANDED_ROM is not specified, blobs will be extracted from"
echo "the device using adb pull."
exit 1
fi
fi
BASE=../../../vendor/$VENDOR/$DEVICE/proprietary
rm -rf $BASE/*
for FILE in `egrep -v '(^#|^$)' ../$DEVICE/proprietary-files.txt`; do
echo "Extracting /system/$FILE ..."
DIR=`dirname $FILE`
if [ ! -d $BASE/$DIR ]; then
mkdir -p $BASE/$DIR
fi
if [ "$SRC" = "adb" ]; then
adb pull /system/$FILE $BASE/$FILE
else
cp $SRC/system/$FILE $BASE/$FILE
fi
done
./setup-makefiles.sh
Where did you get the script? This error:
bazzan said:
bash:./extract-files.sh : /bin/sh^M: bad interpreter: No such file or directory
Click to expand...
Click to collapse
is caused by a bad formatting in the file (Window$ editing... pfff....), so, make a new file using Gedit and paste this directly (don't copy&paste from the original script!!):
bazzan said:
#!/bin/sh
set -e
export DEVICE=express
export VENDOR=samsung
if [ $# -eq 0 ]; then
SRC=adb
else
if [ $# -eq 1 ]; then
SRC=$1
else
echo "$0: bad number of arguments"
echo ""
echo "usage: $0 [PATH_TO_EXPANDED_ROM]"
echo ""
echo "If PATH_TO_EXPANDED_ROM is not specified, blobs will be extracted from"
echo "the device using adb pull."
exit 1
fi
fi
BASE=../../../vendor/$VENDOR/$DEVICE/proprietary
rm -rf $BASE/*
for FILE in `egrep -v '(^#|^$)' ../$DEVICE/proprietary-files.txt`; do
echo "Extracting /system/$FILE ..."
DIR=`dirname $FILE`
if [ ! -d $BASE/$DIR ]; then
mkdir -p $BASE/$DIR
fi
if [ "$SRC" = "adb" ]; then
adb pull /system/$FILE $BASE/$FILE
else
cp $SRC/system/$FILE $BASE/$FILE
fi
done
Click to expand...
Click to collapse
Delete the old file, and try the new one (you can use any filename, it doesn't matter).
Many thanks RoberGalarga.
Got the script off a recognised developer along with proprietary-files.txt and setup-makefiles.sh
He is working a CWM and a rom for owners of the i8730 - he does not have the phone so community feed in content. Get the impression he is not a Windows user (he did not have a Windows script for this) so reckon I might have corrupted it.
I did as you advised and made some real progress. Now we get the following:
[email protected] ~ $ sudo ./extract-files.sh
[sudo] password for megan:
egrep: ../express/proprietary-files.txt: No such file or directory
: not foundefiles.sh: 3: ./setup-makefiles.sh:
: Directory nonexistentk ./setup-makefiles.sh: cannot create ../../../vendor/samsung/express
[email protected] ~ $
It breaks further down the script. In the home folder there is proprietary-files.txt which list the files to be extracted along with their file path. Does that message indicate it is looking for proprietary-files.txt in /home/express?
Setup-makefiles.sh is in the home folder as well and appears to be a Cyanogenmod Project file to create a blob from the the results of extract-files.sh
Bazzan
bazzan said:
Does that message indicate it is looking for proprietary-files.txt in /home/express?
Click to expand...
Click to collapse
Yes, that's it. Check again, seems like something is missing yet.
Thanks again. Got it to work by building the folder structure
/home/vendor/Samsung/express
And then running the files from there
Bazzan

Tolino e-Reader with broken android

Hey Guys,
i got a broken Tolino Vision 3 HD from a friend to fix the issues with the android. It´s a popular ebook reader in Germany.
At the moment I got the device it stuck in language selection and the partition for the ebooks wasn´t shown after USB connection.
So I downloaded the new software version from the vendor "mytolino" (I am not allowed to post urls). I tried to update via
fastboot update
Click to expand...
Click to collapse
but i got this error:
archive does not contain 'android-info.txt'
error: update package '..\update.zip' has no android-info.txt
Click to expand...
Click to collapse
. So I unpack the .zip and try to flash the images manualy. This didn´t work. After this is tried to copy the update.zip to /sdcard via adb push but this didn´t work, too.
Question:
Is there any way to flash the device with the given update.zip?
Regards and all good wishes from sunny Germany
Did you tried to do factory reset? Are you able to boot into recovery using key-combination?
The more heavy way I used yesterday to reanimate my Tolino page after trying to install OpenGapps on them (no, did not work oO).
I am not allowed to post URL's because of "Noob-Protection" in Forum. There is a "Tolino Vision 2 rooten" howto in web. Some parts of them you can use to solve your problem.
1. Create own ADB-Enabled custom recovery (Did worked for me only with 10.0.1 update package). Should be done on Linux
Code:
$ mkdir custom_recovery
$ cd custom_recovery
$ unzip ../update.zip recovery.img
$ mv recovery.img recovery.img.orig
$ abootimg -x recovery.img.orig
$ mv initrd.img initrd.img.orig
$ mkdir initrd
$ cd initrd
$ zcat ../initrd.img.orig | cpio -vid
Adjust default.prop with values "ro.secure=0", "ro.debuggable=1" und "persist.sys.usb.config=mass_storage,adb".
Code:
$ find . | cpio --create --format='newc' | gzip > ../initrd_adb_enabled.img
$ cd ..
$ abootimg --create recovery_adb_enabled.img -f bootimg.cfg -k zImage -r initrd_adb_enabled.img
You get error : "updated is too big for the Boot Image" with new size value. Calculate this value to hexadecimal and adjust the "bootsize" in "bootimg.cfg" to hex-value
Do abootimg again.
2. Use the custom recovery to trigger update manually
Code:
$ fastboot boot ../custom_recovery/recovery_adb_enabled.img
$ adb shell
# mount -t vfat /dev/block/mmcblk0p4 /sdcard/
# exit
$ adb push update.zip /sdcard/update.zip
$adb shell
# cd /sdcard
# busybox unzip update.zip META-INF/com/google/android/update-binary -d /tmp
# busybox chmod u+x /tmp/META-INF/com/google/android/update-binary
# /tmp/META-INF/com/google/android/update-binary 3 1 /sdcard/update.zip # Update installieren
# sync && sleep 5 && sync # sicherheitshalber, wenn man dran glaubt
# reboot
Source: google for "e-reader-forum Toolino vision 2 rooten"

Guide: Fix WhatsApp Images mess after restoring backup

Hey there
Thought this might help some of you finding yourself in a huge mess because WhatApp restores all its media with the date the restore takes place. I wrote a little shellscript you can run in "adb shell". Just paste it into the shell and run it inside WhatsApps Folders.
In "WhatsApp Images" and it's subfolder "Sent" use this:
Code:
for file in *; do
if [ -f "$file" ]; then
timestamp=$(echo "$file" | sed 's/^IMG-\(.*\)-WA\(...\)\(.\)\..*/\10\2\.0\3/g')
echo $timestamp
echo $file
touch -m -t $timestamp $file
fi
done
For "WhatsApp Animated Gifs" and "WhatsApp Video" use this:
Code:
for file in *; do
if [ -f "$file" ]; then
timestamp=$(echo "$file" | sed 's/^VID-\(.*\)-WA\(...\)\(.\)\..*/\10\2\.0\3/g')
echo $timestamp
echo $file
touch -m -t $timestamp $file
fi
done
Keep the following in mind:
- This code works only if your version of Android allows you to change the modified date of files without root. As far as I know this is the case since Andoid 9
- This code doesn't work if you have files with a WA-Number higher than 0599 as my script doesn't take care to match the number with a proper timeformat.
- This code changes the last modified date of your files like this:
Filename: IMG-20190915-WA0039.jpg
Timestamp: 201909150003.09 -> 20190915 00:03:09
Feedbacks and comments welcome
Greets Air

Categories

Resources