FORUMS

OnePlus Addresses Reservation List Cheating

Jake Cooper figured out how to bump his place up on OnePlus’ reservation list and … more

OnePlus 2 Benchmark Scores Show Its Muscle

This video by FoneArena contains all the popular benchmarks being tested on the OnePlus 2, … more

Sony’s Emergence in The Middle: Is The Price Right?

Sony’s Electronics Division is not in its best days, and its smartphone … more

HTC Delivering Ads Straight to Sense Home

HTC’s 2015 has been a year marked by a desperate search for revenue.The HTC One M9 … more

[HOW-TO] Run commands and persist settings after reboot - Updated

52 posts
Thanks Meter: 84
 
By JoshMiers, Member on 6th January 2011, 12:22 AM
Post Reply Subscribe to Thread Email Thread
Here is an easy way to run commands after each boot.

In the init.rc file, the file /system/bin/clrbootcount.sh always gets run after a successful boot. Since it isn't trivial to change the init.rc file, we will use clrbootcount.sh to run commands after a boot. Since people are having issues with modifying clrbootcount.sh, we will choose a safer method.

clrbootcount.sh will always attempt to call /data/boot_complete_hook.sh, which doesn't exit. We are going to create this file and use that to run commands.

Create a file named boot_complete_hook.sh with the following contents (On Windows, use Notepad++):
Code:
#!/system/bin/sh
##################################################################################
#
# File          boot_complete_hook.sh
# Description	Run any commands that you want to be run after boot
#
## 
setprop persist.service.mount.umsauto 0
echo 68000,1024/70/200/40,600/10/11/10 > /sys/devices/omapdss/display0/timings
Save and close.

Now, execute the following commands to put the file on your nook:
Code:
adb push boot_complete_hook.sh /data/boot_complete_hook.sh
adb shell chmod 755 /data/boot_complete_hook.sh
Note:
Before you reboot verify that the file will run properly. Open up a shell via adb shell. Inside that run the following:
Code:
setprop persist.service.mount.umsauto 1
getprop persist.service.mount.umsauto
You should see 1 as the output. Now run:
Code:
sh /system/bin/clrbootcount.sh
You should see an output similar to:
Code:
4+0 records in
4+0 records out
4 bytes transferred in 0.010 secs (400 bytes/sec)
Now run:
Code:
getprop persist.service.mount.umsauto
If 0 is printed out, exit the shell.

If 0 is not printed out, something went wrong and the file will not be run properly on the next boot. If you do reboot in this state 8 times, the boot count won't be reset and you will hit the factory reset. While you are trying to get the script working, you could always manually reset the boot count by executing (from a shell):

Code:
dd if=/dev/zero of=/rom/devconf/BootCnt bs=1 count=4

Now reboot:

Code:
adb shell reboot
As you are rebooting, run:
Code:
adb shell getprop persist.service.mount.umsauto
It will return 1 since the init.rc file sets it to 1 explicitly. However, once you are fully booted it will return 0.
Last edited by JoshMiers; 6th January 2011 at 06:07 PM.
The Following 3 Users Say Thank You to JoshMiers For This Useful Post: [ View ]
 
 
6th January 2011, 01:12 AM |#2  
>DARKMAN<'s Avatar
Senior Member
Flag Chisago City, MN
Thanks Meter: 22
 
More
Didn't work for me.
6th January 2011, 01:36 AM |#3  
docfreed's Avatar
Senior Member
Thanks Meter: 152
 
More
Quote:
Originally Posted by JoshMiers

Here is an easy way to run commands after each boot.

In the init.rc file, the file /system/bin/clrbootcount.sh will always gets run after a successful boot. Since it isn't trivial to change the init.rc file, we will use clrbootcount.sh to run commands after a boot.

Do:

