jancona / android-on-freerunner

Automatically exported from code.google.com/p/android-on-freerunner
1 stars 1 forks source link

Run custom shell commands on boot #110

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
As the AOF is work in progress, there are many instances when one needs to
run a certain commands on boot:
 * Clamp SD card speed for certain SD cards (bug #81)
 * Fix the /cache symlink so that android market application would work
 * fsck SD card
 * fix some kernel variable in /proc or /sys
 * etc

Any changes to init.rc disappear as the script is overwritten on boot from
 built into the kernel version (or something like that).
To allow execution of custom commands, add following line to the end of the
init.rc script:
/custom.rc

Original issue reported on code.google.com by skliarie@gmail.com on 3 Feb 2010 at 2:58

GoogleCodeExporter commented 9 years ago
Simple /custom.rc is not enough, becouse / mounted at ram-disk into kernel 
part. So
to change it will be necessary to rebuild kernel image.
Possible solution may be: /custom.rc as soft link to /sdcard/custom.rc or
/system/custom.rc or /system/etc/custom.rc etc.
The soft link should be defined at kernel part, and ordinary user able to 
change it
after a-o-f start. At places shown above changes will save over reboot.

But do not forget about a problems concerned: safety/stability to work and so.

Original comment by Alexandr...@gmail.com on 3 Feb 2010 at 4:42

GoogleCodeExporter commented 9 years ago
While AOF is in development stage it requires post-boot band-aids. I am sure 
that at
this point it is more important to have them than to worry about obscurely 
possible
security issues. Once there will be no need in any post-boot modifications the
feature can be very easily removed.

And regarding stability - it is the custom shell commands that will bring more 
stability.

I would be very happy if the option will find way into AOF 0.2.0.

Original comment by skliarie@gmail.com on 3 Feb 2010 at 5:41

GoogleCodeExporter commented 9 years ago
I vote for this! 

Yes, might be a security issue, but having access as we do to the underbelly of 
the FR 
makes it acceptable.  I don't think there are "just general users" on here.

This also opens up a new line of dev work for people more comfortable with 
scripting 
than kernel/core code hacking.

Original comment by v4mpyr8...@gmail.com on 4 Feb 2010 at 5:46

GoogleCodeExporter commented 9 years ago
Changed type

Original comment by hmu...@gmail.com on 10 Feb 2010 at 10:36

GoogleCodeExporter commented 9 years ago
Yes, i think too! i'll be very happy if i see this option  in the next daily 
build :)

Original comment by rooszpe...@gmail.com on 25 Feb 2010 at 6:28

GoogleCodeExporter commented 9 years ago
Put following single line at the end if the init.rc script:
/data/local/custom.rc

The /data partition is not rebuilt on boot and is writable by default.

Don't want to hijack the bug report, but hey, it is my bug report :) :

Can the root partition have /cache as symlink to /data/cache and not as useless
directory (it sits on read-only filesystem) as it is now?

Original comment by skliarie@gmail.com on 21 Apr 2010 at 10:46

GoogleCodeExporter commented 9 years ago
Don't forget to "if [ -x /data/local/custom.rc ]" and eventually to add a "&" 
when
you execute it, or it might interfere with the end of the booting process...

Original comment by kewlcat...@gmail.com on 21 Apr 2010 at 11:33

GoogleCodeExporter commented 9 years ago
The shell that is supplied on AoF has no support for "if [" operator, so we 
should
find a different command to test for script presence. Post here once you do.

I see the workaround as a temporary workaround for light on-boot fixes and not
workhorse to run daemons or background running scripts.

Original comment by skliarie@gmail.com on 21 Apr 2010 at 1:37

GoogleCodeExporter commented 9 years ago
Hmmm... OK
I don't have my Freerunner with me right now and I can't check by myself, but 
maybe
we could use "test" (if it is present).

test -x /data/local/custom.rc && /data/local/custom.rc &

?

Original comment by kewlcat...@gmail.com on 21 Apr 2010 at 2:02

GoogleCodeExporter commented 9 years ago
I already checked the option and saw that there is no "test" binary on the AoF.

Original comment by skliarie@gmail.com on 21 Apr 2010 at 2:22

GoogleCodeExporter commented 9 years ago
Ouch !
Alright, if we can't check that it is executable, maybe we can just check if it 
is
present and "source" it in the current shell...
What about that ?

ls /data/local/custom.rc && . /data/local/custom.rc

I'm going to grab my Freerunner now and see how the rest of the init.rc is made 
and
which commands are available...

Original comment by kewlcat...@gmail.com on 21 Apr 2010 at 10:00

GoogleCodeExporter commented 9 years ago
There is not a normal shell available in init. A description of the init 
language is 
here: http://pdk.android.com/online-pdk/guide/bring_up.html#androidInitLanguage

Original comment by scarhill on 21 Apr 2010 at 11:33

GoogleCodeExporter commented 9 years ago
... or, since we have /system/bin/sh

/system/bin/ls /data/local/custom.rc && /system/bin/sh /data/local/custom.rc &

?
But judging from the init.rc script, it'not really what is expected inside this 
file...
This is one weird init file ! :-S

Original comment by kewlcat...@gmail.com on 21 Apr 2010 at 11:33

GoogleCodeExporter commented 9 years ago
It sounds like my change does not work, right?

this is what I did.

diff --git a/init.rc b/init.rc
index ca38eef..4f7bafa 100644
--- a/init.rc
+++ b/init.rc
@@ -21,7 +21,9 @@ loglevel 3
     mkdir /sdcard 0000 system system
     mkdir /system
     mkdir /data 0771 system system
-    mkdir /cache 0770 system cache
+    mkdir /data/cache 0770 system cache
+#    mkdir /cache 0770 system cache
+    ln -s /cache /data/cache
     mkdir /sqlite_stmt_journals 01777 root root
     mount tmpfs tmpfs /sqlite_stmt_journals size=4m

@@ -351,3 +353,5 @@ on property:init.svc.wpa_supplicant=stopped

 on property:init.svc.wpa_supplicant=restarting
     write /sys/bus/platform/drivers/s3c2440-sdi/bind s3c2440-sdi
+
+/data/local/custom.rc

Original comment by seder...@googlemail.com on 22 Apr 2010 at 8:54

GoogleCodeExporter commented 9 years ago
Judging from the link given by scarhill (at the same time as my last post...) 
you do
not have access to "ln" inside the init.rc script. You have to use "symlink" :
(...)
mkdir /data/cache 0770 system cache
#mkdir /cache 0770 system cache
symlink /data/cache /cache
(...)

BTW, thank yuo scarhill. I should've searched a little more before suggesting 
anything.

Original comment by kewlcat...@gmail.com on 22 Apr 2010 at 3:26

GoogleCodeExporter commented 9 years ago
try the latest weekly please

Original comment by seder...@googlemail.com on 22 Apr 2010 at 7:49

GoogleCodeExporter commented 9 years ago
Hello. Perhaps I have a stupid question but there is a problem with the running 
of
custom shell commands on boot.
I need to mount my sdcard with ext3 partition. 
manually: #adb shell mount -t ext3 /dev/block/mmcblk0p3 /sdcard
works correctly, but I need to run this command on boot

I have /data/local/custom.rc line in my /init.rc file

#cat /data/local/custom.rc
umount /sdcard
mount ext3 /dev/block/mmcblk0p3 /sdcard nosuid nodev

After booting, i don't have any changes. I tried to change init.rc file like:
http://discuz-android.blogspot.com/2008/01/step-by-step-to-createmodify-ramdiski
mg.html
but in init.rc there were no changes when I had instaled "android" on my 
freerunner.

Original comment by Shvets.E...@gmail.com on 24 Apr 2010 at 4:53

GoogleCodeExporter commented 9 years ago
I am not tracking weekly releases lately - using the phone as production one.
Have the fix been committed into stable (cupcake) release?

As my 2.5mm audio jack got broken (it thinks a headset is always plugged in) I 
need to fix alsa settings to work on built-in mic and speaker - excellent 
candidate for such on-boot operations:
alsa_amixer sset 'Amp Spk' on

Original comment by skliarie@gmail.com on 13 Nov 2010 at 8:35

GoogleCodeExporter commented 9 years ago
I marked this as invalid because it can't be done as described--see comment 
#12. Please enter separate bugs for the other issues mentioned in this thread.

Original comment by scarhill on 14 Nov 2010 at 9:42

GoogleCodeExporter commented 9 years ago
The provided link is broken, the working link is:
http://www.kandroid.org/android_pdk/bring_up.html

I am well aware that the shell is restricted, but the commands it allows to do 
are enough to do fixes described above.

Original comment by skliarie@gmail.com on 15 Nov 2010 at 11:25