Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Customizing the b2g.sh script

On the phone, the b2g application (which provides the Firefox OS APIs among other things) is started through the /system/bin/b2g.sh script. You can customize this script to change the behavior of Firefox OS, and this article explains how.

Set environment variables

If you just want to set an environment variable for a single run of B2G, then you can do the following:

adb shell stop b2g
adb shell "export ENV_VAR=value && /system/bin/b2g.sh"

If you want to use the same environment variables all of the time, then you can edit b2g.sh, as described in the next section.

Editing b2g.sh

For debugging, you may want to set environment variables to get logging information or to otherwise affect how the b2g program runs. You can do this by editing the b2g.sh script. There aren't any tools included on the phone to edit the file in place, so you'll need to copy it to your computer first.

  1. Connect the phone to your computer, open a terminal window, and execute the following command to edit the script:
    adb pull /system/bin/b2g.sh
  2. Edit the script to make the changes you want. For example, suppose you'd like to see some logging output (which requires a debug build), then you might add something like:
    export NSPR_LOG_FILE=/data/local/tmp/mylog.txt
    export NSPR_LOG_MODULES=Layers:5
    
  3. Run the following commands to save your updated b2g.sh script to the phone and restart b2g:
    adb shell stop b2g
    adb remount
    adb push b2g.sh /system/bin
    adb shell chmod 0755 /system/bin/b2g.sh
    adb shell start b2g
    

Note: /data/local/tmp is the only place on the filesystem which is writable by content processes.

See also

 

Document Tags and Contributors

 Contributors to this page: chrisdavidmills, staktrace, Sheppy, [email protected]
 Last updated by: chrisdavidmills,