[TOOL][BOOT SCRIPTS] bse

Search This thread

r3pwn

Inactive Recognized Developer
Jul 11, 2012
1,745
2,046
Lakeland, FL
r3pwn.com
Hello, all!

I have recently built a tool that allows users to more efficiently create and run scripts on boot.
These can be python scripts if you have python installed to your system (No, SL4A won't work. At least, not without some work). Usually though, they are bash or sh scripts.
They can be used to do various things, such as fix permissions every reboot, or things such as record a log of the time of every time you boot up your device, or other cool things.

I am currently looking into getting python packed into a flashable zip (lots of more fun with python scripts like showing a toast notification on boot).

To use bse's scripts executing feature, you must place the script you wish to execute under /system/etc/startup. You don't need to worry about chmodding it, there is an init script that does that already. For reference purposes, I recommend you read the contents of that init script (it's in /system/etc/startup).

To clarify, anyone who wants to build an automated installer for this, distribute some scripts, or distribute any modification to be, you have my full permission as long as you provide a link to this thread.

DOWNLOAD
https://docs.google.com/file/d/0ByulRvn_lJmbbnRfMG82Mm9Pb3c/edit?usp=docslist_api

INSTALLATION
- Just flash the zip file in the recovery of your choice


If you have any questions, feel free to ask. I'm sorry, this was written when I was tired (Not the program, the post)

Sent from my Nexus 7 using Tapatalk
 

r3pwn

Inactive Recognized Developer
Jul 11, 2012
1,745
2,046
Lakeland, FL
r3pwn.com
FAQ:
What does "bse" stand for?
If you were to run bse alone, you would see that it stands for "Boot Script Executer".

Is BSE open-sourced?
Almost. I lost the source code and I'm in the process of re-creating it from scratch.

Where is the open source repo?
It's at https://github.com/boot-script-executer. PM me with your Github email if you wish to contribute to BSE development or submit your bse scripts. (please tell me which one)


Sent from my Nexus 7 using Tapatalk
 
Last edited:

cybojenix

Retired Forum Mod / Retired Recognized Developer
Apr 7, 2012
801
1,864
nice idea

how about adding in a log wrapper to forward all output to the logcat

note: this is untested, but it should work
Code:
function logger() {
    # args:
      # $1 = message - the message you want to show
      # $2 = priority - optional, defaults to i. the priority you want to give the log message
    export LOG="/system/bin/log"
    tag="BSE_LOGGER"
    message=${1}
    priority="i"
    if [[ $2 ]]
    then
        options="vdiwe"
        if test "${options#*$2}" == "$options"
        then
            $LOG -p "e" -t "$tag" "invalid priority level: $2"
        else
            priority=$2
        fi
    fi
    $LOG -p "$priority" -t "$tag" "$message"
}

examples:
Code:
logger "this is a random message"
# I/BSE_LOGGER(15836): this is a random message
logger "another random message" d
# D/BSE_LOGGER(17393): another random message
logger "this message should give an error" t
# E/BSE_LOGGER(17395): invalid priority level: t 
# I/BSE_LOGGER(17396): this message should give an error
 
Last edited:

Maribou

Senior Member
Nov 29, 2012
565
625
Oklahoma City
This is freaking awesome r3. Good job bro.
*Starts slow clapping. Waiting for other people to join in.* ☺

Sent from my SAMSUNG-SGH-I337 using XDA Premium 4 mobile app
 

Ricky Divjakovski

Recognized Developer / Recognized Contributor
Feb 4, 2013
5,216
7,638
26
Sydney
nice idea

how about adding in a log wrapper to forward all output to the logcat

note: this is untested, but it should work
Code:
function logger() {
    # args:
      # $1 = message - the message you want to show
      # $2 = priority - optional, defaults to i. the priority you want to give the log message
    export LOG="/system/bin/log"
    tag="BSE_LOGGER"
    message=${1}
    priority="i"
    if [[ $2 ]]
    then
        options="vdiwe"
        if test "${options#*$2}" == "$options"
        then
            $LOG -p "e" -t "$tag" "invalid priority level: $2"
        else
            priority=$2
        fi
    fi
    $LOG -p "$priority" -t "$tag" "$message"
}

i like the thought of this!
 
  • Like
Reactions: cybojenix

eushaun99

Senior Member
Feb 8, 2013
2,014
970
23
Subang Jaya
Sorry if this sounds like a stupid question, but what's the difference between using init.d and your tool or even using script manager to run scripts at boot?

Sent from my GT-P7500 using Tapatalk
 

r3pwn

Inactive Recognized Developer
Jul 11, 2012
1,745
2,046
Lakeland, FL
r3pwn.com
Hehe. Funny story about this. All of its source code (There wasn't too much... Don't worry) was on my trusty (not really) old Kindle Fire HD, which I managed to brick. I will have to re-write the source (Again, I didn't really lose that much) and I'll make everything open-sourced (see 2nd post if you want to help contribute).




Thanks... I will try to see if I can implement that. If I have no sucess, you could try for yourself once I get everything re-written.
 

Publiuss

Senior Member
Jun 29, 2012
948
171
init.d triggered through the rom not the kernel, and it supports python scripts aswell

Hi
I didn't understand this answer...
This solution also relies on init.d. Apart from python interpreting, what's the thing that makes it more robust aganist init.d scripts?
If a Rom (it's kernel) does not or only via 3rd part apps supports init.d, there could be problems the same.
 

Ricky Divjakovski

Recognized Developer / Recognized Contributor
Feb 4, 2013
5,216
7,638
26
Sydney
Hi
I didn't understand this answer...
This solution also relies on init.d. Apart from python interpreting, what's the thing that makes it more robust aganist init.d scripts?
If a Rom (it's kernel) does not or only via 3rd part apps supports init.d, there could be problems the same.

what do you mean?
this doesnt rely on init.d, it is init.d.
this makes your device run init.d scripts WITHOUT the need to modify the kernel unlike some previous methods... but the scripts are called from /system/etc/startup/
the python script support is a featured currently in progress(from what i read)
 

r3pwn

Inactive Recognized Developer
Jul 11, 2012
1,745
2,046
Lakeland, FL
r3pwn.com
what do you mean?
this doesnt rely on init.d, it is init.d.
this makes your device run init.d scripts WITHOUT the need to modify the kernel unlike some previous methods... but the scripts are called from /system/etc/startup/
the python script support is a featured currently in progress(from what i read)

It does rely on init.d to call the "bse" binary, but I'm looking for an alternative method.

Sent from my Nexus 7 using Tapatalk
 

Publiuss

Senior Member
Jun 29, 2012
948
171
what do you mean?
this doesnt rely on init.d, it is init.d.
this makes your device run init.d scripts WITHOUT the need to modify the kernel unlike some previous methods... but the scripts are called from /system/etc/startup/
the python script support is a featured currently in progress(from what i read)

Mhhh...
I'm not so expert, but I saw some metods using /etc/install_recovery.sh to call (another script that calls) run-parts to execute all /etc/init.d scripts, don't know if it's a way to make init.d work despite kernel not supporting it...
This one uses init.d itself to call bse executable so... well if init.d is no way supported it won't work?
 

Ricky Divjakovski

Recognized Developer / Recognized Contributor
Feb 4, 2013
5,216
7,638
26
Sydney
Mhhh...
I'm not so expert, but I saw some metods using /etc/install_recovery.sh to call (another script that calls) run-parts to execute all /etc/init.d scripts, don't know if it's a way to make init.d work despite kernel not supporting it...
This one uses init.d itself to call bse executable so... well if init.d is no way supported it won't work?

justarchi has an init.d method where he calls the scripts from debuggerd!
 

Top Liked Posts

  • There are no posts matching your filters.
  • 10
    Hello, all!

    I have recently built a tool that allows users to more efficiently create and run scripts on boot.
    These can be python scripts if you have python installed to your system (No, SL4A won't work. At least, not without some work). Usually though, they are bash or sh scripts.
    They can be used to do various things, such as fix permissions every reboot, or things such as record a log of the time of every time you boot up your device, or other cool things.

    I am currently looking into getting python packed into a flashable zip (lots of more fun with python scripts like showing a toast notification on boot).

    To use bse's scripts executing feature, you must place the script you wish to execute under /system/etc/startup. You don't need to worry about chmodding it, there is an init script that does that already. For reference purposes, I recommend you read the contents of that init script (it's in /system/etc/startup).

    To clarify, anyone who wants to build an automated installer for this, distribute some scripts, or distribute any modification to be, you have my full permission as long as you provide a link to this thread.

    DOWNLOAD
    https://docs.google.com/file/d/0ByulRvn_lJmbbnRfMG82Mm9Pb3c/edit?usp=docslist_api

    INSTALLATION
    - Just flash the zip file in the recovery of your choice


    If you have any questions, feel free to ask. I'm sorry, this was written when I was tired (Not the program, the post)

    Sent from my Nexus 7 using Tapatalk
    4
    FAQ:
    What does "bse" stand for?
    If you were to run bse alone, you would see that it stands for "Boot Script Executer".

    Is BSE open-sourced?
    Almost. I lost the source code and I'm in the process of re-creating it from scratch.

    Where is the open source repo?
    It's at https://github.com/boot-script-executer. PM me with your Github email if you wish to contribute to BSE development or submit your bse scripts. (please tell me which one)


    Sent from my Nexus 7 using Tapatalk
    1
    nice idea

    how about adding in a log wrapper to forward all output to the logcat

    note: this is untested, but it should work
    Code:
    function logger() {
        # args:
          # $1 = message - the message you want to show
          # $2 = priority - optional, defaults to i. the priority you want to give the log message
        export LOG="/system/bin/log"
        tag="BSE_LOGGER"
        message=${1}
        priority="i"
        if [[ $2 ]]
        then
            options="vdiwe"
            if test "${options#*$2}" == "$options"
            then
                $LOG -p "e" -t "$tag" "invalid priority level: $2"
            else
                priority=$2
            fi
        fi
        $LOG -p "$priority" -t "$tag" "$message"
    }

    i like the thought of this!