Code:
adb pull /system/bin/clrbootcount.sh .
Open the file (on Windows, don't use Notepad) and you should see:
Code:
#!/system/bin/sh
##################################################################################
#
# File          clrbootcount.sh
# Description	Clear the bootcount variable to 0 on successful boot
#
## 
# Run potential hook first.
/data/boot_complete_hook.sh
# Zero the boot count
dd if=/dev/zero of=/rom/devconf/BootCnt bs=1 count=4
Add the following to the end of the file:
Code:
#run other commands
setprop persist.service.mount.umsauto 0
Save and close.

Now, execute the following commands to put the file back on your nook:
Code:
adb shell mount -o rw,remount -t ext2 /dev/block/mmcblk0p5 /system 
adb push clrbootcount.sh /system/bin/clrbootcount.sh
adb shell chmod 755 /system/bin/clrbootcount.sh
adb shell mount -o ro,remount -t ext2 /dev/block/mmcblk0p5 /system 
adb shell reboot
As you are rebooting, run:
Code:
adb shell getprop persist.service.mount.umsauto
It will return 1 since the init.rc file sets it to 1 explicitly. However, once you are fully booted it will return 0.

Wouldn't this screw up the 8X "back to stock firmware" sequence since that depends on having the boot counter increment up to 8?
6th January 2011, 03:30 AM |#4  
OP Member
Thanks Meter: 84
 
More
Quote:
Originally Posted by docfreed

Wouldn't this screw up the 8X "back to stock firmware" sequence since that depends on having the boot counter increment up to 8?

The script file is already there and already being called after each successful boot. The 8x boot counter logic happens with 8 failed boots. Regardless, the instructions just show you how to append a custom command to be run after the stock commands run, no other booting logic is affected.

Quote:
Originally Posted by >DARKMAN<

Didn't work for me.

What didn't work? Run the following and paste your output:
Code:
adb shell cat /system/bin/clrbootcount.sh
Code:
adb shell ls -l /system/bin/clrbootcount.sh
6th January 2011, 12:12 PM |#5  
Senior Member
Flag Central Kentucky
Thanks Meter: 1,160
 
More
Awesome, thanks for the tip! Been wondering how to put in my own stuff into the init, I'd love to modify the path but I suspect this won't be the way, but regardless it's good info.

BTW, I have found that disabling this USM property seems to disable the SD card automounting but the Nook itself might still automount... But that's for another thread I suppose
6th January 2011, 01:43 PM |#6  
Senior Member
Thanks Meter: 59
 
More
Worked perfectly

This is exactly what I was looking for.

Thanks

Sent from my LogicPD Zoom2
6th January 2011, 05:40 PM |#7  
OP Member
Thanks Meter: 84
 
More
There seems to be a little confusion over at the refresh rate thread http://forum.xda-developers.com/showthread.php?t=901294.


To be explicit, if you want to disable auto-mounting as well as change the refresh rate, you would edit clrbootcount.sh to have the following contents:
Code:
#!/system/bin/sh
##################################################################################
#
# File          clrbootcount.sh
# Description	Clear the bootcount variable to 0 on successful boot
#
## 
# Run potential hook first.
/data/boot_complete_hook.sh
# Zero the boot count
dd if=/dev/zero of=/rom/devconf/BootCnt bs=1 count=4
#run other commands
setprop persist.service.mount.umsauto 0
echo 68000,1024/70/200/40,600/10/11/10 > /sys/devices/omapdss/display0/timings
If you don't want to disable auto-mounting, just remove the line with
Code:
setprop persist.service.mount.umsauto 0
6th January 2011, 07:38 PM |#8  
>DARKMAN<'s Avatar
Senior Member
Flag Chisago City, MN
Thanks Meter: 22
 
More
I ran what was posted and it still returns 1.

Sent from my HAXSUNG Moment
6th January 2011, 08:12 PM |#9  
Member
Thanks Meter: 33
 
More
Quote:
Originally Posted by JoshMiers

What didn't work? Run the following and paste your output:

Code:
adb shell cat /system/bin/clrbootcount.sh
Code:
adb shell ls -l /system/bin/clrbootcount.sh

Screen shot attached (1.0.1 Auto-Nooter 2.12.25).
Attached Thumbnails
Click image for larger version

Name:	adb.jpg
Views:	107
Size:	64.8 KB
ID:	482296  
Last edited by jleecong; 6th January 2011 at 08:14 PM.
7th January 2011, 01:57 AM |#10  
>DARKMAN<'s Avatar
Senior Member
Flag Chisago City, MN
Thanks Meter: 22
 
More
# cat /system/bin/clrbootcount.sh
cat /system/bin/clrbootcount.sh
#!/system/bin/sh
################################################## ##############################
##
#
# File clrbootcount.sh
# Description Clear the bootcount variable to 0 on successful boot
#
##
# Run potential hook first.
/data/boot_complete_hook.sh
# Zero the boot count
dd if=/dev/zero of=/rom/devconf/BootCnt bs=1 count=4
#

# ls -l /system/bin/clrbootcount.sh
ls -l /system/bin/clrbootcount.sh
-rwxr-xr-x root root 338 2011-01-06 19:50 clrbootcount.sh
#
8th January 2011, 06:25 AM |#11  
>DARKMAN<'s Avatar
Senior Member
Flag Chisago City, MN
Thanks Meter: 22
 
More
edit double post oops
Last edited by >DARKMAN<; 8th January 2011 at 06:34 AM.

Read More
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes