• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Mods BootBuddy - Run Boot Scripts from SDcard (a safe alternative to init.d) [Root only]

Sepero

Linux Guru
Aug 26, 2010
963
594
(The OLD BootBuddy thread can be found here)

UPDATE:
Due to lack of time, BootBuddy has limited development support from me for now. BootBuddy was originally designed to work on a select number of LG phones (Motion, Spirit, L9) but may work for many others. The code is open source and anyone may contribute to development if they choose. I would be happy to feature your updates and I welcome support for new devices. Cheers.
https://github.com/Sepero/bootbuddy


INTRODUCTION:
Boot Buddy will allow you to run Linux shell scripts when your Android device is booting up. It will run your scripts early in the boot process, before the home screen appears.

The intended audience is generally intermediate to advanced users, and those who want to play with shell scripting on their device.


FEATURES:
BootBuddy is similar to init.d scripts, but with a core difference that it stores boot scripts on your SDcard instead of the internal system. This allows for several interesting enhancements. Feature listing-

  • Much more Safe than init.d. If you have a script that is malfunctioning, just boot with the sdcard out, and put the sdcard back in after your device reaches home screen. Your device is Saved, No Problem!
  • Boot Buddy is designed from the start to run scripts right from your SDcard. Just download any scripts to your boot_buddy_scripts directory and they're ready to run. (No more screwing around with permissions and files in your /system/etc/init.d/*)
  • SDcard storage allows you to copy a script to another device, or multiple devices easily.
  • Boot Buddy's author has several years of scripting and programming experience. It is streamlined, fast, and doesn't perform worthless functions like repeatedly logging the authors name and time.
  • Clear goals of making operation simple, intuitive, and clean.
  • If you're currently using an "init.d" solution, BootBuddy can integrate seamlessly with it.
  • If you try BootBuddy and you don't like it, the installer also works as an uninstaller for easy clean removal.
  • BootBuddy is Open Source GNU GPL. Open for anyone to modify and improve upon.
As a developer, I make software to operate the way I would want if I were an end user, because I actually do use it, and I am an end user like you.


REQUIREMENTS:




INSTALL:

  1. Start Script Manager, and allow/grant root access.
  2. Navigate to the bb_install.sh file.
  3. Tap on the file to show the menu options.
  4. At the top, highlight the "Su" icon.
  5. On the top-left, tap "Run".
The script will run quickly. It will automatically detect your sdcard location and create a folder on your sdcard named "boot_buddy_scripts". In that folder, you put the scripts you want to run at system boot. A log file will be kept at /data/boot_buddy.log

If you need your scripts to run in order, they are ordered by filename using the busybox "sort" program. They will run in alphabetical order using this format 0-9A-Za-z.


YOUR FIRST SCRIPTS: (OPTIONAL)
Here are a couple example scripts you may use.

The Android /system is normally mounted with read-only permissions by default. We will change that with the first script listed below. It will cause /system to be remounted to read-write permissions during boot.

The second script will create a file at every boot named /mnt/sdcard/sys_mount_info.txt. That txt file will give us information about how /system is currently mounted.

  1. Download the file 00rw_system.sh into your boot_buddy_scripts folder.
  2. Download the file 99sys_mount_info.sh into your boot_buddy_scripts folder.
  3. Reboot your phone.
That's it, you just installed 2 new scripts and had them run at boot. It's Really just that simple to add startup scripts to your system.

To verify they are running, use any text viewer to open the file /mnt/sdcard/sys_mount_info.txt. It may show more than one line of text. There should be a line similar to this:
/dev/block/(device specific text) /system (fstype) rw,(more text)

The rw means that /system was successfully remounted as read-write during boot.

At any time you can delete either script if you choose. Easy!


UNINSTALL:
If for any reason you find you don't want or don't like Boot Buddy, you can cleanly uninstall it using the installer bb_install.sh. These instructions are almost identical to installing. (All match the installation steps, except step 4)

  1. Start Script Manager, and allow/grant root access.
  2. Navigate to the bb_install.sh file.
  3. Tap on the file to show the menu options.
  4. ** Type --uninstall in the text area labeled Arguments.
  5. At the top, highlight the "Su" icon.
  6. On the top-left, tap "Run".
Boot Buddy will be uninstalled. It will not remove the contents of your boot_buddy_scripts folder. If you have an "init.d" system installed, it will cleanly remove only Boot Buddy parts and leave the rest.


ADVANCED NOTES:
Boot Buddy will Not cause harm to your system, but it may not work on custom roms. Also, it may fail to detect the real location of your SDcard. It requires that /system/etc/install-recovery.sh is run during the boot process, and that file will be created if it does not exist. Also the file /data/boot_buddy.sh will be created. The script /system/etc/install-recovery.sh will run /data/boot_buddy.sh. The script /data/boot_buddy.sh will run the scripts on your sdcard. The file /data/boot_buddy.log will log any script output.

For Windows and Mac users- If you download the installer to your pc first, do not edit the installer with a text editor. Your computer will add hidden markers at the ends of each line that will prevent the installer from running. If you want to edit it, you should do so on a Linux pc or directly on your Android device.

Tell us about your results!!! :)

BootBuddy source code: http://github.com/Sepero/bootbuddy
 
LIST OF USER SCRIPTS MADE SPECIFICALLY FOR BOOTBUDDY:
(Mention your script and get listed here)



Device specific scripts:








MAKING A NEW SCRIPT COMPATIBLE:

For maximum compatibility with BootBuddy your script should be able to run with the standard busybox shell, and simply have a file name in the following format-
NNaaaaa_aaaaa

NN- A 2 digit number like "00", to indicated how soon or late a script should run in relation to other scripts. If the internal sdcard mount location is moved, it should be done at the prefix "50". Your script must run as prefix "49" or earlier to access the sdcard at it's default location ("51" or later at the moved location). If you are unsure what to use, most general scripts will be safe with the digit prefix "10".

aaaaa_aaaaa- This is the name of the script. It should be in all lowercase, and may use letters, numbers, periods, and underscores. An underscore_ should be used to separate words. For example "10my_fancy_script_v1.5"
 
  • Like
Reactions: pmb116 and twogbsd
Upvote 0
This is fricken awesome. Once i get the concept of writing scripts and finding premade scripts i will totally utilize this .
My daily entertainment phone . Movies ,music browsing emails text.
Toss in a different sdcard and my phone is an agressive machine set for more serious functions.Within 2 minutes my playstation is nasa server

My new script wasnt coded properly crap, yank sd and everything is fine. I think this has far more value than people think
This is more for people that look at thier phone as laptop and not just a phone.
And i was never asked to pay for it.
 
Upvote 0
@funkyman
The .sh extension refers to "SHell script". Linux scripts often have this extension, but it's not 100% necessary. Scripts may have another extension, or no file extension at all and still be able to run just the same.

If the script creator says that the script will work with BootBuddy (or init.d), and the script is made for your device, then it should be safe.

Doing anything else is at your own risk.
 
  • Like
Reactions: funkyman
Upvote 0
rhino889a said:
Is there away to get an individual script loaded by bootbuddy to stall or delay?
Say i am trying to change a system setting but system overwrites what my bootbuddy script did.

Yes, you will want to write your code in this format

Code:
# Wrap the delayed code in a function so it doesn't stop other scripts.
delayed_code () {
    busybox sleep 10 # Waits for 10 seconds.
    ## The code you want to run after waiting ##
}

# The & sign tells it to run the function in the background so that other scripts can continue.
delayed_code &
 
Upvote 0
The BootBuddy script is located at /data/boot_buddy.sh

Feel free to edit it at your own risk. BootBuddy has it's own delay currently. Every 1 second it will check to see if the sdcard has been mounted. After the sdcard has been found as mounted, it will then proceed to run all the scripts in the boot_buddy_scripts folder.
 
Upvote 0
Thank you
And i wanted to add something about boot buddy that can be very valuable in the future

You can install BootBuddy now ,even if you have absolutley no intentention of using it

Next month you may have some issue with your phone

Maybe you dont have current backup and may lose valuable info if you unbrick
Maybe a little script can be run by bootbuddy at boot to correct the problem

Like this guy who installed a galaxy voice app that screwed his phone up.he installed as system app so reset wont fix

He will probably have to unbrick since he has no recovery

If he had bootbuddy ,a simpke
Mount system/app/galaxy whatever
Rm system/app/galaxy whatever

Or sometging like that i guess
 
Upvote 0
*FIXED*
I use Rom Toolbox Pro, and I had App2SD set to "external". If you use this program, or a similar app2sd program you must set it to "AUTOMATIC" or it will not work. I switched it to automatic, and the program installed flawlessly, without even needing a reset.

Left below for reference
_____________________
I spent a while messing around with BootBuddy to get it back to the way I wanted it to function, now I'm getting errors when I try to install apps, says I have no free memory.

Maybe move interal_fs to sdcard? (
 
  • Like
Reactions: Sepero
Upvote 0
Hello Everyone;

Well - I'm sorry I didn't see this thread sooner: it would have saved me a lot of time fighting the system.

After about 3 days worth of hacking around, my environment works the way I want it to and I got <crond> and <crontab> to work.

NOW:

o / and /system mount as read-write.

o tcsh starts up and reads the .tcshrc file.

o I can run cron jobs.

o my external memory card is known as sdcard1 instead of extSdCard.

regards,
tony
 
Upvote 0
Hi JPowers2112,
Due to lack of feedback on different phones, I'm going to have to discontinue support for BootBuddy. Sadly, bootbuddy is currently only expected to work with a few phones: (LG Motion 4G, LG Spirit, L9, and perhaps a few more LG phones on MetroPCS). This is due to some inconsistencies between device manufacturers.

With your phone, it unfortunately, sounds like the script isn't working properly. I recommend following the instructions to uninstall BootBuddy. As an alternative you may want to try installing the popular init.d solution on xda forums.

If you need further assistance on BootBuddy, please write on that thread. I am subscribed to both threads, so I will see your message over there.

BootBuddy didn't even install, so there's nothing to uninstall. I had the phone turned on overnight, and the script was still running.
 
Upvote 0
i been trying to get this running on my motion
But it wont execute scripts from my sd card
BB instaled fine. have 775 perms for bb folder on my external sd
but they wont execute. when i run the BB.sh i get Cant find sh applet
logs say Running the file but cant find .sh
Funny thing is i can run scripts directky from the sd card
I am running firmwarw F ,busybox 1.22.1,Gamwrheorys OC kernel
I tried modifying the mount file in Proc but it doesnt stick
Anybody have a clue?

it just not letting the system execute any of my files
 
Upvote 0
well i can execute the scripts directly from inside the boot buddy folder on my sd card
But have negative results at boot up
i even executed the install recovery.sh then i executed the script in /data
i also tried to execute the sxripts on my sd card through terminal emulator which told me Pernission Denied
Even though the sd folder and scripts show full permissions ,I am not able to execute them from the system
 
Upvote 0
Boot buddy doesn't require scripts to have executable permission.

Short explanation:
Boot buddy executes a new shell instance, and feeds the script into it.

Long explanation:
Sdcards usually do not support executable permissions, because they are vfat (windows fat32) filesystem. Fat32 filesystems do not recognize executable flags. On Windows, anything can be executable if you just name it *.exe. For Android (Linux), special mounting is required to allow executing files (and it would result in every file on the sdcard becoming executable). Because of this, it's just easier to execute a new busybox shell and give it the script to read.

Hopefully that answers some questions for ya. Best of luck getting it resolved.
 
Upvote 0
on mt motion
copied sh from bin pasted in xbin
removed (busybox) from (busybox sh) lines from the data/boot_buddy script
changed the log to go to the sdcard
works great

then i moved the data/boot_buddy.sh to my bin folder
remived .sh from boot_buddy.sh
then i changed install_recovery.sh lines to this

(system/bin/boot_buddy)

bootbuddy no longer exists in data

now i have gametheorys kernel on my motion it has sysinit as a boot service
so i use it to exec bootbuddy instead of install_recovery_sh

now i am going to see if i can add run parts and logwrapper to view script exec results in logcat
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones