[Q] edit init.rc to run shell scripts on boot (help urgent!l - Android Q&A, Help & Troubleshooting

I've added the following lines into init.rc
"service sysinit /system/bin/logwrapper /system/xbin/busybox run-parts /system/etc/init.d"
My script is created inside the init.d directory.
#!/system/bin/sh
echo "2048" > /sys/devices/virtual/bdi/179:0/read_ahead_kb
Actually, the above action is worked. But when I have added one more script below the echo "2048... script, the problem was come.
( echo "1337" > /system/etc/init.d/gg.txt) p.s. gg.txt is not existed at the beginning
So, finally read_ahead_kb file has changed, but the gg.txt hasn't been created.
Can any one provide the reason and the solution to me?? Emergent! Thanks a lot!!

Or is it necessary for me to add ";" symbol at the end of each script?
If I want to use an infinity loop's script on boot (while : do xxxx done )
is it possible to do so? And how? Thanks

Any body can help?

No one??

hades94720 said:
No one??
Click to expand...
Click to collapse
use double >>
echo 11111 >> abc.txt
echo 2222 >> abc.txt

Related

My update for AIO Automatic Installation Script

Hello, Im useing this script http://forum.xda-developers.com/showthread.php?t=951274 to install JIT, DualTouch, etc.
I have some update for .sh script.
In JIT installation part:
Code:
echo "Backing up build.prob file"
busybox cp -f /system/build.prop /system/build.prop.stock
echo "Copying build.prop to /system/"
busybox cp -f data/jit/build.prop /system/build.prop
Here script rename system build.prop file to build.prop.stock and copy new build.prop from script folder to system.
And in JIT deinstallation part:
Code:
echo "Copying libraries and build.prop to /system/"
...
busybox cp -f data/jit/disable/build.prop /system/build.prop
And here script copy new build.prop from script folder to system.
BUT!
In deinstallation we need to get back our stock build.prop what was renamed in installation part!
So, i suggest to change
Code:
busybox cp -f data/jit/disable/build.prop /system/build.prop
to
Code:
busybox mv -f system/build.prop.stock system/build.prop
to rename build.prop.stock to build.prop.
And why did we copy/past this build.prop files? Why we cant copy stock build.prop and edit it this way:
Code:
echo "#DEVICE_PROVISIONED=1" >> /system/build.prop
echo "dalvik.vm.heapsize=30m" >> /system/build.prop
echo "#kernel.log=default" >> /system/build.prop
echo "dalvik.vm.execution-mode=int:jit" >> /system/build.prop
What do you think?
And sorry, I cant post this to Development forum because I have < 10 posts.
Iam searching in Google for help and so i find your Post here.
Maybe u can help me a bit.
I have a GalaxyNexus.
I have a Build.prop with and one without Tablet Mode.
I like to use sometimes TabletMode and sometimes not.
I think with a Script like u use here i can change what build.prop to use.
Lets say i have the "build.prop" with TabletMode and a "build.prop.stock" without that Mode.
How can i make it possible to activate the .stock and dissable the TabletMode. And then again the other way arround. ???

[Q] Revolution HD add init.d script

Hi all,
I have a problem with the rom in the subject, the headphone amplifier level is too high for me and I want to set a lower value to it.
I created this script:
Code:
#!/system/bin/sh
echo 1 > /sys/devices/virtual/misc/scoobydoo_sound/headphone_eq
echo 40 > /sys/devices/virtual/misc/scoobydoo_sound/headphone_amplifier_level
I have saved it in the /system/etc/init.d/ folder, I have set user and group (root:shell) and permissions (755) like the other scripts in that folder but the script simply isn't started at boot time!
at the end of the file /system/etc/init.post_boot.sh there are these lines:
Code:
# Execute /system/etc/init.d scripts on boot
chgrp -R 2000 /system/etc/init.d
chmod -R 777 /system/etc/init.d
/system/xbin/busybox run-parts /system/etc/init.d
log -p i -t ARHD "init.d support activated"
;;
what I need to do to allow the system to start my script?
thank you!
k4po said:
Hi all,
I have a problem with the rom in the subject, the headphone amplifier level is too high for me and I want to set a lower value to it.
I created this script:
Code:
#!/system/bin/sh
echo 1 > /sys/devices/virtual/misc/scoobydoo_sound/headphone_eq
echo 40 > /sys/devices/virtual/misc/scoobydoo_sound/headphone_amplifier_level
I have saved it in the /system/etc/init.d/ folder, I have set user and group (root:shell) and permissions (755) like the other scripts in that folder but the script simply isn't started at boot time!
at the end of the file /system/etc/init.post_boot.sh there are these lines:
Code:
# Execute /system/etc/init.d scripts on boot
chgrp -R 2000 /system/etc/init.d
chmod -R 777 /system/etc/init.d
/system/xbin/busybox run-parts /system/etc/init.d
log -p i -t ARHD "init.d support activated"
;;
what I need to do to allow the system to start my script?
thank you!
Click to expand...
Click to collapse
actually it seems that no one file inside that directory is started on boot! also the file that already were into the directory!
Ok a developer told me that init.d support will be available from next release!
I'll try something different
Sent from my GT-I9300 using xda app-developers app

NEED HELP

I have some scripts in my init.d folder, but when i check it on init.d log file.. it doesn't work. I do same as tutorial that i got here.. but it said "nonexistent directory" . Is there anyone know why?
I still confused because two of my scripts (zipalign & loopy_smoothness) are working.. but not for the other..
Here one of my tweaks :
#!system/bin/sh
echo "64" > /sys/module/lowmemorykiller/parameters/cost
echo "0,1,2,4,9,15" > /sys/module/lowmemorykiller/parameters/minfree
echo "0" > /sys/module/lowmemorykiller/parameters/debug_level
The log file said " nonexistent directory "..
Thanks before.. and sorry for my bad english..
Sent from my Hisense E-860 using Tapatalk 2
Looks like you have a typo on line 1.
Should start
#!/system/bin/sh
Sent from my HTC One X+ using Tapatalk 2
albraine said:
I have some scripts in my init.d folder, but when i check it on init.d log file.. it doesn't work. I do same as tutorial that i got here.. but it said "nonexistent directory" . Is there anyone know why?
I still confused because two of my scripts (zipalign & loopy_smoothness) are working.. but not for the other..
Here one of my tweaks :
#!system/bin/sh
echo "64" > /sys/module/lowmemorykiller/parameters/cost
echo "0,1,2,4,9,15" > /sys/module/lowmemorykiller/parameters/minfree
echo "0" > /sys/module/lowmemorykiller/parameters/debug_level
The log file said " nonexistent directory "..
Thanks before.. and sorry for my bad english..
Sent from my Hisense E-860 using Tapatalk 2
Click to expand...
Click to collapse
try this and make sure about script permissions
Code:
#!/system/bin/sh
echo "64" > /sys/module/lowmemorykiller/parameters/cost;
echo "0,1,2,4,9,15" > /sys/module/lowmemorykiller/parameters/minfree;
echo "0" > /sys/module/lowmemorykiller/parameters/debug_level;
you can also add #!/system/xbin/busybox/sh instead of #!/system/bin/sh
No.
I'm not using tipo..
I'm on hisense E-860
Thanks..
I just saw this post..
.
My init.d script is working now

[HOW TO]Adding init.d support

This is a quick how to on how to add init.d support to your device. I am posting this as i have had alot of intrest on the subject.
This method has been tested on the n7000 with a rooted rom and philz kernel if you test on other devices and it works(or does not work) please let me know and i will build a compatibility list
you are doing this at your own risk so do not complain when you mess it up.
use this method to test the init.d support if successful then just add your init.d scripts to the init.d folder.
1. Download the file from here: 00test.zip
2. Extract the file, you will get a file named 00test. DO NOT flash!
3. Paste it into /etc/init.d. If there is no init.d folder, most probably you DO NOT have init.d support. However, if you still wanna try, just create the folder named "init.d"
4. Change the permissions of the init.d folder and 00test into rwxrwxrwx.
5. Reboot.
6. If you see a file named Test.log in /data, you have init.d support. If not, you will have to run Uni-init, Term-init or Zip-init.
at step 3 you should have init.d support if you have a rooted rom and a kernel which has init.d support.
if i have helped you please hit thanks button. :good:​
Uhhh, this doesn't tell you at all how to add init.d support. It just tells you how to test and see if you already have init.d support. Thread title is misleading.
1. add this line
exec /system/bin/sysinit
in init.rc (in ramdisk) ,then compile boot.img
2.flash the boot.img
3.extract sysinit (from the attached file) and copy in /system/bin/ with permission rwxr-xr-x (755)
4.reboot
or you can cook it with dsixda kitchen ... ,
just use this apk called uni init.d it work well on my device ...
here is the link http://forum.xda-developers.com/showthread.php?t=1933849
Or, if you really want to learn a little, you can get the VTS (Virtual Ten Studio) from XDA Developers (free), Do a boot project, and add the following in init.rc
Code:
run-parts /etc/init.d
service sysinit /system/bin/logwrapper /system/xbin/busybox run-parts /system/etc/init.d
disabled
oneshot
Then re-compile your boot image and flash or fastboot it.
MD
There is not init.rc in my boot.img ! What can I do now?
PHP:
# Adds kernel's Init.d
INITD() {
if [[ -e "/PATH/TO/init.rc" ]]; then
sed -i -e '0,/class_start /s//start sysinit\n\n class_start /' "/PATH/TO/init.rc"
sed -i -e 's/service media /service sysinit \/system\/bin\/logwrapper \/system\/xbin\/busybox run-parts \/system\/etc\/init.d\n disabled\n oneshot\n\nservice media /' "/PATH/TO/init.rc"
cd "$(dirname "$0")"
cd ..
# Call other methods
MOUNT
INSTALL_RECOVERY
SYSINT
PERMISSIONS
else
ui_print "ERROR, missing needed contents from the ramdisk?!";
rm -rf "$ACTIVE_PROJECT/TEMP"
return 1
fi
}
# Mount system as R/W
MOUNT() {
busybox mount -o remount,rw -t auto /system
}
# Build and write to install-recovery.sh
INSTALL_RECOVERY() {
if [ -e /system/etc/install-recovery.sh ]
then
busybox echo "# init.d support" >> /system/etc/install-recovery.sh
busybox echo "busybox run-parts /system/etc/init.d/" >> /system/etc/install-recovery.sh
busybox echo "" >> /system/etc/install-recovery.sh
busybox awk '!x[$0]++' /system/etc/install-recovery.sh > /tmp/install-recovery.sh
busybox cat /tmp/install-recovery.sh > /system/etc/install-recovery.sh
busybox echo "" >> /system/etc/install-recovery.sh
else
cat > /system/etc/install-recovery.sh
busybox echo "#!/system/bin/sh" >> /system/etc/install-recovery.sh
busybox echo "# init.d support" >> /system/etc/install-recovery.sh
busybox echo "busybox run-parts /system/etc/init.d/" >> /system/etc/install-recovery.sh
busybox echo "" >> /system/etc/install-recovery.sh
fi
}
# Build and write to systint
SYSINT() {
if [ -e /system/bin/sysint ]
then
busybox echo "#!/system/bin/sh" >> /system/bin/sysint
busybox echo "# init.d support" >> /system/bin/sysint
busybox echo "" >> /system/bin/sysint
busybox echo "export PATH=/sbin:/system/sbin:/system/bin:/system/xbin" >> /system/bin/sysint
busybox echo "/system/bin/logwrapper run-parts /system/etc/init.d" >> /system/bin/sysint
busybox echo "" >> /system/bin/sysint
busybox awk '!x[$0]++' /system/bin/sysint > /tmp/sysint
busybox cat /tmp/sysint > /system/bin/sysint
busybox echo "" >> /system/bin/sysint
else
busybox echo "#!/system/bin/sh" > /system/bin/sysint
busybox echo "# init.d support" >> /system/bin/sysint
busybox echo "" >> /system/bin/sysint
busybox echo "export PATH=/sbin:/system/sbin:/system/bin:/system/xbin" >> /system/bin/sysint
busybox echo "/system/bin/logwrapper run-parts /system/etc/init.d" >> /system/bin/sysint
busybox echo "" >> /system/bin/sysint
fi
}
# Set permissions accordingly
PERMISSIONS() {
busybox chmod 755 /system/etc/install-recovery.sh
busybox chown 0.0 /system/etc/install-recovery.sh
busybox chmod 755 /system/bin/sysint
busybox chown 0.2000 /system/bin/sysint
}
# Start process here
INITD
Here is a small snippet from my script that I use with MyMinds_Kernel_Swap for flashing in my recovery to pull my boot.img using dd, unpack using my unmkbootimg binary, edit init.rc and amongst other things in /system, swap kernel, build ramdisk with mkbootfs, build boot.img with mkbootimg, and flash using dd. Pretty much like AnyKernel, but I wrote my own because AnyKernel just didn't work.
Anyways, here you go. Remember, some adjustments are needed more in less but should give you an idea for init.rc support. If you wish to see my entire script then just look up my github and find my repo as named above.

How to get init.d support on MIUI 7?

Hey everyone,
I've been failing miserably to get init.d support on the MIUI 7 developer roms for the Redmi Note 2 and tried every possible thing from this thread on XDA: http://forum.xda-developers.com/showthread.php?t=1933849. I found a couple of posts regarding init.d support on en.miui.com as well, but they are all targeted at MIUI 5/6. Is there anyone who can help me out with this? I would love to get the support to prevent data from leaking at boot (firewall).
Thanks!
Edit 24/01: Flashed Namaless' MIUI Speed MOD which enabled init.d support. Scripts are being executed correctly on boot.
Smiui ?
Have you tried the smiui rom ? http://www.smiui.net/
It works OK on my Redmi Note 2 Prime and claims to have init.d support although I haven't used this feature yet.
Discussed here
http://forum.xda-developers.com/redmi-note-2/development/rom-smiui-rom-kitchen-major-xiaomi-t3225567
I'm using Miui 7 5.11.19
elaurens said:
Hey everyone,
I've been failing miserably to get init.d support on the MIUI 7 developer roms for the Redmi Note 2 and tried every possible thing from this thread on XDA: http://forum.xda-developers.com/showthread.php?t=1933849. I found a couple of posts regarding init.d support on en.miui.com as well, but they are all targeted at MIUI 5/6. Is there anyone who can help me out with this? I would love to get the support to prevent data from leaking at boot (firewall).
Thanks!
Click to expand...
Click to collapse
Pal, this 'switcher' made the magic for me, https://play.google.com/store/apps/details?id=com.broodplank.initdtoggler&hl=it
Redmi Note 2 Prime Dev EU 5.11.1 here
fourlans said:
Have you tried the smiui rom ? http://www.smiui.net/
It works OK on my Redmi Note 2 Prime and claims to have init.d support although I haven't used this feature yet.
Discussed here
http://forum.xda-developers.com/redmi-note-2/development/rom-smiui-rom-kitchen-major-xiaomi-t3225567
I'm using Miui 7 5.11.19
Click to expand...
Click to collapse
Thanks for the tip. Gonna use that as a last resort as I'd rather just run the Chinese developer rom + init.d support (don't really need any of the other features which smiui offers).
oldslowdiver said:
Pal, this 'switcher' made the magic for me, https://play.google.com/store/apps/details?id=com.broodplank.initdtoggler&hl=it
Redmi Note 2 Prime Dev EU 5.11.1 here
Click to expand...
Click to collapse
Installed on 5.11.19 and enabled AfWall+ data leaking fix (script on startup), but it's still not running. Can you tell me which script you managed to get running after enabling init.d through the toggler app?
Thx.
elaurens said:
Installed on 5.11.19 and enabled AfWall+ data leaking fix (script on startup), but it's still not running. Can you tell me which script you managed to get running after enabling init.d through the toggler app?
Thx.
Click to expand...
Click to collapse
These ones:
Strict min free
echo "2048,3072,6144,15360,17920,20480" > /sys/module/lowmemorykiller/parameters/minfree
VM Management
echo "4096" > /proc/sys/vm/min_free_kbytes
echo "0" > /proc/sys/vm/oom_kill_allocating_task;
echo "0" > /proc/sys/vm/panic_on_oom;
echo "0" > /proc/sys/vm/laptop_mode;
echo "0" > /proc/sys/vm/swappiness
echo "50" > /proc/sys/vm/vfs_cache_pressure
echo "90" > /proc/sys/vm/dirty_ratio
echo "70" > /proc/sys/vm/dirty_background_ratio
Normalize Sleeper
mount -t debugfs none /sys/kernel/debug
echo NO_NORMALIZED_SLEEPER > /sys/kernel/debug/sched_features
---------- Post added at 06:17 PM ---------- Previous post was at 06:12 PM ----------
oldslowdiver said:
These ones:
Strict min free
echo "2048,3072,6144,15360,17920,20480" > /sys/module/lowmemorykiller/parameters/minfree
VM Management
echo "4096" > /proc/sys/vm/min_free_kbytes
echo "0" > /proc/sys/vm/oom_kill_allocating_task;
echo "0" > /proc/sys/vm/panic_on_oom;
echo "0" > /proc/sys/vm/laptop_mode;
echo "0" > /proc/sys/vm/swappiness
echo "50" > /proc/sys/vm/vfs_cache_pressure
echo "90" > /proc/sys/vm/dirty_ratio
echo "70" > /proc/sys/vm/dirty_background_ratio
Normalize Sleeper
mount -t debugfs none /sys/kernel/debug
echo NO_NORMALIZED_SLEEPER > /sys/kernel/debug/sched_features
Click to expand...
Click to collapse
You know what.. they actually won't work! I was sure they did, I just checked, and they actually don't. Still, Init.d is enabled.. wtf?
oldslowdiver said:
These ones:
Strict min free
echo "2048,3072,6144,15360,17920,20480" > /sys/module/lowmemorykiller/parameters/minfree
VM Management
echo "4096" > /proc/sys/vm/min_free_kbytes
echo "0" > /proc/sys/vm/oom_kill_allocating_task;
echo "0" > /proc/sys/vm/panic_on_oom;
echo "0" > /proc/sys/vm/laptop_mode;
echo "0" > /proc/sys/vm/swappiness
echo "50" > /proc/sys/vm/vfs_cache_pressure
echo "90" > /proc/sys/vm/dirty_ratio
echo "70" > /proc/sys/vm/dirty_background_ratio
Normalize Sleeper
mount -t debugfs none /sys/kernel/debug
echo NO_NORMALIZED_SLEEPER > /sys/kernel/debug/sched_features
---------- Post added at 06:17 PM ---------- Previous post was at 06:12 PM ----------
You know what.. they actually won't work! I was sure they did, I just checked, and they actually don't. Still, Init.d is enabled.. wtf?
Click to expand...
Click to collapse
Yeah see.. that's my problem with it I can't find the thread back on en.miui.com's forum, but I read earlier today that MIUI uses another way to launch scripts on startup. No further explanation was given though. Weird, maybe I should try the sMIUI ROM and see what it gives.
Enable Init.d on Redmi Note 2
elaurens said:
Yeah see.. that's my problem with it I can't find the thread back on en.miui.com's forum, but I read earlier today that MIUI uses another way to launch scripts on startup. No further explanation was given though. Weird, maybe I should try the sMIUI ROM and see what it gives.
Click to expand...
Click to collapse
Okay, I found the thread you mentioned on MIUI's website (http://en.miui.com/thread-129336-1-1.html), but you need to correct the path as it follows in Terminal Emulator:
Type :
su
sh /storage/sdcard1/term-init.sh
You have to place the term-init.sh inside the internal SD card in this case, download file here https://www.androidfilehost.com/?w=...5e497fa2bc98ce82437cb8cbfbdb4e56c73c1dd621ead
Anyway, if it works, it should create a Test.log file in /data, but it won't
Try your luck
oldslowdiver said:
Okay, I found the thread you mentioned on MIUI's website (http://en.miui.com/thread-129336-1-1.html), but you need to correct the path as it follows in Terminal Emulator:
Type :
su
sh /storage/sdcard1/term-init.sh
You have to place the term-init.sh inside the internal SD card in this case, download file here https://www.androidfilehost.com/?w=...5e497fa2bc98ce82437cb8cbfbdb4e56c73c1dd621ead
Anyway, if it works, it should create a Test.log file in /data, but it won't
Try your luck
Click to expand...
Click to collapse
Cool of you to follow this up The term-init.sh script actually comes from XDA and this is its original thread: http://forum.xda-developers.com/showthread.php?t=1933849. I copied the script to the internal SD card and executed it (with different versions of busybox), the script ran successfully (/system/etc/init.d and other files are created, permissions set correctly), but that Test.log file isn't being created in /data after a reboot. Of course, when I run the following command manually from a terminal, it does create the Test.log file: /system/xbin/busybox run-parts /system/etc/init.d. So for some reasons, the scripts in /system/etc/init.d/ aren't being executed at boot (and my knowledge is too restricted to troubleshoot this further :/)
elaurens said:
Cool of you to follow this up The term-init.sh script actually comes from XDA and this is its original thread: http://forum.xda-developers.com/showthread.php?t=1933849. I copied the script to the internal SD card and executed it (with different versions of busybox), the script ran successfully (/system/etc/init.d and other files are created, permissions set correctly), but that Test.log file isn't being created in /data after a reboot. Of course, when I run the following command manually from a terminal, it does create the Test.log file: /system/xbin/busybox run-parts /system/etc/init.d. So for some reasons, the scripts in /system/etc/init.d/ aren't being executed at boot (and my knowledge is too restricted to troubleshoot this further :/)
Click to expand...
Click to collapse
Exactly. And I found here http://en.miui.com/thread-99174-1-1.html you may edit Build.prop and add
sys.initd = 1
to enable Init.d scripts at boot, but, again, it won't work. So, if anyone finds a solution, please, share.
oldslowdiver said:
Exactly. And I found here http://en.miui.com/thread-99174-1-1.html you may edit Build.prop and add
sys.initd = 1
to enable Init.d scripts at boot, but, again, it won't work. So, if anyone finds a solution, please, share.
Click to expand...
Click to collapse
Haha. Are you oldmyself on the official MIUI forum who gave me the exact same reply in this thread?
elaurens said:
Haha. Are you oldmyself on the official MIUI forum who gave me the exact same reply in this thread?
Click to expand...
Click to collapse
heheheheh small world, it's me.
oldslowdiver said:
heheheheh small world, it's me.
Click to expand...
Click to collapse
Just so you know, I've got init.d support and scripts being executed on boot thanks to @Namaless' MIUI speed mod. I'm currently running the latest version (v.1.19) and AfWall's firewall rules are being applied on boot. Big thanks to him for that

Categories

Resources