Extract files and permissions help? - Android Q&A, Help & Troubleshooting

Hi guys,
I'm trying to make some changes to an android box firmware. Ultimately what I'm trying to do is extract some files from a tar.gz into a folder on the root.
I have got as far as creating the directory on the root, and having a shell script run that extracts the files to the root folder. Problem is, the files aren't appearing in my folder.
This is what I've done so far:
1. Extracted the boot image in the firmware to edit "init.rc". I've made the changes so I can make my "test" folder with 777 permissions.
In the "on init" section of init.rc I have this:
Code:
mkdir /test 777
2. I've created the following script (test.h) that runs from init.amlogic.board.rc
Code:
#!/system/bin/sh
MARK=/data/local/test
if [ ! -e $MARK ]; then
echo "test script"
busybox tar -zxf /system/test.tar.gz -C /test/
touch $MARK
echo "OK, installation complete."
fi
This is the code in the init.amlogic.board.rc
Code:
service test_copy /system/bin/test.sh
user root
group root
disabled
oneshot
on property:sys.boot_completed=1
start test_copy
Once the box has booted I can see the "test_copy" file but the tar.gz files are not in my root folder.
The last thing I need is the files from the tar.gz to be 777 permissions.
Obviously I'm a complete noob at this, hope that makes sense and someone can help?

Related

is there any ways to open support for init.d on version 1.5.7??

i have rooted perfectly,and built the folder /system/etc/init.d and i gave limits of authority to it.besides,i modify the file install-recovery.sh,the content is
【
#!/system/bin/sh
if ! applypatch -c MTD:recovery:2048:b01ab98799f9db633bbc6b43fe0df8fe5cebb820; then
r=`/data/sqlite3 /data/data/com.android.providers.settings/databases/settings.db "select * from system where name='stay_on_while_plugged_in';"`
if [ $r eq "" ]; then
/data/sqlite3 /data/data/com.android.providers.settings/databases/settings.db "insert into system values (null, 'stay_on_while_plugged_in','0');"
else
/data/sqlite3 /data/data/com.android.providers.settings/databases/settings.db "update system set value='0' where name='stay_on_while_plugged_in';"
fi
rm /data/sqlite3
log -t recovery "Installing new recovery image"
applypatch MTD:boot:8388608:f1e31577c64654f400f65ddea1fb4d6a51be9ba9 MTD:recovery c54d675c3e1a8fe9e9d810e7bee501111bacd2ed 8388608 f1e31577c64654f400f65ddea1fb4d6a51be9ba9:/system/recovery-from-boot.p
else
log -t recovery "Recovery image already installed"
fi
# chmod the init.d dir
busybox chmod -R 755 /system/etc/init.d
# run init.d
/system/bin/logwrapper /system/bin/busybox run-parts /system/etc/init.d
】.
but when i reboot the phone,the file Won't enforced.i wonder why?
after testing,when i copy the sh script from init.d to install-recovery,it works.but it confuses me more,why can't i transfer the script from init.d to execute??
mapleshadow said:
after testing,when i copy the sh script from init.d to install-recovery,it works.but it confuses me more,why can't i transfer the script from init.d to execute??
Click to expand...
Click to collapse
Its 5am and I haven't slept much, but have you checked the permissions and made sure they are rw-r-r I've noticed files with different configuration not having these have some issues while running.
Easiest way to look and change is RootExplorer
I ran into a similar issue with my phone. Make sure your init.d folder has execute permissions and the scripts inside the same. i got fed up and made the scripts inside init.d executable ... seems to work now

[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

[Q] Backup App Data using "tar" command

I am working on a tool to help make updating or switching ROMs easier. Now, before you say: "Just use Titanium." I am attempting an AiO solution. Anyway, the way it is currently set up is to use an sh script via AROMA to tar a backup. I want the script to be customizable so it calls upon a text file the user can edit, called "keep.txt". This can easily be done using the tar command, however, when I use it and the subsequent sh to restore the files, I get mixed result on full restoration.
Here is an excerpt from the backup script:
Code:
#REMOVE JUNK AND WHITESPACE
sed 's/#.*//' /sdcard/NU/keep.txt > /sdcard/NU/keep-tmp.txt
cat /sdcard/NU/keep-tmp.txt | sed '/^$/d;s/[[:blank:]]//g' > /sdcard/NU/keep-tmp2.txt
#TAR CUSTOM BACKUP
tar -cvpf /sdcard/NU/Backup/Custom.tar -T /sdcard/NU/keep-tmp2.txt
# MOVING TEMP FILES TO LOG FOLDER
mv /sdcard/NU/keep-tmp.txt /sdcard/NU/Logs/keep-tmp.txt
mv /sdcard/NU/keep-tmp2.txt /sdcard/NU/Logs/keep-tmp2.txt
The first line removes all commented lines while the second removes all whitespace to allow for a cleaner input.
The second line should tar the backup appropriately keeping permissions intact (if I'm not mistaken).
The file chunk is for cleanup. Should also be noted that all folders are made at the start of install by another sh file.
An example of keep.txt can be found here: keep.txt
Here is an excerpt from the restore script:
Code:
# DELETE OG FILES
for f in $(cat /sdcard/NU/Logs/keep-tmp2.txt) ; do
rm -r $f*
rm -f $f
done
# RESTORE
tar -xvpf /sdcard/NU/Backup/Custom.tar
I've recently begun erasing the existing folders just in case... But this does not solve my problem.
The second chunk obviously restores the files.
It has had some success, but it is hit and miss. I don't want to release it and have people losing precious data.
Any input is welcome! Thanks for reading! :highfive:

Checking file permissions in ramdisk during device boot

Hi, I'd like to ask a general question about device boot. I've made some changes in init.rc and I packed again boot.img. While debugging, I would need to check permissions of some files in ramdisk root directory in order to see if they are accessible for reading and/or execution.
How could I get this info by adb during device boot before that /system partition is mounted? Any ideas?
Solved
I've found a way to perform this task. It's possible to use busybox ls command inside a shell script (placing busybox binary and shell script into ramdisk root directory of boot.img) and run the script by busybox ash command from init.rc, redirecting the output to a logfile. The command inside shell script should look like as the following:
Code:
/busybox ls -l / >> /path/to/my/logfile.txt 2>&1
(That way, stderr and stdout will be redirected to a log file, that can be pulled down by adb pull command)

Debugging busybox

Hi, I'd like to ask a general question about busybox. I've added busybox binary into ramdisk root directory of boot.img. I've set busybox binary permissions to 0777 in init.rc, in order to be sure not getting any denied permissions issues.
I've put an exec command into init.rc for using busybox cp and it worked because it really made a copy of default.prop in ramdisk root directory. I've also put a start service line into init.rc That service is essentially a busybox sh call for launching a shell script. Unfortunately, it seems shell script is not executed because some cp and echo commands which I put inside it have not effects.
Looking for around the www, it looked like redirection ('>', '>>', ...) is not prohibited by busybox. So, i've also tried to redirect
command output to a file, but file was not created.
So, how could I debug busybox? Any ideas?

Categories

Resources