SH Script help? - C++ or Other Android Development Languages

Hello guys, ok I do not know anything when it comes to shell script but last night i came up with an idea of creating a script to backup a rom boot animation and replace it with a new one. Ive probably completly f****d this up as i do not know anything:laugh:
Code:
#mount android root
/tmp/busybox mount /
#make folder called boot on sdcard
/tmp/busybox mkdir /sdcard/boot
#copy old bootanimation.zip to boot folder on sdcard and call it bootanimation.bak
/tmp/busybox cp /system/media/bootanimation.zip /sdcard/boot/bootanimation.bak
#delete bootanimation.zip from rom
/tmp/busybox rm -f /system/media/bootanimation.zip
#copy bootanimation.zip from sd card to rom
/tmp/busybox cp /sdcard/animations/bootanimation.zip /system/media/bootanimation.zip
#unmount andriod root
/tmp/busybox umount -l /
exit 0
could someone please tell me if there is any smidge of a chance that this will actually do something please? Thanks

Related

[Q] Move data/dalvik-cache to dev/dalvik-cache

Hi, I want to freeing up some space in my /data partition so I can install more apps...
I manage to get 60mb more space by doing this: forum.xda-developers.com/showthread.php?p=7459981
Then I also thought to move /data/dalvik-cache since it's very big... In other forum, people move /data/dalvik-cache to SD card or /cache...
Moving dalvik-cache to SD card is a little unstable while /cache partition in X10 mini only have 50mb free space... (my data/dalvik-cache had 65mb size)
Besides that, /cache is used by FOTA, browser and market apps to download a files...
Then I look another partition, and I see that /dev partition has 86mb free space! If I do this, I can install 65mb more application to my phone...
Then after searching, I found this script. It must be executed at boot:
Code:
#!/system/bin/sh
echo "++++ DALVIK 2 DEV STARTING ++++"
if [ ! -d /dev/dalvik-cache ]
then
mkdir /dev/dalvik-cache
chown 1000:1000 /dev/dalvik-cache
chmod 775 /dev/dalvik-cache
fi
if [ -L /data/dalvik-cache ]
then
rm -f /data/dalvik-cache
mkdir /data/dalvik-cache
chown 1000:1000 /data/dalvik-cache
chmod 775 /data/dalvik-cache
elif [ ! -d /data/dalvik-cache ]
then
mkdir /data/dalvik-cache
chown 1000:1000 /data/dalvik-cache
chmod 775 /data/dalvik-cache
elif [ -d /data/dalvik-cache ]
then
for filename in /data/dalvik-cache/*
do
if [ -L $filename ]
then
rm -f $filename
fi
done
mv /data/dalvik-cache/* /dev/dalvik-cache/
fi
mount -o bind /dev/dalvik-cache/ /data/dalvik-cache/
The question is, how to execute this script during boot up? Another peoples do it this way in their phones:
Hacre said:
paste the text into a file called 02dalvik2cache (no file extension)
adb remount
adb push 02dalvik2cache /system/etc/init.d/
adb shell chown root:2000 /system/etc/init.d/02dalvik2cache
adb shell chmod 755 /system/etc/init.d/02dalvik2cache
Reboot phone.
Click to expand...
Click to collapse
But it seems that the file structure is different. Also, adb remount command gives "not permitted" errors because ro.secure is 1 in /default.prop
If I change ro.secure=1 to re.secure=0 in /default.prop then reboots, it comes back to ro.secure=1
Any thoughts?

X8 Custom ROM

Because propoff2 got himself banned, I've decided to re-create his threads for you, hopefully with easier to follow instructions than before.
X8 Android 2.1-rus
X8 Android 1.6
Modified Image (x8.img)
Data.img
Busybox, Rootshell, Chargemon
(If for whatever reason any of the above links don't work, scroll down and see propc's post.)
Before moving on, decide whether you want to boot the rom from the sdcard or from the internal memory, then use the correct instructions to do so.
If you've tried this method and REALLY don't like the customized rom, then see this thread for how to install a clean, pre-rooted rom!
==BOOTING CUSTOM ROM FROM SD==
Before you begin, put chargemon, busybox, rootshell, x8.img and data.img onto the sdcard.
1. Flash 1.6 firmware to the phone.
2. Root the phone.
3. Copy the files rootshell, chargemon and busybox to /system/bin
(You can do this by putting the files on the sdcard, and using a file manager such as root explorer to copy the files into /system/bin. Command line instructions will be here soonish. This guide is still a WIP).
4. Chmod the files.
Code:
chmod 4755 /system/bin/rootshell
chmod 755 /system/bin/busybox
chmod 777 /system/bin/chargemon
5. Copy both x8.img (/system) and data.img (/data) to the sdcard.
6. Flash 2.1 kernel using this flashing utility. (The GUI version is perfectly fine to use.)
Remember to remove system.sin and userdata.sin from the flash files!
7. Reboot and hope it works.
==BOOT CUSTOM ROM FROM INTERNAL MEMORY==
Before you being, copy x8.img and busybox on to the sdcard.
1. Follow steps 1-2 from the instructions above.
2. Copy busybox to /data/local/tmp
Code:
cd /data/local/tmp
cat /sdcard/busybox > /data/local/tmp/busybox
3. Chmod busybox.
Code:
chmod 755 busybox
4. Using busybox, remount /system as rewriteable.
Code:
./busybox mount -o remount,rw /system
./busybox sh
5. Mount x8.img.
Code:
./busybox mkdir /data/local/tmp/1
./busybox losetup /dev/block/loop1 /sdcard/x8.img
./busybox mount -t ext2 -o rw,noatime,nodiratime /dev/block/loop1 /data/local/tmp/1
6. Remove the contents of /system. ADVICE: Remove the folders one by one, leave /system/bin and /system/app last! That way your phone is less likely to crash whilst doing this step. DO NOT TRY AND USE YOUR PHONE WHILE DOING THIS, YOUR PHONE IS CERTAIN TO CRASH! Make sure the phone is locked.
Code:
./busybox rm -rf /system/media
./busybox rm -rf /system/usr
./busybox rm -rf /system/etc
./busybox rm -rf /system/lib
./busybox rm -rf /system/xbin
./busybox rm -rf /system/framework
./busybox rm -rf /system/fonts
./busybox rm -rf /system/drm
./busybox rm -rf /system/build.prop
./busybox rm -rf /system/app
./busybox rm -rf /system/bin
7. Now copy the files into the phone's internal memory. Again, we have to copy these over one by one, as the phone WILL run out of memory during this process! Most important files go first.
Code:
./busybox cp -prfR /data/local/tmp/1/bin /system/
./busybox cp -prfR /data/local/tmp/1/xbin /system/
./busybox cp -prfR /data/local/tmp/1/etc /system/
./busybox cp -prfR /data/local/tmp/1/usr /system/
./busybox cp -prf /data/local/tmp/1/build.prop /system/
./busybox cp -prfR /data/local/tmp/1/lib /system/
./busybox cp -prfR /data/local/tmp/1/framework /system/
./busybox cp -prfR /data/local/tmp/1/fonts /system/
./busybox cp -prfR /data/local/tmp/1/drm /system/
./busybox cp -prfR /data/local/tmp/1/media /system/
./busybox cp -prfR /data/local/tmp/1/app /system/
Hopefully you won't run out of space until you try and copy /app over. No worries! Your phone will still start, and you can easily restore those files after.
8. Flash the 2.1 kernel, and userdata.
Unlike in the previous instructions, you only want to remove system.sin from the flash files! Put userdata.sin back if you've removed it!
9. Turn on your phone and just hope you didn't mess up!
==APPS ON SD==
See this thread: App2SD Mod (Moves dalvik cache to SD) Instructions
ARGH!! MY PHONE IS STUCK IN A ETERNAL REBOOT? WHAT DO I DO?!
Well, if you know for sure what you did, and don't fancy reflashing all over again, then just plug in your phone and use adb to shell into the phone. Quickly fix the problem before the phone reboots!
Just putting this out there: These instructions were roughly written up. If you're having issues, don't be afraid to ask! If you spot any mistakes, please let me know! I'll expand on these instructions later.
All credits go to pulpoff2, for figuring out this solution, and propc for re-uploading the files, discovering steps 6 and 7 in the internal memory instructions, and for helping me fix these instructions multiple times.
Thank you! I will try this as soon as the files are available.
Are there any downsides? Is everything working as before? What about the speed (when loading apps for example)?
Yes, there are a few downsides. While booting from the sdcard, you cannot mount the sdcard via the phone (you'll need to use a card reader, or push/pull files with adb). There may be some performance issues while booting from the sdcard aswell. The camera and the music player also don't work.
However, if you decided to put the rom into the phone's internal memory, all this is fixed! Absolutely no downsides. Unless you don't like the theme, then I guess that is a downside.
thanks for making a new thread, thread pulpoff2 was hacked by ****-arsehole people! maybe.
I don't think so. The site that he used to host the files has been redirected to an anti-muslim site, by the looks of it.
aktw
Thanks man! Really appreciate it! Now I just need your tut for internal memory. Thanks again!
ML
Edit: Can you add app2sd tutorial?
Much more concise internal flashing (for anyone who wants it)
Code:
adb shell
su
cd /data/local/tmp
cat /sdcard/ext/bin/busybox > /data/local/tmp/busybox
chmod 755 busybox
./busybox mount -o remount,rw /system
./busybox sh
/data/local/tmp/busybox mkdir /data/local/tmp/1
/data/local/tmp/busybox losetup /dev/block/loop1 /sdcard/x8.img
/data/local/tmp/busybox mount -t ext2 -o rw,noatime,nodiratime /dev/block/loop1 /data/local/tmp/1
/data/local/tmp/busybox rm -r /system
/data/local/tmp/busybox cp -prf /data/local/tmp/1/* /system
There, the internal memory instructions are up.
EDIT
ALL FILES NEEDED FOR ABOVE METHOD STATED BY a-k-t-w
Mediafire folder
http://www.mediafire.com/?2kk19r7u4x1w3\
duckload:
data.img
X8.img
X8 2.1 russian
Hotfile:
data.img
X8.img
X8 2.1 russian
ext.rar at the attachment
for external rom (if you use adb shell)
Code:
su [B]look at phone screen and press "allow"[/B]
cd /data/local/tmp
cat /sdcard/ext/bin/busybox > /data/local/tmp/busybox
chmod 755 busybox
./busybox mount -o remount,rw /system
./busybox cp -r /sdcard/ext/* /system/
chmod 755 /system/bin/busybox
chmod 777 /system/bin/chargemon
chmod 755 /system/bin/e2fsck
chmod 4755 /system/bin/rootshell
to mount x8.img
Code:
mkdir /data/local/tmp/1
cat /sdcard/ext/bin/busybox > /data/local/tmp/busybox
/data/local/tmp/busybox losetup /dev/block/loop1 /sdcard/x8.img
/data/local/tmp/busybox mount -t ext2 -o rw,noatime,nodiratime /dev/block/loop1
EDIT : a-k-t-w completed the instruction himself. LOL..i think i'll be here for support..
-there you go.
ext.rar and unyaffs uploaded
i'll help by uploading the firmware files on mediafire.
actually I need the firmware 2.1 unmodified, but I'm okay to waiting.
Thx before.
That can be done. You mean unmodified, but rooted, right?
propc said:
...
i'll help by uploading the files on mediafire.
Click to expand...
Click to collapse
Thank you very much!! You have the latest ROM right? I'll add these to the OP when you are done.
a-k-t-w said:
[highlight]Mod Edit: Sorry, but I had to remove the link to the former dev's site due to the nature of that link[/highlight]
Click to expand...
Click to collapse
Understood.
Edit: @propc, What is unyaffs used for?
will the custom ROM have Timescape???? Or it will be the non-customized Android version.....
sry if this is a stupid question....
and i am just a beginner, so want a ask, what to you mean by "Flash 2.1 kernel" how to do it.....what are the files?? what is 2.1 kernel file??
i am new here...sry!
a-k-t-w said:
That can be done. You mean unmodified, but rooted, right?
Thank you very much!! You have the latest ROM right? I'll add these to the OP when you are done.
Click to expand...
Click to collapse
I think it's the latest. btw, it's stable no worries
mohakrastogi said:
will the custom ROM have Timescape???? Or it will be the non-customized Android version.....
sry if this is a stupid question....
and i am just a beginner, so want a ask, what to you mean by "Flash 2.1 kernel" how to do it.....what are the files?? what is 2.1 kernel file??
i am new here...sry!
Click to expand...
Click to collapse
Sorrry, I'll edit the OP. What I mean is, flash the 2.1 firmware, but without the files system.sin and userdata.sin (if your doing the sdcard method). This is basically flashing the 2.1 kernel only. Hang in there, the files will be available for download soon.
The custrom rom does not have timescape. You may have to restore ALL apps as there are some missing that will prevent you downloading your providers settings. I'm not sure which it is, so my solution is restoring them all. :-S
propc said:
I think it's the latest. btw, it's stable no worries
Click to expand...
Click to collapse
Excellent! Thanks again for the help.
a-k-t-w said:
Sorrry, I'll edit the OP. What I mean is, flash the 2.1 firmware, but without the files system.sin and userdata.sin (if your doing the sdcard method). This is basically flashing the 2.1 kernel only. Hang in there, the files will be available for download soon.
The custrom rom does not have timescape. You may have to restore ALL apps as there are some missing that will prevent you downloading your providers settings. I'm not sure which it is, so my solution is restoring them all. :-S
Excellent! Thanks again for the help.
Click to expand...
Click to collapse
i'm uploading data.img, x8.img and russian 2.1(.sin files)
any other files that need to be upload?
using unyaffs, you can extract x8.img directly to /system
maybe needed for future
folder for needed files are up (uploading other files .....)
HERE
please help me when write a command i got a problem with copy file
screenshot:
{
"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"
}
this a file problem with copy:
/data/local/tmp/busybox rm -r /system/app/com.mizusoft.relaxandsleep.apk
/data/local/tmp/busybox cp -prf /data/local/tmp/1/bin/* /system/bin/
/data/local/tmp/busybox cp -prf /data/local/tmp/1/drm/* /system/drm/
/data/local/tmp/busybox cp -prf /data/local/tmp/1/fonts/* /system/fonts/
/data/local/tmp/busybox cp -prf /data/local/tmp/1/framework/* /system/framework/
/data/local/tmp/busybox cp -prf /data/local/tmp/1/lib/* /system/lib/
/data/local/tmp/busybox cp -prf /data/local/tmp/1/usr/* /system/usr/
/data/local/tmp/busybox cp -prf /data/local/tmp/1/xbin/* /system/xbin/
/data/local/tmp/busybox cp -prf /data/local/tmp/1/build.prop /system/build.prop
/data/local/tmp/busybox cp -prf /data/local/tmp/1/media/* /system/media/
Click to expand...
Click to collapse
but remove a system -rm -r work for all files. help me pls
What is this custom ROM I keep reading about? What exactly is different there, except for the theme? I would like to see a screenshot of the theme, btw. Is JIT enabled?
Uhh. Probably not. The difference is just the theme, and root on 2.1. Because you can't get root any other way, if I'm not mistaken.
novincobra said:
please help me when write a command i got a problem with copy file
screenshot:
this a file problem with copy:
but remove a system -rm -r work for all files. help me pls
Click to expand...
Click to collapse
My guess is that you didn't mount the x8.img properly?
Or my cp command could be wrong. OH! Don't copy each app one by one, just the folders!
Don't put /* at the end! That means you are copying the contents of the folder! You want the entire folder on /system !
Ok, this means we have to use this customized ROM to gain root. Thanks for clarifying.

[Q] System.img Editing Dev Help

Hi all,
im working on making a ROM for the Asus Transformer and im struggling a bit. im totall new to Linux, using mint and just getting used to it.
Basically im just trying to take a stock ROM and add root but adding superuser.apk and SU binary but im running into problems.
Asus Roms are a bit unusual, packed into blob files, ive unpacked that no problem, the system image is called blob.APP but its just the same as system.img just the name as i understand it.
ok so what ive done:
Code:
mkdir system
sudo mount -t ext4 -o loop blob.APP system/
so this mounts the ext4 fs as a loop device and allows me to copy the contents out
Code:
sudo cp -ar system new_system
then ive copied superuser.apk to /app and SU binary to /dev with drop and drag.
then make the filesystem image
Code:
sudo ./make_ext4fs -l 512m -a system blob.APP new_system/system
then just pack it up and flash it, flashing works fine, no errors but when i go to reboot it warns that theres no OS so somethings not worked. ive tried everything i can find googeling!
i just started learning linux on weds so go easy on me
any advice or help would be really great. thanks!
mkdir system here you will mount the old system
mkdir system_new here you will mount the new system
we now create the actual image
dd if=/dev/zero of=system_new.img bs=4k count=60000
bs=4k is the block size
count=60000 the number of blocks of 4kb size
so is something like 60000*4= 240000 which is actually 240 Mb
so it depends to you how big you want the image.
now we format the system.img in ext4
mkfs.ext4 system_new.img
Proceed anyway? (y,n) y
now we override the filesystem check
tune2fs -c0 -i0 system_new.img
Now we mount the the 2 directories that we created in the first step
mount -o loop system_new.img system_new/
mount -o loop system_new.img system/
Now we copy the contet of the old image to the new one with all the perimissions
cp -v -r -p system/* system_new/
We sinc the files
sync
We unmount the partitions
umount system_new/
umount system/
And voila, the system.img in ext4 is created.
Tips: you will need superuser acces.
if you will copy new files besides the ones from the old system you will have to set by hand all the permissions.
If you are using ubuntu just type
sudo su
and you will be root and no more sudo at each command.
Thank u so much for your guide this is exactly what I'm looking for so massive thanks!
So to add root I.can drop and drag superuser.apk and the binary into the new image?
Also do I need to worry about the android mountpoint?
Sent from my HTC Sensation Z710e using xda premium
yes you can do that, as long as you set the permissions right. (you can google for them)
and from what i remeber you will have to set also the ownership of the su, and superusers files
you need to do tests first, and then try
the mountpoint should be ok as it is now.
globula_neagra said:
mkdir system here you will mount the old system
mkdir system_new here you will mount the new system
we now create the actual image
dd if=/dev/zero of=system_new.img bs=4k count=60000
bs=4k is the block size
count=60000 the number of blocks of 4kb size
so is something like 60000*4= 240000 which is actually 240 Mb
so it depends to you how big you want the image.
now we format the system.img in ext4
mkfs.ext4 system_new.img
Proceed anyway? (y,n) y
now we override the filesystem check
tune2fs -c0 -i0 system_new.img
Now we mount the the 2 directories that we created in the first step
mount -o loop system_new.img system_new/
mount -o loop system_new.img system/
Now we copy the contet of the old image to the new one with all the perimissions
cp -v -r -p system/* system_new/
We sinc the files
sync
We unmount the partitions
umount system_new/
umount system/
And voila, the system.img in ext4 is created.
Tips: you will need superuser acces.
if you will copy new files besides the ones from the old system you will have to set by hand all the permissions.
If you are using ubuntu just type
sudo su
and you will be root and no more sudo at each command.
Click to expand...
Click to collapse
U said, we have to set permissions by ourselves. So what are the permissions that needs to be set when I add a new folder with an APK in it?
Sudo chmod 777 filepath/filename.apk
Sudo chmod a-rwx filepatch/filename.apk.
This is what I remember from top of my head. Google it a bit if it does not work from the first try as I have not used this like in 5 years.
If you allready have root you can you a file manager and just copy the file/folder where you want and set the permissions via thw file manager or using terminal commanda or via adb.
From what remember you can t make a folder in the apk folder as you won t be able to run the apk.

[Q] how to cook room or delete folder ADB?

I have just cooked my rom( update.zip) and successful installation. But when I restart my mobile, I can't find my settings in bootanimation.zip, Build.prop...
I open Root Explorer and find folder ADB. This Folder has: adb.sh, bootanimation.zip, Build.prop… I can delete this folder but when I restart my mobile, I see it again.
I open file: adb.sh. It has content:
mount -o rw,remount -t ext4 /dev/block/mmcblk0p6 /system
mount -o rw,remount -t ext4 /dev/block/mmcblk0p3 /data
mkdir /data/app
cat /adb/gotiengviet3.apk>/data/app/gotiengviet3.apk
chmod 0644 /data/app/gotiengviet3.apk
mkdir /system
cat /adb/build.prop>/system/build.prop
chmod 0644 /system/build.prop
mkdir /system/media
cat /adb/bootanimation.zip>/system/media/bootanimation.zip
chmod 0644 /system/media/bootanimation.zip
mkdir /system/etc/permissions
cat /adb/com.google.android.features.vendor.xml>/system/etc/permissions/com.google.android.features.vendor.xml
chmod 0644 /system/etc/permissions/com.google.android.features.vendor.xml
rm /adb/gotiengviet3.apk
rm /adb/build.prop
rm /adb/bootanimation.zip
rm /adb/com.google.android.features.vendor.xml
how to cook room or delete folder ADB?

[Q] Superboot image for Motorola Moto G

I'm trying to root my german Motorola Moto G using a superboot image. This topic is very new for me so I followed the Instructions of Mikael Q Kuisma using the original boot.img from the stock ROM. In addition I want to have my image to install a superuser App. So I registered a service in the `init.rc` file which just runs the installer shell script. I register the service like this:
Code:
service installsu /system/bin/sh /superuser/install.sh
class main
user root
group root
oneshot
As far as i understood this service is run once as root when all other services of the class main are run. Am I right?
The superuser app I want to install is the one from Koushik Doutta. My install.sh script looks like this:
Code:
#!/system/bin/sh
mount -o remount,rw /system
chattr -i /system/bin/su
chattr -i /system/xbin/su
rm -f /system/bin/su
rm -f /system/xbin/su
rm -f /system/app/Superuser.*
rm -f /system/app/Supersu.*
rm -f /system/app/superuser.*
rm -f /system/app/supersu.*
rm -f /system/app/SuperUser.*
rm -f /system/app/SuperSU.*
cp /superuser/su /system/xbin/su
chown 0:0 /system/xbin/su
chmod 6755 /system/xbin/su
ln -s /system/xbin/su /system/bin/su
cp /superuser/Superuser.apk /system/app
chmod 644 /system/app/Superuser.apk
chattr -i /system/etc/install-recovery.sh
cp /superuser/install-recovery.sh /system/etc/install-recovery.sh
chmod 755 /system/etc/install-recovery.sh
touch /system/etc/.installed_su_daemon
mount -o remount,ro /system
This is basically the update-android script from the archive but without all the conditionals.
"ls -l" inside the superuser folder gives:
Code:
-rw-rw-r-- 1 root root 44 Nov 30 22:18 install-recovery.sh
-rwxr-x--- 1 root root 737 Jan 7 11:29 install.sh
-rwxr-xr-x 1 root root 283084 Nov 30 22:25 reboot
-rwxr-xr-x 1 root root 311872 Nov 30 22:25 su
-rw-rw-r-- 1 root root 2025538 Nov 30 22:25 Superuser.apk
I think this are the correct permissions?!
The image splitting tool of Mikael Q Kuisma warned me that a different version of mkbootimg was used to create the original boot image an suggested which variables I had to change in the source code. I did this and compiled my own version. The unmkbootimg tool also gave me the complete command including parameters to build the new image. I used it without any modifications.
Finally, the problem: It doesn't root my phone.
It seems like the installer script is never run, because I can't find the su binary using "adb shell ls /system/xbin/". Also the phone does not boot directly into Android. It shows me the Motorola logo, turns black, shows the unlock warning, shows boot animation and then Android is loaded. I don't have a reboot command inside the script, so shouldn't it boot straight to Android when I boot with "fastboot boot <new boot.img>"?
Is it possible to get kernel logs without being root?

Categories

Resources