Hi All Dev's,
In all dev forums we generally face various challenges and as such need to ask users a lot of question's if you have done this or not etc.
I am thinking of creating a simple script which when run on the machine can give us all the details as much as required.
for example for my BT5 and ubuntu work i require output of following commands.
mount
which busybox
echo $PATH
busybox
need inputs from other developers what exact details do they require to debug so that we can make a custom debug script which we can ask user to run once and use that as input for all its queries.....
More i will keep on adding in here... need dev's input here.
Note to MOD : this thread is in Dev section coz work is going on i am working on script just crowdsourcing the content as i don't want to leave anything out....
u will need to check for the following most used commands:
Code:
cat /proc/mtd
which
busybox
mount
ls -l `which mount`
ls -l `which busybox`
ls -l `which sh`
ls -l `which chmod`
ls -l `which chwon`
ls -l `which grep`
ls -l `which sed`
ls -l `which awk`
and so on...
u get the idea...
so u get most info related to the device... MTD blocks, busybox location, mount points, location & symlink info (if any) of most used commands
Thanks for the inital tips ... working in this as i needed it for BT thread thought i would crowdsource the idea.
ohk so here is what i am doing right now.
creating a simple script which will generate all the debug output and dump it in /sdcard/debug_log.txt
then we can ask use to upload this debug_log.txt for our debugging.
To All Dev,
please suggest anything else you need to check frequently which we can add in here.
Will be uploading first version in few minutes.
@DooMLorD : might need your help in creating a recovery zip file of it.
anantshri said:
...
@DooMLorD : might need your help in creating a recovery zip file of it.
Click to expand...
Click to collapse
ya sure let me know...
till then something for u to read/check for creating update.zip
http://forum.xda-developers.com/showthread.php?t=1041064
also some examples of update-script:
http://forum.xda-developers.com/showthread.php?p=13522506#post13522506
First Set of code file
@DooMLorD : shamelessly copied your script to check type of Recovery, although added a bit of my logic in.
Code:
# DEBUG Log generation script created by Anant Shrivastava
# known as anantshri in XDA forum
# credit goes to B,J,Z and other developers.
# any specific code taken from other dev's have credit in place.
# incase i missed something send me a PM and i will add it.
debug()
{
#general debug listing.
echo "********** BUSYBOX *****************"
which busybox
busybox
echo "********** MOUNT *******************"
mount
cat /proc/mtd
echo "*************Command Permissions***************"
ls -l `which mount`
ls -l `which busybox`
ls -l `which sh`
ls -l `which chmod`
ls -l `which chwon`
ls -l `which grep`
ls -l `which sed`
ls -l `which awk`
echo "********** ROM SPECIFIC SETTINGS ***************"
cat /system/build.prop | grep "ro.build.id"
cat /system/build.prop | grep "ro.build.display.id"
cat /system/build.prop | grep "ro.build.version.incremental"
echo "************* KERNEL INFORMATION ****************"
uname -a
echo "************* DEFAULT PATH **********************"
echo $PATH
}
debug_bt()
{
echo "BackTrack Specific Log"
ls -l /sdcard/bt
}
chk_recovery()
{
#
# Script (v1) to check for type of Recovery
# by DooMLoRD
#
# For Xperia X10 users only
#
echo "Recovery disk's available"
if [ -e /system/bin/xrecovery.tar ]
then
echo "xRecovery FOUND!"
fi
if [ -e /system/recovtools/xrecovery.tar.gz ]
then
echo "FreeXperia Recovery FOUND! [TYPE 1]"
fi
if [ -e /system/recovery/recovery.tar.bz2 ]
then
echo "FreeXperia Recovery FOUND! [TYPE 2]"
fi
echo -n "Chargemon Configured Recovery : "
REC=`cat /system/bin/chargemon | grep tar | grep recovery | cut -f4 -d"/"`
if [ $REC == "xrecovery.tar" ]
then
echo "Xrecovery"
elif [ $REC == "xrecovery.tar.gz" ]
then
echo "FreeXperia Recovery"
elif [ $REC == "recovery.tar.bz2"]
then
echo "FreeXperia Recovery type 2"
fi
}
export LOG_FILE=/sdcard/debug_log.txt
echo "Creating DEBUG LOG please wait"
echo "Collection general information"
debug > $LOG_FILE 2>&1
echo "Checking Recovery installed on phone"
chk_recovery >> $LOG_FILE 2>&1
echo "Collecting BT specific information"
debug_bt >> $LOG_FILE 2>&1
I am right now just attaching the sh file we can add an icon on desktop using gscript lite.
Please suggest if anything i missed.
ooohhhh nice modular functions in shell script!!!
great will be using this trick later for some advance work...
btw do shell scripts allow for "include" commands/scripts
EDIT:
yups i was thinking of including grep code to search for exact "Active" recovery in chargmeon...
EDIT2:
Gscript is weird... the output for ur code will display on device screen:
stderr:
stderr:
stderr:
stderr:
....
lots of them too
DooMLoRD said:
ooohhhh nice modular functions in shell script!!!
great will be using this trick later for some advance work...
btw do shell scripts allow for "include" commands/scripts
EDIT:
yups i was thinking of including grep code to search for exact "Active" recovery in chargmeon...
EDIT2:
Gscript is weird... the output for ur code will display on device screen:
stderr:
stderr:
stderr:
stderr:
....
lots of them too
Click to expand...
Click to collapse
1) just pulling off old shell scripting tricks i used to use.
include bash do support need to check if android shell will support or not.
2) So your task half done...
3) Stderr is what i don't understand at all why they occur in gscript
anantshri said:
1) just pulling off old shell scripting tricks i used to use.
include bash do support need to check if android shell will support or not.
2) So your task half done...
3) Stderr is what i don't understand at all why they occur in gscript
Click to expand...
Click to collapse
u might also want to search for:
Code:
which
on FreeX10-beta4 its a part of busybox (symlinked to busybox)
also some additional stuff u might want to check from build.prop
Code:
echo "********** ROM SPECIFIC SETTINGS ***************"
cat /system/build.prop | grep "ro.build.version.sdk"
cat /system/build.prop | grep "ro.build.version.release"
cat /system/build.prop | grep "ro.product.model"
{
"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"
}
I think this is a great idea, as a standard user it will give me a chance to provide useful feedback (rather then just saying "that's a good idea!")
So, forgive me for my ignorance of development, but could you also use the routine to perform common tests. i.e, besides the bug reports are there other sub-routines that can be executed (harmlessly) to provide the dev's with additional info on the phones' make-up.
I suggest this assuming there are some common problems that could be identified by accessing additional date not currently found in the de-bug outputs..?
Hi All,
updated the script with some more codes ....
Please suggest if anything else is needed will try to see if i can make a flashable zip for this.
changelog
1)added logcat's for events main and radio. also added option to get stacktrace of dalvik.
EDIT : script updated.....
anantshri said:
Hi All,
updated the script with some more codes ....
Please suggest if anything else is needed will try to see if i can make a flashable zip for this.
changelog
1)added logcat's for events main and radio. also added option to get stacktrace of dalvik.
Click to expand...
Click to collapse
dude u posted output of script and not the updated script itself
@DooMLorD
thanks for pointing ... correct script updated....
Please check and suggest...
anantshri said:
@DooMLorD
thanks for pointing ... correct script updated....
Please check and suggest...
Click to expand...
Click to collapse
looking good so far....
few more sugestions:
dmesg
kmesg
last_kmesg
DooMLoRD said:
looking good so far....
few more sugestions:
dmesg
kmesg
last_kmesg
Click to expand...
Click to collapse
I DooMLoRD,
Checked about all three
dmesg gives runtime output of kerenel messages.
cat /proc/kmesg is a copy of dmesg output... with a twist. once cat /proc/kmesg is done the output goes out of file and it just keeps waiting for more input.
last_kmesg as i know is for the last session.
Script is done ... will just post the details. here.
Need your help in creating a zipable file for creating this script as a simple command on shell.
Version 1.0 debug script
Code:
# DEBUG Log generation script created by Anant Shrivastava
# known as anantshri in XDA forum
# credit goes to B,J,Z and other developers.
# any specific code taken from other dev's have credit in place.
# incase i missed something send me a PM and i will add it.
debug()
{
#general debug listing.
echo "********** BUSYBOX *****************"
which
which busybox
busybox
echo "********** MOUNT *******************"
mount
cat /proc/mtd
echo "*************Command Permissions***************"
ls -l `which mount`
ls -l `which busybox`
ls -l `which sh`
ls -l `which chmod`
ls -l `which chwon`
ls -l `which grep`
ls -l `which sed`
ls -l `which awk`
echo "********** ROM SPECIFIC SETTINGS ***************"
cat /system/build.prop | grep "ro.build.id"
cat /system/build.prop | grep "ro.build.display.id"
cat /system/build.prop | grep "ro.build.version.incremental"
cat /system/build.prop | grep "ro.build.version.sdk"
cat /system/build.prop | grep "ro.build.version.release"
cat /system/build.prop | grep "ro.product.model"
cat /system/build.prop | grep "ro.modversion"
cat /system/build.prop | grep "ro.rommanager.developerid"
cat /system/build.prop | grep "ro.build.description"
cat /system/build.prop | grep "ro.build.fingerprint"
echo "************* KERNEL INFORMATION ****************"
uname -a
echo "************* DEFAULT PATH **********************"
echo $PATH
}
debug_bt()
{
echo "************* BackTrack Specific Log ************"
ls -l /sdcard/bt
ls -l /data/local/bt
ls -l `which bt`
ls -l `which stopbt`
ls -l `which startbt`
echo "************* VNC Config File *******************"
cat /data/local/bt/root/.vnc/xstartup
}
chk_recovery()
{
#
# Script (v1) to check for type of Recovery
# by DooMLoRD
#
# For Xperia X10 users only
#
echo "*********************** RECOVERY DETAILS ***************"
echo "Recovery disk's available"
if [ -e /system/bin/xrecovery.tar ]
then
echo "xRecovery FOUND!"
fi
if [ -e /system/recovtools/xrecovery.tar.gz ]
then
echo "FreeXperia Recovery FOUND! [TYPE 1]"
fi
if [ -e /system/recovery/recovery.tar.bz2 ]
then
echo "FreeXperia Recovery FOUND! [TYPE 2]"
fi
echo -n "Chargemon Configured Recovery : "
REC=`cat /system/bin/chargemon | grep tar | grep recovery | cut -f4 -d"/"`
if [ $REC == "xrecovery.tar" ]
then
echo "Xrecovery"
elif [ $REC == "xrecovery.tar.gz" ]
then
echo "FreeXperia Recovery"
elif [ $REC == "recovery.tar.bz2"]
then
echo "FreeXperia Recovery type 2"
fi
}
logcats()
{
echo "========== LOGCAT : MAIN ==================="
logcat -b main -d
echo "========== LOGCAT : EVENTS ================="
logcat -b events -d
echo "========== LOGCAT : RADIO =================="
logcat -b radio -d
echo "******** DALVIK STACK TRACE *********************"
cat `cat /system/build.prop | grep "dalvik.vm.stack-trace-file" | cut -f2 -d"="`
echo "******** Kernel Messages DMESG ******************"
dmesg
echo "******** LOG LAST KMESG *************************"
cat /proc/last_kmsg
}
export LOG_FILE=/data/local/debug_log.txt
echo "Creating DEBUG LOG please wait"
echo "Collection general information"
debug > $LOG_FILE 2>&1
echo "Checking Recovery installed on phone"
chk_recovery >> $LOG_FILE 2>&1
echo "Collecting BT specific information"
debug_bt >> $LOG_FILE 2>&1
echo "Collecting logcat's : main, events, radio + stack trace"
logcats >> $LOG_FILE 2>&1
Okay, I see a lot of devs that want to put out a "rom", and I am trying to do that for all the roms- leaks, roms, etc. I think I can accomplish what most rom devs do with small flashable zips-- I just need this help to make it possible!
The only thing that is hanging me up is - change A to B, if A doesn't exist add B. I've done lots of googling, but the sed command seems REALLY complicated for what I am trying to do- and I think there must be an easier way people are already using for android! Or is there a program people are using to make these insanely complicated scrips I see?!?!
Here is an example I know I can do, and works- but it is modifying a line I know IS there:
Code:
sed 's/^ro.product.version=*/ro.product.version=Revolutionized Nonsense 2.1Final/g' /system/build.prop
Like as simple as changing my build, no problem, I know that build is there, but what if I want to change "ro.ril.gprsclass=10" to "ro.ril.gprsclass=12"- but if it ISN'T there, I want to add that line??(I'm not saying it ISN'T there, this is just an example..)
Like I said, I am sure there is a simpler way, I know SED allows patterns and all of that- I am trying to keep this simple! I don't want to replace someone's build.prop, I want to modify it(and I will make a backup)- and for all non RO(read only) lines I plan to use local.prop..
Please, I have asked a few questions here that never got answered, I eventually found a workaround, but this one has TRULY stumped me! This is all a learning process for me, and I am trying to learn the simplest/best way, not just the long and complicated way..
Thanks in advance!
SBD
So from my understanding, you are looking to write a script that modifies the build.prop, yes?
If so, you'd want to do something like this. This is pseudo-code!
if entry exists ; then
replace entry
else if entry does not exist ; then
add entry
fi
For your test, use grep.
if grep ro.sample.prop build.prop ; then
sed -d CODE HERE TO REPLACE
else
echo CODE HERE >> build.prop
fi
Please let me know if you need further help.
Sent from my PG86100 using Tapatalk 2
tommytomatoe said:
So from my understanding, you are looking to write a script that modifies the build.prop, yes?
If so, you'd want to do something like this. This is pseudo-code!
if entry exists ; then
replace entry
else if entry does not exist ; then
add entry
fi
For your test, use grep.
if grep ro.sample.prop build.prop ; then
sed -d CODE HERE TO REPLACE
else
echo CODE HERE >> build.prop
fi
Please let me know if you need further help.
Sent from my PG86100 using Tapatalk 2
Click to expand...
Click to collapse
So with my example above would this work??
Code:
if grep ro.ril.gprsclass= /system/build.prop ; then
sed 's/^ro.ril.gprsclass=*/ro.ril.gprsclass=12/g' /system/build.prop
else
busybox echo "ro.ril.gprsclass=12" >> /system/build.prop
Your example makes me wonder if sed gets use differently aftergrep(or is that formatted correctly?) and what is the -d for?
I need to do this with a lot of lines, so if this does work I need to make sure that the formatting is correct.. because I just want to make a file that works, not troubleshoot it a million times!(My luck I'd leave a space in it somewhere that screws it all up)..
I'm sorry if these questions seem ridiculous, but this will help me get done what I am trying to do - I've already learned so much java, scripting, coding, unix- I don't even know what's what anymore.. I'm just trying to keep learning!
I would use busybox sed just I'm case.
You have two choices with sed.
sed -d will remove the line and then you would echo a new one.
sed -i would replace it inline. Your current script would not work. You need to use -i flag.
Sent from my PG86100 using Tapatalk 2
tommytomatoe said:
I would use busybox sed just I'm case.
You have two choices with sed.
sed -d will remove the line and then you would echo a new one.
sed -i would replace it inline. Your current script would not work. You need to use -i flag.
Sent from my PG86100 using Tapatalk 2
Click to expand...
Click to collapse
I would actually prefer it removed the original line if it will add the modified line at the end of the build.prop
So would this work:
if grep ro.ril.gprsclass= /system/build.prop ; then
busybox sed -d 's/^ro.ril.gprsclass=*/ro.ril.gprsclass=12/g' /system/build.prop
else
busybox echo "ro.ril.gprsclass=12" >> /system/build.prop
Click to expand...
Click to collapse
Or does the sed command have to be modified because of the -d or because of the grep command?
I appreciate you taking the time- I have had several questions get totally overlooked when trying to ask development questions, no matter where I post! You're awesome(and people will be thankful when I get this done, I'm sure!)
SBD
Code:
#!/bin/bash
arg="Cool ass rom bro!"
oldarg=`grep ro.product.version /system/build.prop |cut -d"=" -f2`
sed -i "s/^ro.product.version=*/ro.product.version=${arg}/g" /system/build.prop >> /tmp/tmp-prop
chknewarg=`grep ro.product.version /tmp/tmp-prop |cut -d"=" -f2`
if "$chknewarg" = "$arg"; then
mv /tmp/tmp-prop /system/build.prop
echo "File edited"
else
rm /tmp/tmp-prop
echo "Expected $arg, got $chknewarg instead"
exit 1
fi
exit 0
POC, piece not tested, but should be what you are looking for. This will indeed sed the file but output the file to tmp, then run a check to make sure it wrote it properly, if so it will replace your file. Simple enough.
lithid-cm said:
Code:
#!/bin/bash
arg="Cool ass rom bro!"
oldarg=`grep ro.product.version /system/build.prop |cut -d"=" -f2`
sed -i "s/^ro.product.version=*/ro.product.version=${arg}/g" /system/build.prop >> /tmp/tmp-prop
chknewarg=`grep ro.product.version /tmp/tmp-prop |cut -d"=" -f2`
if "$chknewarg" = "$arg"; then
mv /tmp/tmp-prop /system/build.prop
echo "File edited"
else
rm /tmp/tmp-prop
echo "Expected $arg, got $chknewarg instead"
exit 1
fi
exit 0
POC, piece not tested, but should be what you are looking for. This will indeed sed the file but output the file to tmp, then run a check to make sure it wrote it properly, if so it will replace your file. Simple enough.
Click to expand...
Click to collapse
Okay, if I get this right, the line that says
Code:
chknewarg=`grep ro.product.version /tmp/tmp-prop |cut -d"=" -f2`
is cutting the line that was taken out or modified by sed, or added by the grep command if it didn't exist, and it puts that line at the end of the original build.prop? I could just have this same script 10 times if I wanted to make 10 prop edits and all would be at the end of the original build.prop?
I plan on making a backup of the original build.prop in the script before doing any of this, I just want to make sure that I understand exactly what the outcome is(and this is all just trying to learn anyways, so I am trying to breakdown the commands to understand which line is doing what)..
And thanks for the reply, I'm trying to keep it simple, but I also want to do this as safely as possible too if this goes right, this might end up modifying many phones, and I don't want to screw up any of them!
EDIT: and is there a way I can test this on my pc before trying it on the phone? I would think there is a way to run the script on my pc with a test build.prop to make sure it makes the expected changes- THIS would be very helpful in getting the script perfect!
test it with this:
script
Code:
#!/bin/bash
file=$HOME/build.prop
tmpf=/tmp/tmp-prop
line=ro.product.version
arg="Cool ass rom bro!"
oldarg=`grep $line $file |cut -d"=" -f2`
sed "s/$line=.*/$line=${arg}/g" $file > $tmpf
chknewarg=`grep $line $tmpf |cut -d"=" -f2`
if [ "$chknewarg" = "$arg" ]; then
mv $tmpf $file
echo "File edited"
else
rm $tmpf
echo "Expected $arg, got $chknewarg instead"
exit 1
fi
exit 0
$HOME/build.prop
Code:
ro.product.version=Old Rom Name
ro.generic.type=ForSure
Btw. Do you plan on running this script from Android or from Linux?
Sent from my PG86100 using Tapatalk 2
tommytomatoe said:
Btw. Do you plan on running this script from Android or from Linux?
Sent from my PG86100 using Tapatalk 2
Click to expand...
Click to collapse
Yes, it does matter if your running from the linux OS or android. My example was more edited for him to test locally. There will need to be a few changes before he can run this via android. Plus he should think about getting his own busybox binary to run from, that way he knows that the version he has would work for him.
lithid-cm said:
Yes, it does matter if your running from the linux OS or android. My example was more edited for him to test locally. There will need to be a few changes before he can run this via android. Plus he should think about getting his own busybox binary to run from, that way he knows that the version he has would work for him.
Click to expand...
Click to collapse
Yeah I just wanted it to be clear for him. Since your sample script has /bin/bash I didn't want OP to be confused at why it didn't work
And definitely as lithid said you should build your own busybox so you know what all the applets are and what arguments they can receive.
If you need one I have one built with all features enabled. (v1.9.4) I need to download latest source.
lithid-cm said:
Yes, it does matter if your running from the linux OS or android. My example was more edited for him to test locally. There will need to be a few changes before he can run this via android. Plus he should think about getting his own busybox binary to run from, that way he knows that the version he has would work for him.
Click to expand...
Click to collapse
Well, I decided that I can try testing with script manager, the goal is to have an updater-script run this script to make a backup then the modifications to the build.prop that I need. I modified your last example to this
Code:
#!/bin/bash
file=/system/build.prop
tmpf=/tmp/tmp-prop
line=ro.product.version
arg="Cool ass rom bro!"
oldarg=`grep $line $file |cut -d"=" -f2`
sed "s/$line=.*/$line=${arg}/g" $file > $tmpf
chknewarg=`grep $line $tmpf |cut -d"=" -f2`
if [ "$chknewarg" = "$arg" ]; then
mv $tmpf $file
echo "File edited"
else
rm $tmpf
echo "Expected $arg, got $chknewarg instead"
exit 1
fi
exit 0
and I get a
Code:
failed on '/tmp/tmp-prop' - cross-device link
File edited
And yes I am running it as root.
But I imagine it is because commands in the script aren't using busybox? The final update already has the busybox binary to run from that SHOULD work - but I'll gladly take an updated one!
So for testing with script manager(or even in my flashable) what changes do I need to make? I figured I'd ask before I try flashing this..
EDIT: I did some googling, the only reason it didn't work with Script manager had to do with the mv command, I changed it to copy, and it executed beautifully.. since it deletes the tmp file anyways, shouldn't be an issue right?
Edit2: This is where my noobiness with scripts come in(especially when you involve if/then or variable statements)
I am trying to create probably 15 build.prop edits, I am sure there is just an error in the formatting(or worse), but I get a
test2.sh[11]: syntax error: 'if' unmatched
Click to expand...
Click to collapse
when I try to add the next build.prop edit:
#!/bin/bash
file=/system/build.prop
tmpf=/sdcard/tmp/tmp-prop
arg="Cool ass rom bro!"
oldarg=`busybox grep ro.product.version $file |cut -d"=" -f2`
sed "s/ro.product.version=.*/ro.product.version=${arg}/g" $file > $tmpf
chknewarg=`busybox grep ro.product.version $tmpf |cut -d"=" -f2`
if [ "$chknewarg" = "$arg" ]; then
cp $tmpf $file
echo "File edited"
else
rm $tmpf
echo "Expected $arg, got $chknewarg instead"
arg2="12"
oldarg2=`ro.ril.gprsclass $file |cut -d"=" -f2`
sed "s/ro.ril.gprsclass=.*/ro.product.version=${arg2}/g" $file > $tmpf
chknewarg=`busybox grep ro.ril.gprsclass $tmpf |cut -d"=" -f2`
if [ "$chknewarg" = "$arg2" ]; then
cp $tmpf $file
echo "File edited"
else
rm $tmpf
echo "Expected $arg2, got $chknewarg instead"
exit 1
fi
exit 0
Click to expand...
Click to collapse
Change #/bin/bash at the top to #/system/bin/sh
That was what my previous comment was referring to
Sent from my PG86100 using Tapatalk 2
tommytomatoe said:
Change #/bin/bash at the top to #/system/bin/sh
That was what my previous comment was referring to
Sent from my PG86100 using Tapatalk 2
Click to expand...
Click to collapse
Noted. I just realized this script doesn't create the line if the line isn't found.. how do I fix that?
For example this:
Code:
#!/sbin/sh
file=/system/build.prop
tmpf=/sdcard/tmp/tmp-prop
line=ro.ril.gprsclass
arg="12"
oldarg=`busybox grep $line $file |cut -d"=" -f2`
sed "s/$line=.*/$line=${arg}/g" $file > $tmpf
chknewarg=`grep $line $tmpf |cut -d"=" -f2`
if [ "$chknewarg" = "$arg" ]; then
cp $tmpf $file
echo "File edited"
else
rm $tmpf
echo "Expected $arg, got $chknewarg instead"
exit 1
fi
exit 0
Gives me "Expected 12, got instead"
so how do I make sure to insert the line if it isn't actually there? People rolling with stock won't have many of the tweaks I am trying to modify- I want to make sure they are covered(without possibly duplicating script)
Silentbtdeadly said:
Noted. I just realized this script doesn't create the line if the line isn't found.. how do I fix that?
For example this:
Gives me "Expected 12, got instead"
so how do I make sure to insert the line if it isn't actually there? People rolling with stock won't have many of the tweaks I am trying to modify- I want to make sure they are covered(without possibly duplicating script)
Click to expand...
Click to collapse
Code:
#/system/bin/sh
# Definitions
file=/system/build.prop
tmpf=/tmp/tmp-prop
line_list="ro.product.version=New ro.ril.gprsclass=12"
# Function to get args as needed for loop
getargs() {
par=$1
line=`echo $par |cut -d"=" -f1`
arg=`echo $par |cut -d"=" -f2`
}
# Loop to make all changes in line_list
for x in $line_lst; do
# Get all needed arguments
getargs $x
# Write this change to a tmp file to check on it
oldarg=`grep $line $file |cut -d"=" -f2`
sed "s/$line=.*/$line=${arg}/g" $file > $tmpf
# Check if the change was made
chknewarg=`grep $line $tmpf |cut -d"=" -f2`
if [ "$chknewarg" = "$arg" ]; then
cp $tmpf $file
if [ -f $tmpf ]; then
rm $tmpf
fi
echo "File edited"
else
if [ -f $tmpf ]; then
rm $tmpf
fi
echo "Expected $arg, got $chknewarg instead"
exit 1
fi
# If it doesn't exist at all append it to the file
chkexists=`grep -c $line $file`
if [ $chkexists -eq 0 ]; then
echo "$x" >> $file
fi
done
exit 0
lithid-cm said:
Code:
#/system/bin/sh
# Definitions
file=/system/build.prop
tmpf=/tmp/tmp-prop
line_list="ro.product.version=New ro.ril.gprsclass=12"
# Function to get args as needed for loop
getargs() {
par=$1
line=`echo $par |cut -d"=" -f1`
arg=`echo $par |cut -d"=" -f2`
}
# Loop to make all changes in line_list
for x in $line_lst; do
# Get all needed arguments
getargs $x
# Write this change to a tmp file to check on it
oldarg=`grep $line $file |cut -d"=" -f2`
sed "s/$line=.*/$line=${arg}/g" $file > $tmpf
# Check if the change was made
chknewarg=`grep $line $tmpf |cut -d"=" -f2`
if [ "$chknewarg" = "$arg" ]; then
cp $tmpf $file
if [ -f $tmpf ]; then
rm $tmpf
fi
echo "File edited"
else
if [ -f $tmpf ]; then
rm $tmpf
fi
echo "Expected $arg, got $chknewarg instead"
exit 1
fi
# If it doesn't exist at all append it to the file
chkexists=`grep -c $line $file`
if [ $chkexists -eq 0 ]; then
echo "$x" >> $file
fi
done
exit 0
Click to expand...
Click to collapse
Alright, I got some stuff to do now so I won't be able to play with it for a while, but extra thanks for including the #reasons for the lines, with that I will hopefully be able to get it working AND learn more about what it is I am doing..
Of course the frustrating part is that as a CONCEPT this seems so simple, and I was a little scared it would get fairly complicated to do it.. but this isn't as bad as I thought it would be. Thumbs up for the help!
Alright, let me ask you this, because I haven't decided yet what the final choice will be as far as future updates..
What if I did this - my original release has lines like this in the updater script:
ui_print(" Tweaking /system/build.prop...");
set_perm(0, 0, 0777, "/system/tmp/add_to_buildprop.sh");
run_program("/system/tmp/add_to_buildprop.sh");
set_perm(0, 0, 0777, "/system/tmp/tweak1.sh");
run_program("/system/tmp/tweak1.sh");
set_perm(0, 0, 0777, "/system/tmp/tweak2.sh");
Click to expand...
Click to collapse
The add_to_buildprop.sh script could be changed to a different script(to avoid duplicates), and each tweak.sh script would modify or add ONE line of code in the build.prop.
Calling up separate scripts, each modifying the build.prop like the code in post #14(except with code added to add a line when none exists)..
Then in the next update I add NEW tweaks - this way if someone is new to the "rom" they would flash the first update, then the second one - or I could offer a combined update for new users and old alike(as long as the scripts were written to modify or add missing lines in the build.prop it wouldn't create duplicate lines, and everything they've already flashed wouldn't duplicate)?
I'm just seeing how complicated the script in the last post would get as I continue to add more and more updates to the same script, rather than create more small flashable scripts and modifying the updater script to flash them? Does this make sense?
I am guessing this is why people put out full "roms" - but I am trying to find a way to accomplish the same task for EVERYONE - as long as I pick the right modifications(like specific to the ICS build) it WILL work on ANY rom..
If my logic makes sense, then what lines would I add to the code in post #14 to add lines when they don't already exist? I'm sorry if I am being a pain, but it seems easier to flash 14 scripts than make one incredibly complex script that makes 14 changes..(especially when you consider future updates)
Thanks in advance
SBD
Silentbtdeadly said:
Alright, let me ask you this, because I haven't decided yet what the final choice will be as far as future updates..
What if I did this - my original release has lines like this in the updater script:
The add_to_buildprop.sh script could be changed to a different script(to avoid duplicates), and each tweak.sh script would modify or add ONE line of code in the build.prop.
Calling up separate scripts, each modifying the build.prop like the code in post #14(except with code added to add a line when none exists)..
Then in the next update I add NEW tweaks - this way if someone is new to the "rom" they would flash the first update, then the second one - or I could offer a combined update for new users and old alike(as long as the scripts were written to modify or add missing lines in the build.prop it wouldn't create duplicate lines, and everything they've already flashed wouldn't duplicate)?
I'm just seeing how complicated the script in the last post would get as I continue to add more and more updates to the same script, rather than create more small flashable scripts and modifying the updater script to flash them? Does this make sense?
I am guessing this is why people put out full "roms" - but I am trying to find a way to accomplish the same task for EVERYONE - as long as I pick the right modifications(like specific to the ICS build) it WILL work on ANY rom..
If my logic makes sense, then what lines would I add to the code in post #14 to add lines when they don't already exist? I'm sorry if I am being a pain, but it seems easier to flash 14 scripts than make one incredibly complex script that makes 14 changes..(especially when you consider future updates)
Thanks in advance
SBD
Click to expand...
Click to collapse
The script I gave you already does everything. Just add edits to line_list
Sent from my Nexus S 4G using xda premium
lithid-cm said:
The script I gave you already does everything. Just add edits to line_list
Sent from my Nexus S 4G using xda premium
Click to expand...
Click to collapse
Alright, I just wasn't sure if this code was better for a one time flashable since I intended to put out future updates.. I'm gonna play with it now, and thanks again for taking the time to put so much work into it!(it is quite informative, and most of this is me trying to learn, to break into the next level of work).
Thanks again!
Oh also, in the script make sure you use busybox to mount system with rw (busybox mount -o remount,rw /system). It is not enough most of the time to Mont system in updater-script
Sent from my PG86100 using Tapatalk 2
I have two of these devices sitting around and I was wondering how people were repurposing them. I just picked up a Raspberry Pi with the intention of setting up a home automation system. Isn't the Eris also an ARMv6 processor? Could they be used as smart WiIP video security cameras? Is there a Linux distro somewhere? Anyone have any experience?
Greetings! There's a thread here you might be interested in. http://forum.xda-developers.com/showthread.php?t=823564&highlight=linux
roirraW "edor" ehT said:
Greetings! There's a thread here you might be interested in. http://forum.xda-developers.com/showthread.php?t=823564&highlight=linux
Click to expand...
Click to collapse
http://www.4shared.com/zip/uiPl7NhN/ubuntu.html Link to Ubuntu.img
to mount you can use this:
linuxboot.sh
#option if you wish to load a different file than the rc_enter just replace the rc_enter.sh with the script file you want to run
# i.e init.sh below this script I will post the initl.ls if you wan to replace the rc_enter.sh
Code:
#!/system/bin/sh
(
# If $BINDS does not exist, then done of the others are set iether.
if [ -z "$BINDS" ]; then
export DIST="debian squeeze"
export FILESYSTEM=/sdcard/ubuntu.img
export MOUNTPOINT=/sdcard/linux
export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
export USER=root
export LOGNAME=root
export UID=0
export SHELL=bash
export FS=ext3
export busybox="/data/data/com.galoula.LinuxInstall/bin/busybox"
export BINDS="1"
unset TMPDIR
fi
createLinuxBoot() {
if $busybox [ -d "$FILESYSTEM" ]
then
echo "I: Directory chroot !"
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT/proc")" ]; then
# If the loop device is already mounted, we do nothing.
echo "W: $DIST is already mounted. Entering chroot..."
else
echo "I: Mounting device for $DIST..."
# Bind some Android dirs to the linux filesystem
if $busybox [ $BINDS -eq 1 ]
then
# Create mtab
echo > "${MOUNTPOINT}/etc/mtab"
$busybox cat /proc/mounts > "${MOUNTPOINT}/etc/mtab"
# for i in `$busybox cat /proc/mounts | $busybox cut -d " " -f 2`
for i in $( $busybox cat /proc/mounts | $busybox awk '{print $2}' )
do
$busybox mkdir -p "${MOUNTPOINT}/$i" 2> /dev/null
$busybox mount -o bind "${i}" "${MOUNTPOINT}/${i}" 2> /dev/null
#echo "${i}" >> "${MOUNTPOINT}/etc/mtab"
done
fi
fi
else
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
# If the loop device is already mounted, we do nothing.
echo "W: $DIST is already mounted. Entering chroot..."
else
echo "I: Mounting device for $DIST..."
if $busybox [ ! -d $MOUNTPOINT ]; then
# Create the mount point if it does not already exist
$busybox mkdir -p $MOUNTPOINT 2> /dev/null
if $busybox [ ! -d $MOUNTPOINT ]; then
echo "F: It was not possible to create the missing mount location ($MOUNTPOINT)"
return 0
fi
fi
if $busybox [ -f "$FILESYSTEM" ]
then
# 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 $busybox [ ! -e /dev/block/loop0 ]; then
i=0
while [ $i -le 8 ]
do
$busybox mknod /dev/block/loop$i b 7 $i
let i=1+$i
done
fi
# Locate the current loop device file
if $busybox [ ! -z "$($busybox losetup | $busybox grep "$FILESYSTEM")" ]; then
# If the filesystem file is already attached to an loop device, we get the path to the device file.
loblk=$($busybox losetup | $busybox grep "$FILESYSTEM" | $busybox cut -d ":" -f 1)
else
# If the filesystem file is not yet attached, we attach it.
loblk=$($busybox losetup -f)
$busybox losetup $loblk $FILESYSTEM 2> /dev/null
# Make sure that the device was successfully attached to a loop device file
if $busybox [ -z "$($busybox losetup | $busybox grep "$FILESYSTEM")" ]; then
echo "F: It was not possible to attach the device to a loop device file"
return 0
fi
fi
fi
if $busybox [ -b "$FILESYSTEM" ]
then
loblk=$FILESYSTEM
fi
# Mount the filesystem
$busybox mount -t $FS $loblk $MOUNTPOINT 2> /dev/null
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
# Bind some Android dirs to the linux filesystem
if $busybox [ $BINDS -eq 1 ]
then
# Create mtab
echo > "${MOUNTPOINT}/etc/mtab"
$busybox cat /proc/mounts > "${MOUNTPOINT}/etc/mtab"
# for i in `$busybox cat /proc/mounts | $busybox cut -d " " -f 2`
for i in $( $busybox cat /proc/mounts | $busybox awk '{print $2}' )
do
# /sdcard/Mon mount/Linux
$busybox mkdir -p "${MOUNTPOINT}/$i" 2> /dev/null
$busybox mount -o bind "${i}" "${MOUNTPOINT}/${i}" 2> /dev/null
#echo "${i}" >> "${MOUNTPOINT}/etc/mtab"
done
fi
#for i in $BINDS
#do
# # Bind the dirs if they are not already binded
# if $busybox [ -z "$($busybox mount | $busybox grep "$MOUNTPOINT/$i ")" ]; then
# # Create any missing dirs in the mountpoint
# if $busybox [ ! -d $MOUNTPOINT/$i ]; then
# $busybox mkdir -p $MOUNTPOINT/$i
# fi
# $busybox mount -o bind $i $MOUNTPOINT$i
# fi
#done
else
echo "F: It was not possible to mount $DIST at the specified location ($MOUNTPOINT)"
return 0
fi
fi
fi
# FIX the "stdin: is not a tty" error in direct hadware case.
if $busybox [ -z "$($busybox mount | $busybox grep "$MOUNTPOINT/dev/pts ")" ]; then
$busybox 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.
$busybox rm -rf $MOUNTPOINT/tmp/*
if $busybox [ -f $MOUNTPOINT/etc/init.android/rc_mount.sh ]; then
# Execute the mount init file, if it exists
echo "I: Executing /etc/init.android/rc_mount.sh"
$busybox chroot $MOUNTPOINT /etc/init.android/rc_mount.sh
fi
echo "I: Entering chroot..."
return 1
}
removeLinuxBoot() {
if $busybox [ -d "$FILESYSTEM" ]
then
echo "I: Directory chroot !"
# Unmount pts
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT/dev/pts ")" ]; then
$busybox umount $MOUNTPOINT/dev/pts 2> /dev/null
fi
for i in $BINDS
do
# Unmount all binding dirs
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT/$i ")" ]; then
$busybox umount $MOUNTPOINT/$i
fi
done
for i in `$busybox cat /proc/mounts | $busybox tac | $busybox grep -v "$MOUNTPOINT " | $busybox grep "$MOUNTPOINT" | $busybox cut -d " " -f 2`;do umount $i 2> /dev/null;done
else
if $busybox [ -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
# If linux is not mounted, then do nothing.
echo "W: $DIST is already unmounted"
else
echo "I: Unmounting $DIST..."
if $busybox [ -f $MOUNTPOINT/etc/init.android/rc_unmount.sh ]; then
echo "I: Executing /etc/init.android/rc_unmount.sh"
# Execute the unmount init script, if it exist.
$busybox chroot $MOUNTPOINT /etc/init.android/rc_unmount.sh
fi
sync
# Make sure that we have an loop device file to use
if $busybox [ -f "$FILESYSTEM" ]
then
if $busybox [ ! -z "$($busybox losetup | $busybox grep "$FILESYSTEM")" ]; then
# Get the loop device file
loblk=$($busybox losetup | $busybox grep "$FILESYSTEM" | $busybox cut -d ":" -f 1)
else
echo "E: Could not locate the loop device file. $DIST was not unmounted successfully"
fi
fi
if $busybox [ -b "$FILESYSTEM" ]
then
loblk=$FILESYSTEM
fi
# Unmount pts
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT/dev/pts ")" ]; then
$busybox umount $MOUNTPOINT/dev/pts
fi
for i in `$busybox cat /proc/mounts | $busybox tac | $busybox grep -v "$MOUNTPOINT " | $busybox grep "$MOUNTPOINT" | $busybox cut -d " " -f 2`;do umount $i 2> /dev/null;done
for i in $BINDS
do
# Unmount all binding dirs
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT/$i ")" ]; then
$busybox umount $MOUNTPOINT/$i
fi
done
sync && sleep 1
# Unmount the device
$busybox umount $MOUNTPOINT 2> /dev/null && sleep 1
# If the device could not be unmounted
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
echo "E: $DIST could not be unmounted. Trying to kill attached processes..."
# Try to kill all processes holding the device
for i in `$busybox grep "$MOUNTPOINT" /proc/*/maps 2> /dev/null | $busybox cut -d":" -f 1 | $busybox sort | $busybox uniq | $busybox cut -d "/" -f 3`; do kill $i 2> /dev/null; echo; done
fuser -k -9 $MOUNTPOINT
for i in `$busybox grep "$MOUNTPOINT" /proc/*/maps 2> /dev/null | $busybox cut -d":" -f 1 | $busybox sort | $busybox uniq | $busybox cut -d "/" -f 3`; do kill -9 $i 2> /dev/null; echo; done
# Use umount with the -l option to take care of the rest
$busybox umount -l $MOUNTPOINT 2> /dev/null && sleep 1
fi
# Make sure the device has been successfully unmounted
if $busybox [ -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
if $busybox [ -f "$FILESYSTEM" ]
then
# Try to detach the device from the loop device file
$busybox losetup -d $loblk 2> /dev/null
# Make sure that the device was successfully detached
if $busybox [ -z "$($busybox losetup | $busybox grep "$FILESYSTEM")" ]; then
echo "I: $DIST has been successfully unmounted"
else
echo "E: $DIST has been unmounted, but could not detach the loop device"
fi
fi
if $busybox [ -b "$FILESYSTEM" ]
then
if $busybox [ -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
echo "I: $DIST has been successfully unmounted"
else
echo "E: $DIST has been unmounted, but could not detach the loop device"
fi
fi
else
echo "E: $DIST could not be unmounted successfully"
fi
fi
fi
}
if $busybox [ "$1" = "unmount" ]; then
removeLinuxBoot
else
createLinuxBoot
if $busybox [ $? -eq 1 ]; then
if $busybox [ -f $MOUNTPOINT/etc/init.android/rc_enter.sh ]; then
echo "I: Executing /etc/init.android/rc_enter.sh"
$busybox chroot $MOUNTPOINT /etc/init.android/rc_enter.sh
else
echo "I: To run command when enterring Linux create executable file at /etc/init.android/rc_enter.sh"
fi
$busybox chroot $MOUNTPOINT /bin/bash -i
if $busybox [ -f $MOUNTPOINT/etc/init.android/rc_leave.sh ]; then
echo "I: Executing /etc/init.android/rc_leave.sh ..."
$busybox chroot $MOUNTPOINT /etc/init.android/rc_leave.sh
else
echo "I: To run command when leaving Linux create executable file at /etc/init.android/rc_leave.sh"
fi
echo "Q: Do you want to unmount the $DIST environment, or leave it as is ? Y will kill all process as required; any other key will leave services running."
read REPLY
if $busybox [ "y$REPLY" = "yy" ] || $busybox [ "y$REPLY" = "yY" ]; then
removeLinuxBoot
fi
fi
fi
)
or you can mount it with this linuxboot.sh:
Code:
# Check Permissions
if [ $(whoami) != root ]; then
echo "This script must be run as root."
exit
fi
# Script Variables
NAME=ubuntu
PATH=$(dirname $0)
# Enviroment Variables
export BIN=/system/bin
export HOME=/root
export MOUNT=/data/local/mnt/$NAME
export PATH=$BIN:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
export TERM=linux
export USER=root
# Change Directory
cd $PATH
# Create Mount Point
mkdir -p $MOUNT
# Remount System Read/Write
mount -o remount,rw /system
# Check Loop Block Device
if [ ! -b /dev/block/loop_$NAME ]; then
# Create Loop Block Device
mknod /dev/block/loop_$NAME b 7 255
fi
# Setup Loop Block Device
losetup /dev/block/loop_$NAME $NAME.img
# Mount Loop Block Device To Mount Point
mount -t ext3 /dev/block/loop_$NAME $MOUNT
# Add Mount Points
mount -o bind /dev $MOUNT/dev
mount -o bind /dev/pts $MOUNT/dev/pts
mount -o bind /dev/shm $MOUNT/dev/shm
mount -o bind /sdcard $MOUNT/media
mount -t proc none $MOUNT/proc
mount -t sysfs none $MOUNT/sys
# Set Options
echo "127.0.0.1 localhost" > $MOUNT/etc/hosts
echo "nameserver 8.8.4.4" > $MOUNT/etc/resolv.conf
echo "nameserver 8.8.8.8" >> $MOUNT/etc/resolv.conf
rm -rf $MOUNT/lost+found
sysctl -w net.ipv4.ip_forward=1 > /dev/null
sysctl -w net.ipv6.conf.all.forwarding=1 > /dev/null
# Enter Linux
chroot $MOUNT /bin/bash -c "source /etc/profile; bash"
# Remove Mount Points
umount $MOUNT/sys
umount $MOUNT/proc
umount $MOUNT/media
umount $MOUNT/dev/shm
umount $MOUNT/dev/pts
umount $MOUNT/dev
# Clean Up
umount $MOUNT
losetup -d /dev/block/loop_$NAME
rm /dev/block/loop_$NAME
rmdir $MOUNT
this is not the init.sh.
the init.sh is iniside the ubuntu.img so to boot using the init.sh you can edit the rc_enter.sh to start init.sh like so:
./init.sh
you can also start a service like so:
service hostname start
Hi all,
I have a ZP980 rooted running android 4.2.1 that has 1.5GB for app storage and another partition of 26GB in the internal memory mounted as /sdcard used for data.
I wanted to use the big partition to store apps too and since none of the app I tried worked to move some apps to the fake SD I tried to do a script on my own.
PROBLEM:
The script works good but the problem is that if I reboot the phone all files and symlinks are still there but the app is "not installed" so I can't lunch it, I think android makes a scan on boot and maybe /sdcard is not available at that time.
TEMPORARY SOLUTION:
The only way to make it work again is to move the apk back to /data/app and reboot, or remove the symlink and use:
# pm install -r PACKAGE
WHAT I TRIED:
#pm enable PACKAGE
but it looks like it's not disabled that way
WHAT I'D LIKE TO HAVE:
I'd like to find a way to reenable the PACKAGE without having to reinstall it, any clue where android memorize that the app is "installed" or a command to do only that tiny bit and not the whole install process?
SCRIPT (for who interested)
Code:
#!/system/bin/sh
sdcard="/storage/sdcard0/Apps"
internal="/data"
data="/data/data"
package="$2"
usage()
{
echo "Usage: $0 [OPTION] [PACKAGE]"
echo
echo "This script copy app and dalvik cache from internal memory to sd and back creating a symlink."
echo
echo "OPTIONS:"
echo " -a Move app and dalvik cache to sd"
echo " -b Move app and dalvik cache back to internal memory"
echo " -r Restore apps after reboot"
echo
echo "PACKAGE"
echo " without .apk"
echo " ES. to move candycrush to sd:"
echo " mv2sd -a com.king.candycrushsaga"
}
function setperm
{
local file=$1
case $type in
"app")
group="system"
;;
"dalvik-cache")
local group=$(ls -ld $data/$package | awk '{print $4}')
;;
esac
chown system:$group $file
chmod 644 $file
}
function mvfile
{
local fileFrom=$1
local fileTo=$2
if [ "$back" -eq 1 ]; then
rm -f $fileTo
local destination="data"
else
local destination="sd"
fi
cp -a $fileFrom $fileTo
if [ $? -ne 0 ]; then
exit $?
else
echo "$package $type moved to $destination"
rm -f $fileFrom
if [ $back -eq 0 ]; then
ln -s $fileTo $fileFrom
else
setperm $fileTo
fi
fi
}
function mvfiles
{
type=$1
case $type in
"app")
local uri="$type/$filename"
;;
"dalvik-cache")
local uri="$type/[email protected]@[email protected]"
;;
esac
intFile="$internal/$uri"
sdFile="$sdcard/$uri"
if [ "$back" -eq 0 ] && [ -f "$intFile" ]; then
mvfile $intFile $sdFile
elif [ "$back" -eq 1 ] && [ -L "$intFile" ] && [ -f "$sdFile" ]; then
mvfile $sdFile $intFile
else
echo "$type file or symlink not found"
fi
}
#initialize
back=2
restore=0
while getopts "abrh" option
do
case $option in
a)
back=0;
;;
b)
back=1;
;;
r)
restore=1;
;;
h)
usage
exit
;;
esac
done
if [ "$back" -eq "2" ] && [ "$restore" -eq "0" ]; then
usage
exit 1
fi
#restore
if [ "$restore" -eq "1" ]; then
for file in $sdcard/app/*.apk
do
filename=$(basename "$file")
intFile="$internal/app/$filename"
sdFile="$sdcard/app/$filename"
intDalvik="$internal/dalvik-cache/[email protected]@[email protected]"
sdDalvik="$sdcard/dalvik-cache/[email protected]@[email protected]"
package="${filename%-*}"
if [ -L "$intFile" ] && [ -f "$sdFile" ] && [ -L "$intDalvik" ] && [ -f "$sdDalvik" ]; then
rm -f $intFile
rm -f $intDalvik
rm -f $sdDalvik
pm install -r $sdFile
rm -f $sdFile
mv2sd -a $package
fi
done
else
file=$(ls $internal/app/$package-*)
filename=$(basename "$file")
#move app
mvfiles "app"
mvfiles "dalvik-cache"
fi
shift $(($OPTIND -1))
I found something, thanks to this nice article:
http://www.kpbird.com/2012/10/in-depth-android-package-manager-and.html
So I tried to reboot and I see that in /data/system/packages.xml all apps I symlinked have flags="0"
Before:
<package name="com.king.candycrushsaga" codePath="/data/app/com.king.candycrushsaga-1.apk" nativeLibraryPath="/data/app-lib/com.king.candycrushsaga-1" flags="572996" ft="1435aa87ca0" it="140f50e81fe" ut="14303810da6" version="102212" userId="10084">
Click to expand...
Click to collapse
After:
<package name="com.king.candycrushsaga" codePath="/data/app/com.king.candycrushsaga-1.apk" nativeLibraryPath="/data/app-lib/com.king.candycrushsaga-1" flags="0" ft="1435aa87ca0" it="140f50e81fe" ut="14303810da6" version="102212" userId="10084">
Click to expand...
Click to collapse
Changing that value on runtime doesn't work.
I'm still looking how to change it maybe PackageManagerService.grantPermissionsLP()
https://android.googlesource.com/pl.../android/server/pm/PackageManagerService.java
At the end I solved the problem.
I'm not sure why but if an app is symlinked to anything on sdcard is disabled at start, but if it's symlinked on another folder on /data or /system it keeps working after reboot.
So first I tried to symlink /data/sdcard => /sdcard but it's not working because it can still see the final destination is the sdcard, so I mounted the sdcard on /data/sdcard and symlink /data/app/some.app-1.apk => /data/sdcard/app/some.app-1.apk and it's working
sdcard need to be mounted on start inside an init.d script so it's available when the scan happens.
Moving forward I decided to create an ext2 filesystem in a file, keep it in my sdcard partition and mount it on /data/sdcard.
This way, with a modified and improved version of my script I can move apks, libs, dalvik-cache and all the data folder for each app I want keeping the right file permissions